mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Merge remote-tracking branch 'origin/master'
Conflicts: src/main/java/net/openhft/chronicle/hash/ChronicleHash.java
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -72,7 +72,7 @@ public class Builder {
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints))
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.forUnknownTopology(serverPort, Arrays.asList(endpoints))
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS);
|
||||
return ChronicleMapBuilder.of(kClass, vClass)
|
||||
.replication(identifier, tcpConfig);
|
||||
|
||||
@@ -81,7 +81,7 @@ public class CHMMetaDataTest {
|
||||
|
||||
@Override
|
||||
public void onPut(ChronicleMap<String, String> map, Bytes entry, int metaDataBytes,
|
||||
boolean added, String key, String value, long pos,
|
||||
boolean added, String key, String replacedValue, String value, long pos,
|
||||
SharedSegment segment) {
|
||||
assertEquals(8, metaDataBytes);
|
||||
if (added)
|
||||
|
||||
@@ -20,7 +20,7 @@ package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -53,13 +53,13 @@ public class ChannelReplicationTest {
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
{
|
||||
TcpConfig tcpConfig = TcpConfig
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubA = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 1);
|
||||
.createWithId((byte) 1);
|
||||
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
@@ -67,11 +67,11 @@ public class ChannelReplicationTest {
|
||||
}
|
||||
|
||||
{
|
||||
TcpConfig tcpConfig =
|
||||
TcpConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 2);
|
||||
.createWithId((byte) 2);
|
||||
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
|
||||
+118
-134
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
@@ -30,20 +30,49 @@ import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.TcpConfig.forSendingNode;
|
||||
import static net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig.forSendingNode;
|
||||
|
||||
/**
|
||||
* Test ReplicatedChronicleMap where the Replicated is over a TCP Socket
|
||||
*
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
|
||||
public class EventListenerTestWithTCPSocketReplication {
|
||||
|
||||
|
||||
ChronicleMap<Integer, CharSequence> map1;
|
||||
ChronicleMap<Integer, CharSequence> map2;
|
||||
|
||||
final AtomicReference<Integer> keyRef = new AtomicReference<Integer>();
|
||||
|
||||
final AtomicReference<CharSequence> replacedValueRef = new AtomicReference<CharSequence>();
|
||||
final AtomicReference<CharSequence> valueRef = new AtomicReference<CharSequence>();
|
||||
final AtomicBoolean putWasCalled = new AtomicBoolean(false);
|
||||
|
||||
final AtomicBoolean wasRemoved = new AtomicBoolean(false);
|
||||
final AtomicReference<CharSequence> valueRemoved = new AtomicReference<CharSequence>();
|
||||
|
||||
final MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>> eventListener = new
|
||||
MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onPut(ChronicleMap<Integer, CharSequence> map, Bytes entry, int metaDataBytes, boolean added, Integer key,
|
||||
CharSequence value, CharSequence replacedValue) {
|
||||
putWasCalled.getAndSet(true);
|
||||
keyRef.set(key);
|
||||
valueRef.set(value);
|
||||
replacedValueRef.set(replacedValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(ChronicleMap<Integer, CharSequence> map, Bytes entry, int metaDataBytes, Integer key, CharSequence value) {
|
||||
wasRemoved.set(true);
|
||||
valueRemoved.set(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
@@ -54,8 +83,12 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Thread.sleep(1600);
|
||||
wasRemoved.set(false);
|
||||
valueRemoved.set(null);
|
||||
putWasCalled.set(false);
|
||||
valueRef.set(null);
|
||||
replacedValueRef.set(null);
|
||||
keyRef.set(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,60 +96,26 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
public void testAdded() throws IOException, InterruptedException {
|
||||
|
||||
|
||||
final AtomicBoolean putWasCalled = new AtomicBoolean(false);
|
||||
|
||||
final AtomicReference<Integer> keyRef = new AtomicReference<Integer>();
|
||||
|
||||
|
||||
final AtomicReference<CharSequence> valueRef = new AtomicReference<CharSequence>();
|
||||
|
||||
MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>> eventListener = new MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onPut(ChronicleMap<Integer, CharSequence> map, Bytes entry, int metaDataBytes, boolean added, Integer key,
|
||||
CharSequence value) {
|
||||
putWasCalled.getAndSet(true);
|
||||
keyRef.set(key);
|
||||
valueRef.set(value);
|
||||
}
|
||||
};
|
||||
|
||||
// ---------- SERVER1 1 ----------
|
||||
{
|
||||
|
||||
// we connect the maps via a TCP socket connection on port 8077
|
||||
|
||||
TcpConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 2, tcpConfig);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder = serverBuilder();
|
||||
|
||||
map1 = map1Builder.create();
|
||||
}
|
||||
// ---------- SERVER2 2 on the same server as ----------
|
||||
|
||||
{
|
||||
TcpConfig tcpConfig = TcpConfig.forReceivingOnlyNode(8077);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 1, tcpConfig)
|
||||
.eventListener(eventListener);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2Builder = clientBuilder();
|
||||
|
||||
map2 = map2Builder.create();
|
||||
}
|
||||
|
||||
// we will stores some data into one map here
|
||||
map1.put(5, "EXAMPLE");
|
||||
int t = 0;
|
||||
for (; t < 5000; t++) {
|
||||
if (map1.equals(map2)) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1);
|
||||
}
|
||||
waitTillReplicated();
|
||||
|
||||
Assert.assertEquals("Maps should be equal", map1, map2);
|
||||
Assert.assertTrue("Map 1 should not be empty", !map1.isEmpty());
|
||||
@@ -126,141 +125,130 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
Assert.assertEquals(Integer.valueOf(5), keyRef.get());
|
||||
Assert.assertEquals("EXAMPLE", valueRef.get());
|
||||
|
||||
keyRef.set(null);
|
||||
valueRef.set(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddedOriginalValueToBeOverWritten() throws IOException, InterruptedException {
|
||||
|
||||
|
||||
final AtomicBoolean putWasCalled = new AtomicBoolean(false);
|
||||
|
||||
final AtomicReference<Integer> keyRef = new AtomicReference<Integer>();
|
||||
|
||||
|
||||
final AtomicReference<CharSequence> valueRef = new AtomicReference<CharSequence>();
|
||||
|
||||
MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>> eventListener = new MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onPut(ChronicleMap<Integer, CharSequence> map, Bytes entry, int metaDataBytes, boolean added, Integer key,
|
||||
CharSequence value) {
|
||||
putWasCalled.getAndSet(true);
|
||||
keyRef.set(key);
|
||||
valueRef.set(value);
|
||||
}
|
||||
};
|
||||
public void testRemoteNotifyPutLargerValue() throws IOException, InterruptedException {
|
||||
|
||||
// ---------- SERVER1 1 ----------
|
||||
{
|
||||
|
||||
// we connect the maps via a TCP socket connection on port 8077
|
||||
|
||||
TcpConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 2, tcpConfig);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder = serverBuilder();
|
||||
|
||||
map1 = map1Builder.create();
|
||||
|
||||
|
||||
}
|
||||
// ---------- SERVER2 2 on the same server as ----------
|
||||
|
||||
{
|
||||
TcpConfig tcpConfig = TcpConfig.forReceivingOnlyNode(8077);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 1, tcpConfig)
|
||||
.eventListener(eventListener);
|
||||
|
||||
map2 = map2Builder.create();
|
||||
map2 = clientBuilder().create();
|
||||
map2.put(5, "WILL_GET_OVER-WRITTEN");
|
||||
}
|
||||
|
||||
|
||||
// we will stores some data into one map here
|
||||
map1.put(5, "EXAMPLE");
|
||||
int t = 0;
|
||||
for (; t < 5000; t++) {
|
||||
if (map1.equals(map2)) {
|
||||
break;
|
||||
}
|
||||
Thread.sleep(1);
|
||||
}
|
||||
waitTillReplicated();
|
||||
|
||||
Assert.assertEquals("Maps should be equal", map1, map2);
|
||||
Assert.assertTrue("Map 1 should not be empty", !map1.isEmpty());
|
||||
Assert.assertTrue("Map 2 should not be empty", !map2.isEmpty());
|
||||
|
||||
Assert.assertTrue("The eventListener.onPut should have been called", putWasCalled.get());
|
||||
Assert.assertEquals(Integer.valueOf(5), keyRef.get());
|
||||
Assert.assertEquals("EXAMPLE", valueRef.get());
|
||||
|
||||
keyRef.set(null);
|
||||
valueRef.set(null);
|
||||
Assert.assertEquals("WILL_GET_OVER-WRITTEN", replacedValueRef.get());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAlreadyAddedWithSmallInitialValue() throws IOException, InterruptedException {
|
||||
public void testRemoteNotifyPutSmallerValue() throws IOException, InterruptedException {
|
||||
|
||||
|
||||
final AtomicBoolean putWasCalled = new AtomicBoolean(false);
|
||||
|
||||
final AtomicReference<Integer> keyRef = new AtomicReference<Integer>();
|
||||
|
||||
|
||||
final AtomicReference<CharSequence> valueRef = new AtomicReference<CharSequence>();
|
||||
|
||||
MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>> eventListener = new MapEventListener<Integer, CharSequence, ChronicleMap<Integer, CharSequence>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onPut(ChronicleMap<Integer, CharSequence> map, Bytes entry, int metaDataBytes, boolean added, Integer key,
|
||||
CharSequence value) {
|
||||
putWasCalled.getAndSet(true);
|
||||
keyRef.set(key);
|
||||
valueRef.set(value);
|
||||
}
|
||||
};
|
||||
|
||||
// ---------- SERVER1 1 ----------
|
||||
{
|
||||
|
||||
// we connect the maps via a TCP socket connection on port 8077
|
||||
|
||||
TcpConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 2, tcpConfig);
|
||||
map1 = serverBuilder().create();
|
||||
|
||||
map1 = map1Builder.create();
|
||||
map1.put(5, "WILL_GET_OVERWRITEN");
|
||||
}
|
||||
// ---------- SERVER2 2 on the same server as ----------
|
||||
|
||||
{
|
||||
TcpConfig tcpConfig = TcpConfig.forReceivingOnlyNode(8077);
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2Builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 1, tcpConfig)
|
||||
.eventListener(eventListener);
|
||||
|
||||
map2 = map2Builder.create();
|
||||
map2 = clientBuilder().create();
|
||||
map2.put(5, "small");
|
||||
}
|
||||
|
||||
|
||||
// we will stores some data into one map here
|
||||
map1.put(5, "EXAMPLE");
|
||||
|
||||
waitTillReplicated();
|
||||
|
||||
|
||||
Assert.assertTrue("The eventListener.onPut should have been called", putWasCalled.get());
|
||||
Assert.assertEquals(Integer.valueOf(5), keyRef.get());
|
||||
Assert.assertEquals("small", replacedValueRef.get());
|
||||
Assert.assertEquals("EXAMPLE", valueRef.get());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRemoteNotifyRemove() throws IOException, InterruptedException {
|
||||
|
||||
// ---------- SERVER1 1 ----------
|
||||
{
|
||||
|
||||
// we connect the maps via a TCP socket connection on port 8077
|
||||
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder = serverBuilder();
|
||||
|
||||
map1 = map1Builder.create();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ---------- SERVER2 2 on the same server as ----------
|
||||
{
|
||||
map2 = clientBuilder().create();
|
||||
map2.put(5, "WILL_GET_REMOVED");
|
||||
}
|
||||
|
||||
// its we have to wait here for this entry to be removed - as removing an entry that you dont have
|
||||
// on map 1 will have no effect
|
||||
waitTillReplicated();
|
||||
|
||||
// no more puts after this point
|
||||
putWasCalled.set(false);
|
||||
|
||||
// we will stores some data into one map here
|
||||
map1.remove(5);
|
||||
|
||||
waitTillReplicated();
|
||||
|
||||
Assert.assertTrue(!putWasCalled.get());
|
||||
Assert.assertTrue(wasRemoved.get());
|
||||
Assert.assertEquals("WILL_GET_REMOVED", valueRemoved.get());
|
||||
Assert.assertEquals(null, map2.get(5));
|
||||
}
|
||||
|
||||
private ChronicleMapBuilder<Integer, CharSequence> clientBuilder() {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.forReceivingOnlyNode(8077);
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 1, tcpConfig)
|
||||
.eventListener(eventListener);
|
||||
}
|
||||
|
||||
|
||||
private void waitTillReplicated() throws InterruptedException {
|
||||
int t = 0;
|
||||
for (; t < 5000; t++) {
|
||||
if (map1.equals(map2)) {
|
||||
@@ -268,17 +256,13 @@ public class EventListenerTestWithTCPSocketReplication {
|
||||
}
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertEquals("Maps should be equal", map1, map2);
|
||||
Assert.assertTrue("Map 1 should not be empty", !map1.isEmpty());
|
||||
Assert.assertTrue("Map 2 should not be empty", !map2.isEmpty());
|
||||
|
||||
Assert.assertTrue("The eventListener.onPut should have been called", putWasCalled.get());
|
||||
Assert.assertEquals(Integer.valueOf(5), keyRef.get());
|
||||
Assert.assertEquals("EXAMPLE", valueRef.get());
|
||||
|
||||
keyRef.set(null);
|
||||
valueRef.set(null);
|
||||
private ChronicleMapBuilder<Integer, CharSequence> serverBuilder() {
|
||||
TcpTransportAndNetworkConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replication((byte) 2, tcpConfig);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class Issue3 {
|
||||
public class Issue3Test {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
@@ -20,7 +20,7 @@ package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -62,12 +62,12 @@ public class PostChannelCreationTest {
|
||||
public void setup() throws IOException {
|
||||
|
||||
{
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubA = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 1);
|
||||
.createWithId((byte) 1);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
@@ -81,12 +81,12 @@ public class PostChannelCreationTest {
|
||||
|
||||
|
||||
{
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 2);
|
||||
.createWithId((byte) 2);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
|
||||
@@ -20,7 +20,7 @@ package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -60,7 +60,7 @@ public class SingleMapChannelTest {
|
||||
public void setup() throws IOException {
|
||||
|
||||
{
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
int maxEntrySize = 1024;
|
||||
@@ -68,7 +68,7 @@ public class SingleMapChannelTest {
|
||||
hubA = ReplicationHub.builder()
|
||||
.maxEntrySize(maxEntrySize)
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
.createWithId(identifier);
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
@@ -77,11 +77,11 @@ public class SingleMapChannelTest {
|
||||
|
||||
|
||||
{
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig).create((byte) 2);
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig).createWithId((byte) 2);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
|
||||
serverMap.put(10, "EXAMPLE-10");
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
|
||||
serverMap.put(10, "EXAMPLE-10");
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.create();
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.create();
|
||||
@@ -372,7 +372,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.create();
|
||||
@@ -415,9 +415,9 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8086)).create();
|
||||
serverMap2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8077)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8077)).create();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
{
|
||||
// restart map 2 but don't doConnect it to map one
|
||||
final ChronicleMap<Integer, CharSequence> map2b =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.createPersistedTo(map2File);
|
||||
map2aBuilder.createPersistedTo(map2File);
|
||||
// add data into it
|
||||
map2b.put(11, "ADDED WHEN DISCONNECTED TO MAP1");
|
||||
map2b.close();
|
||||
@@ -112,8 +111,7 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
{
|
||||
// restart map 2 but don't doConnect it to map one
|
||||
final ChronicleMap<Integer, CharSequence> map2b =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.createPersistedTo(map2File);
|
||||
map2aBuilder.createPersistedTo(map2File);
|
||||
// add data into it
|
||||
map2b.put(11, "ADDED WHEN DISCONNECTED TO MAP1");
|
||||
map2b.close();
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -48,7 +48,7 @@ public class TCPSocketReplicationTest3wayPutReturnsNull {
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints));
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.forUnknownTopology(serverPort, Arrays.asList(endpoints));
|
||||
|
||||
return (T) ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
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 net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -45,8 +43,8 @@ public class TwoMapOnDifferentServers {
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
|
||||
final TcpConfig tcpConfig =
|
||||
TcpConfig.forSendingNode(8076, new InetSocketAddress("localhost", 8077))
|
||||
final TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.forSendingNode(8076, new InetSocketAddress("localhost", 8077))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
|
||||
@@ -56,7 +54,7 @@ public class TwoMapOnDifferentServers {
|
||||
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8077)
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(8077)
|
||||
.heartBeatInterval(1, SECONDS)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.SimpleReplication;
|
||||
import net.openhft.chronicle.hash.replication.UdpConfig;
|
||||
import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication;
|
||||
import net.openhft.chronicle.hash.replication.UdpTransportConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -41,13 +41,14 @@ public class UDPSocketReplicationTest {
|
||||
final int identifier,
|
||||
final int udpPort) throws IOException {
|
||||
|
||||
UdpConfig udpConfig = UdpConfig
|
||||
.simple(Inet4Address.getByName("255.255.255.255"), udpPort);
|
||||
UdpTransportConfig udpConfig = UdpTransportConfig
|
||||
.of(Inet4Address.getByName("255.255.255.255"), udpPort);
|
||||
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.replication(SimpleReplication.builder().udpTransport(udpConfig)
|
||||
.create((byte) identifier)).create();
|
||||
.replication(SingleChronicleHashReplication.builder().udpTransport(udpConfig)
|
||||
.createWithId((byte) identifier))
|
||||
.create();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.openhft.chronicle.map.example;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import org.junit.Assert;
|
||||
@@ -69,14 +69,14 @@ public class ChannelExample {
|
||||
|
||||
byte identifier = (byte) 1;
|
||||
|
||||
TcpConfig tcpConfig = TcpConfig
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
|
||||
hubOnServer1 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
.createWithId(identifier);
|
||||
|
||||
// this demotes favoriteColour
|
||||
short channel1 = (short) 1;
|
||||
@@ -104,12 +104,12 @@ public class ChannelExample {
|
||||
|
||||
byte identifier = (byte) 2;
|
||||
|
||||
TcpConfig tcpConfig =
|
||||
TcpConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
TcpTransportAndNetworkConfig tcpConfig =
|
||||
TcpTransportAndNetworkConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
|
||||
hubOnServer2 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
.createWithId(identifier);
|
||||
|
||||
|
||||
// this demotes favoriteColour
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.*;
|
||||
/**
|
||||
* @test
|
||||
* @synopsis Times and checks basic map operations
|
||||
* <p></p>
|
||||
* <p>
|
||||
* When run with "s" second arg, this requires file "testwords", which
|
||||
* is best used with real words. We can't check in this file, but you
|
||||
* can create one from a real dictionary (1 line per word) and then run
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map.jrs166.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import net.openhft.chronicle.map.ReadContext;
|
||||
@@ -192,7 +192,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
|
||||
final ChronicleMap<Integer, String> serverMap =
|
||||
ChronicleMapBuilder.of(Integer.class, String.class)
|
||||
.replication((byte) 1, TcpConfig.forReceivingOnlyNode(port)).create();
|
||||
.replication((byte) 1, TcpTransportAndNetworkConfig.forReceivingOnlyNode(port)).create();
|
||||
|
||||
final ChronicleMap<Integer, String> statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, String.class)
|
||||
@@ -206,7 +206,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
IOException {
|
||||
|
||||
final ChronicleMap<CharSequence, CharSequence> serverMap = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(port)).create();
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.forReceivingOnlyNode(port)).create();
|
||||
|
||||
|
||||
final ChronicleMap<CharSequence, CharSequence> statelessMap = ChronicleMapBuilder.of(CharSequence
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -26,7 +26,6 @@ import org.junit.Test;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
@@ -53,7 +52,7 @@ public class SetForTCPSocketReplicationTest3way {
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return (T) ChronicleSetBuilder.of(Integer.class)
|
||||
.replication(identifier, TcpConfig.unknownTopology(serverPort, asList(endpoints))
|
||||
.replication(identifier, TcpTransportAndNetworkConfig.forUnknownTopology(serverPort, asList(endpoints))
|
||||
.heartBeatInterval(1L, SECONDS))
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user