Some renames in replication API, fixed potential issue with networkInterface configuration for udp multicast

This commit is contained in:
leventov
2014-11-08 05:26:10 +03:00
parent 0bcfa7ee43
commit c0d9099da9
29 changed files with 215 additions and 202 deletions
@@ -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.forUnknownTopology(serverPort, Arrays.asList(endpoints))
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.forUnknownTopology(serverPort, Arrays.asList(endpoints))
.heartBeatInterval(1L, TimeUnit.SECONDS);
return ChronicleMapBuilder.of(kClass, vClass)
.replication(identifier, tcpConfig);
@@ -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,7 +53,7 @@ public class ChannelReplicationTest {
@Before
public void setup() throws IOException {
{
TcpConfig tcpConfig = TcpConfig
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
.heartBeatInterval(1, SECONDS);
@@ -67,8 +67,8 @@ 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);
@@ -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,7 +30,7 @@ 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
@@ -240,7 +240,7 @@ public class EventListenerTestWithTCPSocketReplication {
}
private ChronicleMapBuilder<Integer, CharSequence> clientBuilder() {
TcpConfig tcpConfig = TcpConfig.forReceivingOnlyNode(8077);
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.forReceivingOnlyNode(8077);
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.entries(20000L)
.replication((byte) 1, tcpConfig)
@@ -259,7 +259,7 @@ public class EventListenerTestWithTCPSocketReplication {
}
private ChronicleMapBuilder<Integer, CharSequence> serverBuilder() {
TcpConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
TcpTransportAndNetworkConfig tcpConfig = forSendingNode(8076, new InetSocketAddress("localhost", 8077));
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
.entries(20000L)
.replication((byte) 2, tcpConfig);
@@ -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,7 +62,7 @@ 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);
@@ -81,7 +81,7 @@ public class PostChannelCreationTest {
{
final TcpConfig tcpConfig = TcpConfig
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
.heartBeatInterval(1, SECONDS);
@@ -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;
@@ -77,7 +77,7 @@ public class SingleMapChannelTest {
{
final TcpConfig tcpConfig = TcpConfig
final TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
.heartBeatInterval(1, SECONDS);
@@ -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();
}
@@ -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.forUnknownTopology(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,7 +69,7 @@ public class ChannelExample {
byte identifier = (byte) 1;
TcpConfig tcpConfig = TcpConfig
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
.heartBeatInterval(1, SECONDS);
@@ -104,8 +104,8 @@ 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)
@@ -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;
@@ -52,7 +52,7 @@ public class SetForTCPSocketReplicationTest3way {
final int serverPort,
final InetSocketAddress... endpoints) throws IOException {
return (T) ChronicleSetBuilder.of(Integer.class)
.replication(identifier, TcpConfig.forUnknownTopology(serverPort, asList(endpoints))
.replication(identifier, TcpTransportAndNetworkConfig.forUnknownTopology(serverPort, asList(endpoints))
.heartBeatInterval(1L, SECONDS))
.createPersistedTo(getPersistenceFile());
}