mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-134 changed the default so that is does not autoReconnectedUponDroppedConnection, however it better if most of the test cases have this can you can guarantee that the server is ready to accept TCP/IP before the client.
This commit is contained in:
@@ -73,7 +73,7 @@ public class Builder {
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints))
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS);
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
return ChronicleMapBuilder.of(kClass, vClass)
|
||||
.replication(identifier, tcpConfig);
|
||||
}
|
||||
|
||||
+4
-2
@@ -238,7 +238,8 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
}
|
||||
|
||||
private ChronicleMapBuilder<Integer, CharSequence> clientBuilder() {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8077);
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8077)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 1, tcpConfig)
|
||||
@@ -257,7 +258,8 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
}
|
||||
|
||||
private ChronicleMapBuilder<Integer, CharSequence> serverBuilder() {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077));
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077))
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 2, tcpConfig);
|
||||
|
||||
@@ -94,23 +94,25 @@ public class MapByNameTest {
|
||||
final ReplicationHubFindByName<CharSequence> mapByName = nodeDiscovery.mapByName();
|
||||
Thread.sleep(2000);
|
||||
|
||||
ChronicleMapBuilder<CharSequence, CharSequence> builder = ChronicleMapBuilder.of(CharSequence
|
||||
ChronicleMapBuilder<CharSequence, CharSequence> builder = ChronicleMapBuilder.of(CharSequence
|
||||
.class, CharSequence.class)
|
||||
.minSegments(2)
|
||||
.entries(2)
|
||||
.name("myMap5")
|
||||
.name("myMap6")
|
||||
.removeReturnsNull(true);
|
||||
|
||||
ChronicleMap<String, String> map = mapByName.create(builder);
|
||||
map.put("hello", "world");
|
||||
ChronicleMap<String, String> map = mapByName.create(builder);
|
||||
map.put("hello", "world");
|
||||
|
||||
// final ChronicleMap<CharSequence, CharSequence> map = mapByName.from("myMap5");
|
||||
// final ChronicleMap<CharSequence, CharSequence> map = mapByName.from("myMap5");
|
||||
|
||||
|
||||
// allow time for replication
|
||||
Thread.sleep(2000);
|
||||
System.out.print(map);
|
||||
|
||||
map.close();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -48,7 +48,8 @@ public class TCPSocketReplication3wayPutReturnsNullTest {
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints));
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints))
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
return (T) ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -25,6 +26,8 @@ import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.map.Builder.newTcpSocketShmBuilder;
|
||||
@@ -87,12 +90,22 @@ public class TCPSocketReplicationBootStrapTest {
|
||||
@Test
|
||||
public void testBootstrapAndHeartbeat() throws IOException, InterruptedException {
|
||||
|
||||
map1 = newTcpSocketShmIntString((byte) 1, 8068, new InetSocketAddress("localhost", 8067));
|
||||
TcpTransportAndNetworkConfig map1Config = TcpTransportAndNetworkConfig.of(8068, Arrays.asList(new InetSocketAddress("localhost", 8067)))
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).name("map1").autoReconnectedUponDroppedConnection
|
||||
(true);
|
||||
|
||||
map1 = (ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?>) ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 1, map1Config).create();
|
||||
|
||||
File persistenceFile = getPersistenceFile();
|
||||
|
||||
TcpTransportAndNetworkConfig map2Config = TcpTransportAndNetworkConfig.of(8067)
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).name("map2");
|
||||
|
||||
final ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?> map2a =
|
||||
(ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?>)
|
||||
newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8067).createPersistedTo(persistenceFile);
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, map2Config).createPersistedTo(persistenceFile);
|
||||
|
||||
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
|
||||
|
||||
@@ -106,6 +119,7 @@ public class TCPSocketReplicationBootStrapTest {
|
||||
|
||||
map2a.close();
|
||||
|
||||
|
||||
{
|
||||
// restart map 2 but does not connect it to map1
|
||||
final ChronicleMap<Integer, CharSequence> map2b = ChronicleMapBuilder.of(Integer.class,
|
||||
@@ -116,10 +130,13 @@ public class TCPSocketReplicationBootStrapTest {
|
||||
}
|
||||
|
||||
// now restart map2a and doConnect it to map1, map1 should bootstrap the missing entry
|
||||
map2 = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8067).createPersistedTo(persistenceFile);
|
||||
TcpTransportAndNetworkConfig tcpConfigNewMap2 = TcpTransportAndNetworkConfig.of(8067)
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).name("newMap2");
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, tcpConfigNewMap2).createPersistedTo(persistenceFile);
|
||||
|
||||
// add data into it
|
||||
waitTillEqual(20000);
|
||||
waitTillEqual(20000000);
|
||||
assertEquals("ADDED WHEN DISCONNECTED TO MAP1", map1.get(11));
|
||||
|
||||
|
||||
|
||||
@@ -51,13 +51,13 @@ public class TCPSocketReplicationNativeTest {
|
||||
InetSocketAddress endpoint = new InetSocketAddress("localhost", 8077);
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig1 = TcpTransportAndNetworkConfig.of(8076, endpoint)
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS);
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
map1 = ChronicleMapBuilder.of(Integer.class, LongValue.class)
|
||||
.replication((byte) 1, tcpConfig1).create();
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig2 = TcpTransportAndNetworkConfig.of(8077)
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS);
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, LongValue.class)
|
||||
.replication((byte) 2, tcpConfig2).create();
|
||||
|
||||
@@ -45,17 +45,19 @@ public class TwoMapOnDifferentServersTest {
|
||||
|
||||
final TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
|
||||
map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.replication((byte) 1, tcpConfig).create();
|
||||
|
||||
TcpTransportAndNetworkConfig config2 = TcpTransportAndNetworkConfig.of(8077)
|
||||
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.of(8077)
|
||||
.heartBeatInterval(1, SECONDS)).create();
|
||||
.replication((byte) 2, config2).create();
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ChannelReplicationTest {
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
|
||||
hubOnServer1 = ReplicationHub.builder()
|
||||
@@ -96,7 +96,8 @@ public class ChannelReplicationTest {
|
||||
byte identifier = (byte) 2;
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.of(8087).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig.of(8087).heartBeatInterval(1, SECONDS)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
hubOnServer2 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
@@ -166,7 +167,7 @@ public class ChannelReplicationTest {
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.of(8086)
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
.heartBeatInterval(1, SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
|
||||
hubOnServer1 = ReplicationHub.builder()
|
||||
@@ -201,7 +202,9 @@ public class ChannelReplicationTest {
|
||||
byte identifier = (byte) 6;
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.of(8087, new InetSocketAddress("localhost", 8086)).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig.of(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
ReplicationHub hubOnServer = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
@@ -224,7 +227,9 @@ public class ChannelReplicationTest {
|
||||
byte identifier = (byte) 3;
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.of(8088, new InetSocketAddress("localhost", 8086)).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig.of(8088, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
ReplicationHub hubOnServer3 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
@@ -290,7 +295,8 @@ public class ChannelReplicationTest {
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
.heartBeatInterval(1, SECONDS)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
|
||||
hubOnServer1 = ReplicationHub.builder()
|
||||
@@ -324,7 +330,8 @@ public class ChannelReplicationTest {
|
||||
byte identifier = (byte) 2;
|
||||
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.of(8087).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig.of(8087).heartBeatInterval(1, SECONDS)
|
||||
.autoReconnectedUponDroppedConnection(true);
|
||||
|
||||
hubOnServer2 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SetForTCPSocketReplication3wayTest {
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return (T) ChronicleSetBuilder.of(Integer.class)
|
||||
.replication(identifier, TcpTransportAndNetworkConfig.of(serverPort, asList(endpoints))
|
||||
.heartBeatInterval(1L, SECONDS))
|
||||
.heartBeatInterval(1L, SECONDS).autoReconnectedUponDroppedConnection(true))
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user