Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,7 @@
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.apache.commons.io.IOUtils;
import org.apache.ignite.marshaller.Marshaller;
import org.jetbrains.annotations.Nullable;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* IO test utilities.
Expand Down Expand Up @@ -141,49 +134,6 @@ public static <T> T externalize(Externalizable obj, Marshaller marshaller) throw
return (T)marshaller.unmarshal(buf, obj.getClass().getClassLoader());
}

/**
* Validate streams generate the same output.
*
* @param expIn Expected input stream.
* @param actIn Actual input stream.
* @param expSize Expected size of the streams.
* @throws IOException In case of any IO exception.
*/
public static void assertEqualStreams(InputStream expIn, InputStream actIn,
@Nullable Long expSize) throws IOException {
int bufSize = 2345;
byte buf1[] = new byte[bufSize];
byte buf2[] = new byte[bufSize];
long pos = 0;

while (true) {
int i1 = actIn.read(buf1, 0, bufSize);

int i2;

if (i1 == -1) // Expects EOF?
i2 = expIn.read(buf2, 0, 1); // Try to read at least 1 byte guaranted by stream's API.
else
IOUtils.readFully(expIn, buf2, 0, i2 = i1); // Read the same bytes count as from actual stream.

if (i1 != i2)
fail("Expects the same data [pos=" + pos + ", i1=" + i1 + ", i2=" + i2 + ']');

if (i1 == -1)
break; // EOF

// i1 == bufSize => compare buffers.
// i1 < bufSize => Compare part of buffers, rest of buffers are equal from previous iteration.
assertTrue("Expects the same data [pos=" + pos + ", i1=" + i1 + ", i2=" + i2 + ']',
Arrays.equals(buf1, buf2));

pos += i1;
}

if (expSize != null)
assertEquals(expSize.longValue(), pos);
}

/**
* Gets short value from byte array assuming that value stored in little-endian byte order.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
Expand All @@ -33,11 +31,7 @@
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
import org.apache.ignite.internal.processors.cache.CacheGroupContext;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.lang.IgniteBiPredicate;
Expand Down Expand Up @@ -241,21 +235,6 @@ private void doRebalanceAfterPartitionsWereLost(boolean reactivateGridBeforeRese
assertEquals(CACHE_NAMES.length * CACHE_SIZE, averageSizeAroundAllNodes());
}

/**
* @param gridNumber Grid number.
* @param cacheName Cache name.
* @return Partitions states for given cache name.
*/
private List<GridDhtPartitionState> getPartitionsStates(int gridNumber, String cacheName) {
CacheGroupContext cgCtx = grid(gridNumber).context().cache().cacheGroup(CU.cacheId(cacheName));

GridDhtPartitionTopologyImpl top = (GridDhtPartitionTopologyImpl)cgCtx.topology();

return top.localPartitions().stream()
.map(GridDhtLocalPartition::state)
.collect(Collectors.toList());
}

/**
* Checks that all nodes see the correct size.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,6 @@ private TxThread(
this.key2 = key2;
}

/**
* @param ignite Ignite.
* @param key1 key 1.
* @param key2 key 2.
*/
private TxThread(final Ignite ignite, final int key1, final int key2) {
commitAllowLatch = new CountDownLatch(0);
transactionStartLatch = new CountDownLatch(1);

this.ignite = ignite;
this.key1 = key1;
this.key2 = key2;
}

/** {@inheritDoc} */
@Override public void run() {
try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,6 @@ private List<?> dataToTest() {
);
}

/** */
private void putRegularGetInBinary(IgniteCache<Object, Object> c) {
List<?> vals = dataToTest();

for (Object val : vals) {
c.put(1, val);

Object obj = c.withKeepBinary().get(1);

assertEquals(useBinaryArrays ? BinaryArray.class : Object[].class, obj.getClass());

if (useBinaryArrays)
assertEquals(val.getClass(), ((BinaryObject)obj).deserialize().getClass());

assertTrue(c.remove(1));
}
}

/** */
private void putInBinaryGetRegular(CacheAdapter<Object, Object> c) {
Runnable checker = () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4081,17 +4081,6 @@ private <T extends Enum<?>> Integer[] binaryOrdinals(Object fld) {
return ords;
}

/**
* @param po Binary object.
* @param off Offset.
* @return Value.
*/
private int intFromBinary(BinaryObject po, int off) {
byte[] arr = U.field(po, "arr");

return Integer.reverseBytes(U.bytesToInt(arr, off));
}

/**
* @param obj Original object.
* @return Result object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,45 +274,6 @@ public void testOverrideIdMapperFullNameMapper() throws Exception {
checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
}

/**
*
* @param nameMapper Name mapper.
* @param mapper Mapper.
* @throws IgniteCheckedException If failed.
*/
private void checkOverrideIdMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();

typeCfg.setTypeName(CLASS2_FULL_NAME);
typeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return 100;
}

@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
});

BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
typeCfg));

BinaryContext ctx = binaryContext(marsh);

Map<Integer, Class> typeIds = U.field(ctx, "userTypes");

assertEquals(3, typeIds.size());

assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
assertTrue(typeIds.containsKey(100));

Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");

assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}

/**
* @throws Exception If failed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ private static Collection<Object> createObjectsOfAllTypes(BinaryContext ctx) thr
return res;
}

/** */
private Object createTestObject() {
TestObjectAllTypes res = new TestObjectAllTypes();

res.setDefaultData();

return res;
}

/** */
private interface RegisteredClass { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

package org.apache.ignite.internal.binary.mutabletest;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand All @@ -33,7 +29,6 @@
import java.util.Objects;
import java.util.TreeMap;
import java.util.UUID;
import com.google.common.base.Throwables;
import org.apache.ignite.binary.BinaryMapFactory;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
Expand Down Expand Up @@ -249,26 +244,6 @@ public static class TestObjectAllTypes implements Serializable {
/** */
public Map.Entry entry;

/**
* @return Array.
*/
private byte[] serialize() {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();

try {
ObjectOutput out = new ObjectOutputStream(byteOut);

out.writeObject(this);

out.close();
}
catch (IOException e) {
Throwables.propagate(e);
}

return byteOut.toByteArray();
}

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,5 @@ private static class MockLogger extends GridTestLog4jLogger {
public List<String> logs() {
return logs;
}

/** */
public void clear() {
logs.clear();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,6 @@ public void testRemoteNodeSecurityContext() throws Exception {
}
}

/**
* @param passwd User's password to check.
*/
private void checkInvalidPassword(final String passwd) {
assertThrows(() -> asRoot(grid(CLI_NODE), s -> s.createUser("test", passwd.toCharArray())), "Invalid user name");
}

/**
* @param createNode Node to execute create operation.
* @param authNode Node to execute authentication.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ private void createCaches(boolean statisticsEnabled) {
cache2 = grid(0).getOrCreateCache(ccfg2);
}

/**
* Closes caches.
*/
private void destroyCaches() {
cache1.destroy();
cache2.destroy();
}

/**
* @param cache Cache.
* @param cnt Count.
Expand Down
Loading
Loading