Improve robustness of TestReplication test

This commit is contained in:
Peter Lawrey
2015-05-20 08:21:04 +01:00
parent 6208729f30
commit 9830e0bc42
27 changed files with 85 additions and 101 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import net.openhft.chronicle.map.TcpUtil;
import java.io.Closeable;
import java.io.File;
@@ -61,7 +62,7 @@ public class BGChronicleTest {
File file2 = File.createTempFile("bg-test", ".deleteme");
file2.deleteOnExit();
final InetSocketAddress serverHostPort = new InetSocketAddress("localhost", port);
final InetSocketAddress serverHostPort = TcpUtil.localPort(port);
final TcpTransportAndNetworkConfig clientConfig =
TcpTransportAndNetworkConfig.of(port + 1, serverHostPort)
@@ -23,7 +23,6 @@ import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.concurrent.ExecutionException;
@@ -266,7 +265,7 @@ public class CHMUseCasesTest {
}
{
final TcpTransportAndNetworkConfig tcpConfig2 = TcpTransportAndNetworkConfig.of
(8087, new InetSocketAddress("localhost", 8086))
(8087, TcpUtil.localPort(8086))
.heartBeatInterval(1, TimeUnit.SECONDS)
.tcpBufferSize(1024 * 64);
@@ -27,7 +27,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -53,7 +52,7 @@ public class ChannelReplicationTest {
public void setup() throws IOException {
{
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8086, new InetSocketAddress("localhost", 8087))
.of(8086, TcpUtil.localPort(8087))
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
hubA = ReplicationHub.builder()
@@ -26,7 +26,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -254,7 +253,7 @@ public class EventListenerWithTCPSocketReplicationTest {
}
private ChronicleMapBuilder<Integer, CharSequence> serverBuilder() {
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077))
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8076, TcpUtil.localPort(8077))
.autoReconnectedUponDroppedConnection(true);
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.entries(20000L)
@@ -28,7 +28,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertTrue;
@@ -61,7 +60,7 @@ public class PostChannelCreationTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8086, new InetSocketAddress("localhost", 8087))
.of(8086, TcpUtil.localPort(8087))
.heartBeatInterval(1, SECONDS);
hubA = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
@@ -79,7 +78,7 @@ public class PostChannelCreationTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8087, new InetSocketAddress("localhost", 8086))
.of(8087, TcpUtil.localPort(8086))
.heartBeatInterval(1, SECONDS);
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
@@ -28,7 +28,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertTrue;
@@ -59,7 +58,7 @@ public class SingleMapChannelTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(18086, new InetSocketAddress("localhost", 18087))
.of(18086, TcpUtil.localPort(18087))
.autoReconnectedUponDroppedConnection(true)
.heartBeatInterval(1, SECONDS);
@@ -75,7 +74,7 @@ public class SingleMapChannelTest {
{
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(18087, new InetSocketAddress("localhost", 18086))
.of(18087, TcpUtil.localPort(18086))
.autoReconnectedUponDroppedConnection(true)
.heartBeatInterval(1, SECONDS);
@@ -32,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.concurrent.*;
@@ -120,7 +119,7 @@ public class StatelessClientTest {
try (ChronicleMap<Integer, StringBuilder> statelessMap =
ChronicleMapBuilder
.of(Integer.class, StringBuilder.class, new InetSocketAddress("localhost", port))
.of(Integer.class, StringBuilder.class, TcpUtil.localPort(port))
.putReturnsNull(true)
.create()) {
String actual = statelessMap.getMapped(10, ToString.INSTANCE);
@@ -132,7 +131,7 @@ public class StatelessClientTest {
}
public static <K, V> ChronicleMap<K, V> localClient(int port) throws IOException {
return createClientOf(new InetSocketAddress("localhost", port));
return createClientOf(TcpUtil.localPort(port));
}
@Test(timeout = 10000)
@@ -676,8 +675,7 @@ public class StatelessClientTest {
try (ChronicleMap<Integer, Integer> server2 = ChronicleMapBuilder
.of(Integer.class, Integer.class)
.putReturnsNull(true)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8046, new
InetSocketAddress("localhost", 8047))).create()) {
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8046, TcpUtil.localPort(8047))).create()) {
// stateless client
@@ -25,11 +25,11 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import static net.openhft.chronicle.hash.serialization.internal.DummyValue.DUMMY_VALUE;
import static net.openhft.chronicle.map.Builder.newMapDummyValue;
import static net.openhft.chronicle.map.TcpUtil.localPort;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -47,9 +47,8 @@ public class TCPSocketReplication3VoidValueTest {
@Before
public void setup() throws IOException {
map1 = newMapDummyValue((byte) 1, 8036, new InetSocketAddress("localhost", 8037),
new InetSocketAddress("localhost", 8039));
map2 = newMapDummyValue((byte) 2, 8037, new InetSocketAddress("localhost", 8039));
map1 = newMapDummyValue((byte) 1, 8036, localPort(8037), localPort(8039));
map2 = newMapDummyValue((byte) 2, 8037, localPort(8039));
map3 = newMapDummyValue((byte) 3, 8039);
}
@@ -29,6 +29,7 @@ import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Set;
import static net.openhft.chronicle.map.TcpUtil.localPort;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -58,9 +59,8 @@ public class TCPSocketReplication3wayPutReturnsNullTest {
@Before
public void setup() throws IOException {
map1 = newTcpSocketShmIntString((byte) 1, 8026, new InetSocketAddress("localhost", 8027),
new InetSocketAddress("localhost", 8028));
map2 = newTcpSocketShmIntString((byte) 2, 8027, new InetSocketAddress("localhost", 8028));
map1 = newTcpSocketShmIntString((byte) 1, 8026, localPort(8027), localPort(8028));
map2 = newTcpSocketShmIntString((byte) 2, 8027, localPort(8028));
map3 = newTcpSocketShmIntString((byte) 3, 8028);
}
@@ -24,10 +24,10 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import static net.openhft.chronicle.map.TCPSocketReplication4WayMapTest.newTcpSocketShmIntString;
import static net.openhft.chronicle.map.TcpUtil.localPort;
import static org.junit.Assert.*;
/**
@@ -44,9 +44,8 @@ public class TCPSocketReplication3wayTest {
@Before
public void setup() throws IOException {
map1 = newTcpSocketShmIntString((byte) 1, 8026, new InetSocketAddress("localhost", 8027),
new InetSocketAddress("localhost", 8029));
map2 = newTcpSocketShmIntString((byte) 2, 8027, new InetSocketAddress("localhost", 8029));
map1 = newTcpSocketShmIntString((byte) 1, 8026, localPort(8027), localPort(8029));
map2 = newTcpSocketShmIntString((byte) 2, 8027, localPort(8029));
map3 = newTcpSocketShmIntString((byte) 3, 8029);
}
@@ -29,6 +29,7 @@ import java.net.InetSocketAddress;
import java.util.Set;
import static net.openhft.chronicle.map.Builder.newTcpSocketShmBuilder;
import static net.openhft.chronicle.map.TcpUtil.localPort;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -55,11 +56,9 @@ public class TCPSocketReplication4WayMapTest {
@Before
public void setup() throws IOException {
map1 = newTcpSocketShmIntString((byte) 1, 8086, new InetSocketAddress("localhost", 8087),
new InetSocketAddress("localhost", 8088), new InetSocketAddress("localhost", 8089));
map2 = newTcpSocketShmIntString((byte) 2, 8087, new InetSocketAddress("localhost", 8088),
new InetSocketAddress("localhost", 8089));
map3 = newTcpSocketShmIntString((byte) 3, 8088, new InetSocketAddress("localhost", 8089));
map1 = newTcpSocketShmIntString((byte) 1, 8086, localPort(8087), localPort(8088), localPort(8089));
map2 = newTcpSocketShmIntString((byte) 2, 8087, localPort(8088), localPort(8089));
map3 = newTcpSocketShmIntString((byte) 3, 8088, localPort(8089));
map4 = newTcpSocketShmIntString((byte) 4, 8089);
}
@@ -152,12 +151,12 @@ public class TCPSocketReplication4WayMapTest {
private void waitTillEqual(final int timeOutMs) throws InterruptedException {
int t = 0;
for (; t < timeOutMs; t++) {
if ( map1.equals(map2) &&
map1.equals(map3) &&
map1.equals(map4) &&
map2.equals(map3) &&
map2.equals(map4) &&
map3.equals(map4))
if (map1.equals(map2) &&
map1.equals(map3) &&
map1.equals(map4) &&
map2.equals(map3) &&
map2.equals(map4) &&
map3.equals(map4))
break;
Thread.sleep(1);
}
@@ -27,7 +27,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -55,7 +54,7 @@ public class TCPSocketReplicationBootStrapTest {
ChronicleMapBuilder<Integer, CharSequence> map2aBuilder =
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
(byte) 2, 8092, new InetSocketAddress("localhost", 8091));
(byte) 2, 8092, TcpUtil.localPort(8091));
final ChronicleMap<Integer, CharSequence> map2a =
map2aBuilder.createPersistedTo(getPersistenceFile());
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
@@ -92,7 +91,7 @@ public class TCPSocketReplicationBootStrapTest {
public void testBootstrapAndHeartbeat() throws IOException, InterruptedException {
TcpTransportAndNetworkConfig map1Config = TcpTransportAndNetworkConfig
.of(8068, Arrays.asList(new InetSocketAddress("localhost", 8067)))
.of(8068, Arrays.asList(TcpUtil.localPort(8067)))
.heartBeatInterval(1L, TimeUnit.SECONDS)
.autoReconnectedUponDroppedConnection(true);
@@ -24,12 +24,10 @@ import net.openhft.lang.model.DataValueClasses;
import net.openhft.lang.values.IntValue;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.Random;
import java.util.Set;
@@ -58,7 +56,7 @@ public class TCPSocketReplicationIntValueTest {
value = DataValueClasses.newDirectReference(IntValue.class);
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
map1Builder = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
(byte) 1, s_port, new InetSocketAddress("localhost", s_port + 1));
(byte) 1, s_port, TcpUtil.localPort(s_port + 1));
map1 = map1Builder.createPersistedTo(getPersistenceFile());
map2 = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
(byte) 2, s_port + 1)
@@ -47,7 +47,7 @@ public class TCPSocketReplicationNativeTest {
@Before
public void setup() throws IOException {
InetSocketAddress endpoint = new InetSocketAddress("localhost", 8077);
InetSocketAddress endpoint = TcpUtil.localPort(8077);
TcpTransportAndNetworkConfig tcpConfig1 = TcpTransportAndNetworkConfig.of(8076, endpoint)
.heartBeatInterval(1L, TimeUnit.SECONDS).autoReconnectedUponDroppedConnection(true);
@@ -24,7 +24,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import static net.openhft.chronicle.map.Builder.newTcpSocketShmBuilder;
@@ -63,7 +62,7 @@ public class TCPSocketReplicationPostConnectionTest {
map1.put(5, "EXAMPLE-2");
Thread.sleep(10);
map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, port + 1,
new InetSocketAddress("localhost", port));
TcpUtil.localPort(port));
// allow time for the recompilation to resolve
waitTillEqual(15000);
@@ -79,7 +78,7 @@ public class TCPSocketReplicationPostConnectionTest {
map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, port);
map1.put(5, "EXAMPLE-2");
map2 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 2, port + 1,
new InetSocketAddress("localhost", port));
TcpUtil.localPort(port));
// allow time for the recompilation to resolve
waitTillEqual(1000);
@@ -95,7 +94,7 @@ public class TCPSocketReplicationPostConnectionTest {
ChronicleMapBuilder<Integer, CharSequence> map2aBuilder =
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
(byte) 2, port + 1, new InetSocketAddress("localhost", port));
(byte) 2, port + 1, TcpUtil.localPort(port));
try (final ChronicleMap<Integer, CharSequence> map2a =
map2aBuilder.createPersistedTo(Builder.getPersistenceFile())) {
map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, port);
@@ -25,7 +25,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@@ -52,7 +51,7 @@ public class TCPSocketReplicationTest {
int port = s_port;
ChronicleMapBuilder<Integer, CharSequence> map1Builder =
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
(byte) 1, port, new InetSocketAddress("localhost", port + 1));
(byte) 1, port, TcpUtil.localPort(port + 1));
map1 = map1Builder.entries(Builder.SIZE).averageValueSize(10).create();
ChronicleMapBuilder<Integer, CharSequence> map2Builder =
@@ -37,7 +37,7 @@ public class TcpReplicationLargeEntryTest {
Arrays.fill(valueX, 'Y');
String sampleValue = new String(valueX);
final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1);
final InetSocketAddress endpoint = TcpUtil.localPort(s_port + 1);
{
final TcpTransportAndNetworkConfig tcpConfig1 = TcpTransportAndNetworkConfig.of(s_port,
@@ -35,7 +35,7 @@ public class TcpReplicationSoakTest {
value = DataValueClasses.newDirectReference(IntValue.class);
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1);
final InetSocketAddress endpoint = TcpUtil.localPort(s_port + 1);
{
final TcpTransportAndNetworkConfig tcpConfig1 = TcpTransportAndNetworkConfig.of(s_port,
@@ -34,7 +34,7 @@ public class TcpTimeBasedReplicationSoakTest {
value = DataValueClasses.newDirectReference(IntValue.class);
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
final InetSocketAddress endpoint = new InetSocketAddress("localhost", s_port + 1);
final InetSocketAddress endpoint = TcpUtil.localPort(s_port + 1);
timeProvider = new TimeProvider() {
Random rnd = new Random(4);
@@ -0,0 +1,17 @@
package net.openhft.chronicle.map;
import org.jetbrains.annotations.NotNull;
import java.net.InetSocketAddress;
/**
* Created by peter on 20/05/15.
*/
public enum TcpUtil {
;
@NotNull
public static InetSocketAddress localPort(int port) {
return new InetSocketAddress("localhost", port);
}
}
@@ -8,7 +8,6 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
@@ -47,7 +46,7 @@ public class TestEntriesSpanningSeveralChunksReplicationHub {
byte identifier = (byte) 1;
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8021, new InetSocketAddress("localhost", 8022))
.of(8021, TcpUtil.localPort(8022))
.heartBeatInterval(1, TimeUnit.SECONDS);
ReplicationHub hubOnServer1 = ReplicationHub.builder()
@@ -181,7 +180,7 @@ public class TestEntriesSpanningSeveralChunksReplicationHub {
byte identifier = (byte) 2;
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8054, new InetSocketAddress("localhost", 8059));
.of(8054, TcpUtil.localPort(8059));
hubOnServer2 = ReplicationHub.builder()
.tcpTransportAndNetwork(tcpConfig)
@@ -350,8 +349,7 @@ public class TestEntriesSpanningSeveralChunksReplicationHub {
byte identifier = (byte) 2;
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8026, new
InetSocketAddress("localhost", 8025)); // change the localhost to your server
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8026, TcpUtil.localPort(8025)); // change the localhost to your server
ReplicationHub hubOnServer1 = ReplicationHub.builder()
.tcpTransportAndNetwork(tcpConfig)
@@ -1,57 +1,43 @@
package net.openhft.chronicle.map;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import org.junit.Assert;
import org.junit.Test;
import java.net.InetSocketAddress;
/**
* Created by Rob Austin
*/
public class TestReplication {
@Test
public void testAllDataGetsReplicated() throws InterruptedException {
TcpTransportAndNetworkConfig tcpConfigServer1 =
TcpTransportAndNetworkConfig.of(8082);
TcpTransportAndNetworkConfig tcpConfigServer2 =
TcpTransportAndNetworkConfig.of(8083, new InetSocketAddress("localhost",
8082));
TcpTransportAndNetworkConfig.of(8083, TcpUtil.localPort(8082));
final ChronicleMap<Integer, Integer> map2 = ChronicleMapBuilder.of(Integer.class,
Integer.class)
final ChronicleMap<Integer, Integer> map2 = ChronicleMapBuilder
.of(Integer.class, Integer.class)
.replication((byte) 2, tcpConfigServer2)
.create();
final ChronicleMap<Integer, Integer> map1 = ChronicleMapBuilder.of(Integer.class,
Integer.class)
final ChronicleMap<Integer, Integer> map1 = ChronicleMapBuilder
.of(Integer.class, Integer.class)
.replication((byte) 3, tcpConfigServer1)
.create();
for (int i = 0; i < 70000; i++) {
for (int i = 0; i < 500000; i++) {
map1.put(i, i);
}
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 50; i++) {
Thread.sleep(100);
System.out.println(map2.size());
if (map2.size() == map1.size())
break;
}
Assert.assertEquals(map1.size(),map2.size());
Assert.assertEquals(map1.size(), map2.size());
}
}
@@ -28,7 +28,6 @@ import org.mockito.Mockito;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
@@ -78,7 +77,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase {
.entries(10)
.timeProvider(timeProvider)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8087,
new InetSocketAddress("localhost", 8086)))
TcpUtil.localPort(8086)))
.create()) {
current(timeProvider);
@@ -197,7 +196,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase {
.entries(10)
.timeProvider(timeProvider)
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8087,
new InetSocketAddress("localhost", 8086)))
TcpUtil.localPort(8086)))
.create()) {
current(timeProvider);
@@ -25,7 +25,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Set;
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -44,7 +43,7 @@ public class TwoMapOnDifferentServersTest {
public void setup() throws IOException {
final TcpTransportAndNetworkConfig tcpConfig =
TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077))
TcpTransportAndNetworkConfig.of(8076, TcpUtil.localPort(8077))
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
@@ -23,11 +23,11 @@ import net.openhft.chronicle.hash.replication.ReplicationHub;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.ChronicleMap;
import net.openhft.chronicle.map.ChronicleMapBuilder;
import net.openhft.chronicle.map.TcpUtil;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.net.InetSocketAddress;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertEquals;
@@ -59,7 +59,7 @@ public class ChannelReplicationTest {
byte identifier = (byte) 1;
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8086, new InetSocketAddress("localhost", 8087))
.of(8086, TcpUtil.localPort(8087))
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
hubOnServer1 = ReplicationHub.builder()
@@ -186,7 +186,7 @@ public class ChannelReplicationTest {
byte identifier = (byte) 6;
TcpTransportAndNetworkConfig tcpConfig =
TcpTransportAndNetworkConfig.of(8087, new InetSocketAddress("localhost", 8086))
TcpTransportAndNetworkConfig.of(8087, TcpUtil.localPort(8086))
.heartBeatInterval(1, SECONDS)
.autoReconnectedUponDroppedConnection(true);
@@ -210,7 +210,7 @@ public class ChannelReplicationTest {
byte identifier = (byte) 3;
TcpTransportAndNetworkConfig tcpConfig =
TcpTransportAndNetworkConfig.of(8088, new InetSocketAddress("localhost", 8086))
TcpTransportAndNetworkConfig.of(8088, TcpUtil.localPort(8086))
.heartBeatInterval(1, SECONDS)
.autoReconnectedUponDroppedConnection(true);
@@ -267,7 +267,7 @@ public class ChannelReplicationTest {
byte identifier = (byte) 1;
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.of(8086, new InetSocketAddress("localhost", 8087))
.of(8086, TcpUtil.localPort(8087))
.heartBeatInterval(1, SECONDS)
.autoReconnectedUponDroppedConnection(true);
@@ -21,7 +21,6 @@ package net.openhft.chronicle.map.jsr166.map;
import net.openhft.chronicle.hash.function.SerializableFunction;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.*;
import net.openhft.chronicle.map.MapKeyContext;
import net.openhft.chronicle.map.jsr166.JSR166TestCase;
import org.jetbrains.annotations.NotNull;
import org.junit.After;
@@ -32,7 +31,6 @@ import org.junit.Test;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.function.Consumer;
@@ -281,7 +279,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
.create();
final ChronicleMap<byte[], byte[]> statelessMap = ChronicleMapBuilder
.of(byte[].class, byte[].class, new InetSocketAddress("localhost", port))
.of(byte[].class, byte[].class, TcpUtil.localPort(port))
.putReturnsNull(true)
.create();
@@ -19,6 +19,7 @@
package net.openhft.chronicle.set;
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
import net.openhft.chronicle.map.TcpUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -57,9 +58,9 @@ public class SetForTCPSocketReplication3wayTest {
@Before
public void setup() throws IOException {
set1 = newTcpSocketIntSet((byte) 1, 18076, new InetSocketAddress("localhost", 18077),
new InetSocketAddress("localhost", 18079));
set2 = newTcpSocketIntSet((byte) 2, 18077, new InetSocketAddress("localhost", 18079));
set1 = newTcpSocketIntSet((byte) 1, 18076, TcpUtil.localPort(18077),
TcpUtil.localPort(18079));
set2 = newTcpSocketIntSet((byte) 2, 18077, TcpUtil.localPort(18079));
set3 = newTcpSocketIntSet((byte) 3, 18079);
}