mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-163 renamed chronicle custer to chronicle channel
This commit is contained in:
@@ -46,7 +46,7 @@ Click here to get the [Latest Version Number](http://search.maven.org/#search%7C
|
||||
* [Identifier](https://github.com/OpenHFT/Chronicle-Map#identifier)
|
||||
* [Port](https://github.com/OpenHFT/Chronicle-Map#port)
|
||||
* [Heart Beat Interval](https://github.com/OpenHFT/Chronicle-Map#heart-beat-interval)
|
||||
* [Clustering](https://github.com/OpenHFT/Chronicle-Map#cluster)
|
||||
* [Channels](https://github.com/OpenHFT/Chronicle-Map#channels)
|
||||
|
||||
#### Miscellaneous
|
||||
|
||||
@@ -512,7 +512,7 @@ A heartbeat will only be send if no data is transmitted, if the maps are constan
|
||||
no heartbeat message is sent. If a map does not receive either data of a heartbeat the connection
|
||||
is dropped and re-established.
|
||||
|
||||
# Cluster
|
||||
# Channels
|
||||
|
||||
Chronicle Map TCP Replication lets you distribute a single Chronicle Map, to a number of servers
|
||||
across your network. Replication is point to point and the data transfer is bidirectional, so in the
|
||||
@@ -523,34 +523,37 @@ unfortunately with just TCP replication you would have to have two tcp socket co
|
||||
not ideal. This is why we created Chronicle Clustering. Clustering lets you replicate numerous
|
||||
Chronicle Maps via a single point to point socket connection.
|
||||
|
||||
Clustering is similar to TCP replication, where each map has to be given a unique identifier, but
|
||||
when using Chronicle Clustering its the cluster that is given the unique identifier not the map.
|
||||
Chronicle Channels are similar to TCP replication, where each map has to be given a unique identifier, but
|
||||
when using Chronicle Channels its the channels that are given the unique identifier not the map.
|
||||
|
||||
``` java
|
||||
ReplicatingClusterBuilder clusterBuilder = new ReplicatingClusterBuilder((byte) 2, 1024);
|
||||
byte identifier = 2;
|
||||
ChannelReplicator channelReplicatorA = new ChannelReplicatorBuilder(identifier, 1024)
|
||||
.create();
|
||||
```
|
||||
|
||||
In this example above the cluster is given the identifier of 2
|
||||
In this example above the channel is given the identifier of 2
|
||||
|
||||
In addition to specifying the identifier we also have to set the maximum entry size, this sets
|
||||
the size of the memory buffers within the cluster. This has to be set manually, with clusters you
|
||||
are able to attach additional maps to a cluster once its up and running, so the maximum size of each
|
||||
the size of the memory buffers within the ChannelReplicator. This has to be set manually, with channels you
|
||||
are able to attach additional maps to a ChannelReplicator once its up and running, so the maximum size of each
|
||||
entry in the map can not be known in advance and we don’t currently support automatic resizing
|
||||
of buffers.
|
||||
|
||||
Once you have created the cluster you should attach your tcpConfig
|
||||
Once you have created the ChannelReplicator you should attach your tcp configuration
|
||||
``` java
|
||||
TcpReplicationConfig tcpConfig = TcpReplicationConfig.of(8087).heartBeatInterval(1, SECONDS);
|
||||
clusterBuilder.tcpReplication(tcpConfig);
|
||||
ReplicatingCluster cluster = clusterBuilder.create();
|
||||
byte identifier = 2;
|
||||
ChannelReplicator channelReplicator = new ChannelReplicatorBuilder(identifier, 1024)
|
||||
.tcpReplication(tcpConfig)
|
||||
.create();;
|
||||
```
|
||||
|
||||
Attaching cluster replication to the map:
|
||||
Attaching ChannelReplicator replication to the map:
|
||||
|
||||
``` java
|
||||
ChronicleMap<Integer, CharSequence> map = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.addReplicator(cluster.channelReplicator((short) 1))
|
||||
.channel(channelReplicator.createChannel((short) 1))
|
||||
.create(file);
|
||||
```
|
||||
|
||||
@@ -567,11 +570,11 @@ If you inadvertently got the chronicle channels around the wrong way, then chron
|
||||
to replicate the wrong maps data. The chronicle channels don't have to be in order but they must be
|
||||
unique for each map you have.
|
||||
|
||||
Once you have created the cluster you may wish to hold onto the reference so that you can call close
|
||||
once you have finished, this will close everything in the cluster
|
||||
Once you have created the ChannelReplicator you may wish to hold onto the reference so that you can call close
|
||||
once you have finished, this will close everything in the ChannelReplicator
|
||||
|
||||
``` java
|
||||
cluster.close();
|
||||
channelReplicator.close();
|
||||
```
|
||||
|
||||
#### Known Issues
|
||||
|
||||
+4
-4
@@ -45,8 +45,8 @@ import static net.openhft.chronicle.map.Replica.ModificationNotifier.NOP;
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public final class ReplicatingChannel implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReplicatingChannel.class.getName());
|
||||
public final class ChannelReplicator implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChannelReplicator.class.getName());
|
||||
|
||||
private static final byte BOOTSTRAP_MESSAGE = 'B';
|
||||
final EntryExternalizable asEntryExternalizable = new EntryExternalizable() {
|
||||
@@ -152,7 +152,7 @@ public final class ReplicatingChannel implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
ReplicatingChannel.this.close();
|
||||
ChannelReplicator.this.close();
|
||||
}
|
||||
};
|
||||
private final int maxEntrySize;
|
||||
@@ -169,7 +169,7 @@ public final class ReplicatingChannel implements Closeable {
|
||||
private final Set<AbstractChannelReplicator> replicators =
|
||||
new CopyOnWriteArraySet<AbstractChannelReplicator>();
|
||||
|
||||
ReplicatingChannel(ReplicatingChannelBuilder builder) {
|
||||
ChannelReplicator(ChannelReplicatorBuilder builder) {
|
||||
localIdentifier = builder.identifier;
|
||||
maxEntrySize = builder.maxEntrySize;
|
||||
chronicleChannels = new Replica[builder.maxNumberOfChronicles];
|
||||
+7
-7
@@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public final class ReplicatingChannelBuilder {
|
||||
public final class ChannelReplicatorBuilder {
|
||||
|
||||
final byte identifier;
|
||||
final int maxEntrySize;
|
||||
@@ -29,7 +29,7 @@ public final class ReplicatingChannelBuilder {
|
||||
private UdpReplicationConfig udpReplicationConfig = null;
|
||||
private TcpReplicationConfig tcpReplicationConfig = null;
|
||||
|
||||
ReplicatingChannelBuilder(byte identifier, final int maxEntrySize) {
|
||||
ChannelReplicatorBuilder(byte identifier, final int maxEntrySize) {
|
||||
this.identifier = identifier;
|
||||
this.maxEntrySize = maxEntrySize;
|
||||
if (identifier <= 0) {
|
||||
@@ -38,23 +38,23 @@ public final class ReplicatingChannelBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public ReplicatingChannelBuilder udpReplication(UdpReplicationConfig replicationConfig) {
|
||||
public ChannelReplicatorBuilder udpReplication(UdpReplicationConfig replicationConfig) {
|
||||
this.udpReplicationConfig = replicationConfig;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicatingChannelBuilder tcpReplication(TcpReplicationConfig replicationConfig) {
|
||||
public ChannelReplicatorBuilder tcpReplication(TcpReplicationConfig replicationConfig) {
|
||||
this.tcpReplicationConfig = replicationConfig;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicatingChannelBuilder maxNumberOfChronicles(int maxNumberOfChronicles) {
|
||||
public ChannelReplicatorBuilder maxNumberOfChronicles(int maxNumberOfChronicles) {
|
||||
this.maxNumberOfChronicles = maxNumberOfChronicles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicatingChannel create() throws IOException {
|
||||
final ReplicatingChannel replicatingCluster = new ReplicatingChannel(this);
|
||||
public ChannelReplicator create() throws IOException {
|
||||
final ChannelReplicator replicatingCluster = new ChannelReplicator(this);
|
||||
if (tcpReplicationConfig != null) {
|
||||
final TcpReplicator tcpReplicator = new TcpReplicator(
|
||||
replicatingCluster.asReplica,
|
||||
@@ -562,10 +562,10 @@ public class ChronicleMapBuilder<K, V> implements Cloneable,
|
||||
}
|
||||
|
||||
|
||||
public ChronicleMapBuilder<K, V> channel(ReplicatingChannel.ChronicleChannel replicator) {
|
||||
this.identifier = replicator.identifier();
|
||||
public ChronicleMapBuilder<K, V> channel(ChannelReplicator.ChronicleChannel chronicleChannel) {
|
||||
this.identifier = chronicleChannel.identifier();
|
||||
this.replicators.clear();
|
||||
replicators.put(replicator.getClass(), replicator);
|
||||
replicators.put(chronicleChannel.getClass(), chronicleChannel);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
+12
-11
@@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
|
||||
*
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public class ClusterReplicationTest {
|
||||
public class ChannelReplicationTest {
|
||||
|
||||
private ChronicleMap<Integer, CharSequence> map1a;
|
||||
private ChronicleMap<Integer, CharSequence> map2a;
|
||||
@@ -40,8 +40,8 @@ public class ClusterReplicationTest {
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
private ChronicleMap<Integer, CharSequence> map2b;
|
||||
|
||||
private ReplicatingChannel clusterB;
|
||||
private ReplicatingChannel clusterA;
|
||||
private ChannelReplicator channelReplicatorA;
|
||||
private ChannelReplicator channelReplicatorB;
|
||||
|
||||
|
||||
@Before
|
||||
@@ -52,12 +52,13 @@ public class ClusterReplicationTest {
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterA = new ReplicatingChannelBuilder((byte) 1, 1024).tcpReplication(tcpConfig)
|
||||
.create();
|
||||
channelReplicatorA = new ChannelReplicatorBuilder((byte) 1, 1024)
|
||||
.tcpReplication(tcpConfig)
|
||||
.create();
|
||||
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterA.createChannel((short) 1))
|
||||
.channel(channelReplicatorA.createChannel((short) 1))
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
|
||||
@@ -65,12 +66,12 @@ public class ClusterReplicationTest {
|
||||
TcpReplicationConfig tcpConfig =
|
||||
TcpReplicationConfig.of(8087).heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterB = new ReplicatingChannelBuilder((byte) 2, 1024).tcpReplication(tcpConfig)
|
||||
channelReplicatorB = new ChannelReplicatorBuilder((byte) 2, 1024).tcpReplication(tcpConfig)
|
||||
.create();
|
||||
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterB.createChannel((short) 1))
|
||||
.channel(channelReplicatorB.createChannel((short) 1))
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class ClusterReplicationTest {
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{clusterA, clusterB}) {
|
||||
for (final Closeable closeable : new Closeable[]{channelReplicatorA, channelReplicatorB}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
@@ -93,13 +94,13 @@ public class ClusterReplicationTest {
|
||||
|
||||
map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterB.createChannel((short) 2))
|
||||
.channel(channelReplicatorB.createChannel((short) 2))
|
||||
.create(getPersistenceFile());
|
||||
|
||||
|
||||
map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterA.createChannel((short) 2))
|
||||
.channel(channelReplicatorA.createChannel((short) 2))
|
||||
.create(getPersistenceFile());
|
||||
|
||||
map2a.put(1, "EXAMPLE-2");
|
||||
@@ -43,11 +43,8 @@ public class PostClusterMapCreationTest {
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
private ChronicleMap<Integer, CharSequence> map2b;
|
||||
|
||||
private ReplicatingChannel clusterB;
|
||||
private ReplicatingChannel clusterA;
|
||||
|
||||
private ReplicatingChannelBuilder replicatingClusterBuilder1;
|
||||
|
||||
private ChannelReplicator channelReplicatorA;
|
||||
private ChannelReplicator channelReplicatorB;
|
||||
|
||||
public static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
@@ -66,18 +63,18 @@ public class PostClusterMapCreationTest {
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterA = new ReplicatingChannelBuilder((byte) 1, 1024)
|
||||
channelReplicatorA = new ChannelReplicatorBuilder((byte) 1, 1024)
|
||||
.tcpReplication(tcpReplicationConfig).create();
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterA.createChannel((short) 1))
|
||||
.channel(channelReplicatorA.createChannel((short) 1))
|
||||
.create(getPersistenceFile());
|
||||
|
||||
map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterA.createChannel((short) 2))
|
||||
.channel(channelReplicatorA.createChannel((short) 2))
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
|
||||
@@ -87,18 +84,18 @@ public class PostClusterMapCreationTest {
|
||||
.of(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterB = new ReplicatingChannelBuilder((byte) 2, 1024)
|
||||
channelReplicatorB = new ChannelReplicatorBuilder((byte) 2, 1024)
|
||||
.tcpReplication(tcpReplicationConfig).create();
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterB.createChannel((short) 1))
|
||||
.channel(channelReplicatorB.createChannel((short) 1))
|
||||
.create(getPersistenceFile());
|
||||
|
||||
map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterB.createChannel((short) 2))
|
||||
.channel(channelReplicatorB.createChannel((short) 2))
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
|
||||
@@ -108,7 +105,7 @@ public class PostClusterMapCreationTest {
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{clusterA, clusterB}) {
|
||||
for (final Closeable closeable : new Closeable[]{channelReplicatorA, channelReplicatorB}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -41,9 +41,8 @@ public class SingleMapClusterTest {
|
||||
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
|
||||
private ReplicatingChannel clusterB;
|
||||
private ReplicatingChannel clusterA;
|
||||
|
||||
private ChannelReplicator channelReplicatorA;
|
||||
private ChannelReplicator channelReplicatorB;
|
||||
|
||||
public static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
@@ -61,12 +60,12 @@ public class SingleMapClusterTest {
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterA = new ReplicatingChannelBuilder((byte) 1, 1024)
|
||||
channelReplicatorA = new ChannelReplicatorBuilder((byte) 1, 1024)
|
||||
.tcpReplication(tcpReplicationConfig).create();
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(clusterA.createChannel((short) 1))
|
||||
.channel(channelReplicatorA.createChannel((short) 1))
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
|
||||
@@ -76,11 +75,11 @@ public class SingleMapClusterTest {
|
||||
.of(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
clusterB = new ReplicatingChannelBuilder((byte) 2, 1024)
|
||||
channelReplicatorB = new ChannelReplicatorBuilder((byte) 2, 1024)
|
||||
.tcpReplication(tcpReplicationConfig).create();
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.channel(clusterB.createChannel((short) 1))
|
||||
.channel(channelReplicatorB.createChannel((short) 1))
|
||||
.entries(1000)
|
||||
.create(getPersistenceFile());
|
||||
}
|
||||
@@ -89,7 +88,7 @@ public class SingleMapClusterTest {
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{clusterA, clusterB}) {
|
||||
for (final Closeable closeable : new Closeable[]{channelReplicatorA, channelReplicatorB}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user