mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-246 added test for - Tcp Replication fails with large values or entries sizes that don't " +
"included internal replication bytes
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.lang.io.ByteBufferBytes;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueClasses;
|
||||
import net.openhft.lang.values.IntValue;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -25,13 +20,19 @@ public class TcpReplicationSoakTest {
|
||||
|
||||
private ChronicleMap<Integer, CharSequence> map1;
|
||||
private ChronicleMap<Integer, CharSequence> map2;
|
||||
private IntValue value;
|
||||
|
||||
static int s_port = 8010;
|
||||
int valueSize = 1000000;
|
||||
|
||||
char[] value = new char[valueSize];
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
value = DataValueClasses.newDirectReference(IntValue.class);
|
||||
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
|
||||
Arrays.fill(value, 'X');
|
||||
|
||||
int keySize = 4;
|
||||
int entrySize = keySize + valueSize;
|
||||
|
||||
final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1);
|
||||
|
||||
@@ -43,7 +44,7 @@ public class TcpReplicationSoakTest {
|
||||
|
||||
|
||||
map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(Builder.SIZE + Builder.SIZE)
|
||||
.entries(entrySize)
|
||||
.actualSegments(1)
|
||||
.replication((byte) 1, tcpConfig1)
|
||||
.instance()
|
||||
@@ -57,7 +58,7 @@ public class TcpReplicationSoakTest {
|
||||
.packetSize(1024 * 64);
|
||||
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(Builder.SIZE + Builder.SIZE)
|
||||
.entries(entrySize)
|
||||
.replication((byte) 2, tcpConfig2)
|
||||
.instance()
|
||||
.name("map2")
|
||||
@@ -94,26 +95,13 @@ public class TcpReplicationSoakTest {
|
||||
StatelessClientTest.checkThreadsShutdown(threads);
|
||||
}
|
||||
|
||||
|
||||
@Ignore("HCOLL-246 Tcp Replication fails with large values or entries sizes that don't " +
|
||||
"included internal replication bytes")
|
||||
@Test
|
||||
public void testSoakTestWithRandomData() throws IOException, InterruptedException {
|
||||
public void testLargeValues() throws IOException, InterruptedException {
|
||||
|
||||
System.out.print("SoakTesting ");
|
||||
for (int j = 1; j < 2 * Builder.SIZE; j++) {
|
||||
if (j % 100 == 0)
|
||||
System.out.print(".");
|
||||
Random rnd = new Random(j);
|
||||
for (int i = 1; i < 10; i++) {
|
||||
final int select = rnd.nextInt(2);
|
||||
final ChronicleMap<Integer, CharSequence> map = select > 0 ? map1 : map2;
|
||||
map1.put(1, new String(value));
|
||||
|
||||
if (rnd.nextBoolean()) {
|
||||
map.put(rnd.nextInt(Builder.SIZE), "test" + j);
|
||||
} else {
|
||||
map.remove(rnd.nextInt(Builder.SIZE));
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
System.out.println("\nwaiting till equal");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user