diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 48355137c..a5e8cf385 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -562,7 +562,7 @@ public class ChronicleMapBuilder implements Cloneable, } - public ChronicleMapBuilder channel(ReplicatingCluster.ChronicleChannel replicator) { + public ChronicleMapBuilder channel(ReplicatingChannel.ChronicleChannel replicator) { this.identifier = replicator.identifier(); this.replicators.clear(); replicators.put(replicator.getClass(), replicator); diff --git a/src/main/java/net/openhft/chronicle/map/Replica.java b/src/main/java/net/openhft/chronicle/map/Replica.java index 821d4ab28..fcc698273 100644 --- a/src/main/java/net/openhft/chronicle/map/Replica.java +++ b/src/main/java/net/openhft/chronicle/map/Replica.java @@ -55,14 +55,11 @@ public interface Replica extends Closeable { ModificationNotifier modificationNotifier); /** - * Returns the timestamp of the last change from the specified remote node, already replicated - * to this Replica. - *

- *

Used in conjunction with replication, to back fill data from a remote node. This node + * Returns the timestamp of the last change from the specified remote node, already replicated to this + * Replica.

Used in conjunction with replication, to back fill data from a remote node. This node * may have missed updates while it was not been running or connected via TCP. * - * @param remoteIdentifier the identifier of the remote node to check last replicated update - * time from + * @param remoteIdentifier the identifier of the remote node to check last replicated update time from * @return a timestamp of the last modification to an entry, or 0 if there are no entries. * @see #identifier() */ @@ -102,7 +99,7 @@ public interface Replica extends Closeable { * A non-blocking call that provides the entry that has changed to {@code callback.onEntry()}. * * @param callback a callback which will be called when a new entry becomes available. - * @param chronicleId only assigned when clustering + * @param chronicleId only assigned when using chronicle channels * @return {@code true} if the entry was accepted by the {@code callback.onEntry()} method, {@code * false} if the entry was not accepted or was not available */ @@ -111,10 +108,8 @@ public interface Replica extends Closeable { /** * Dirties all entries with a modification time equal to {@code fromTimeStamp} or newer. It means all * these entries will be considered as "new" by this ModificationIterator and iterated once again no - * matter if they have already been. - *

- *

This functionality is used to publish recently modified entries to a new remote node as it - * connects. + * matter if they have already been.

This functionality is used to publish recently modified + * entries to a new remote node as it connects. * * @param fromTimeStamp the timestamp from which all entries should be dirty */ @@ -133,7 +128,7 @@ public interface Replica extends Closeable { * @param entry the byte location of the entry to be stored * @param destination a buffer the entry will be written to, the segment may reject this operation and * add zeroBytes, if the identifier in the entry did not match the maps local - * @param chronicleId used in cluster into identify the canonical map or queue + * @param chronicleId is the channel id used to identify the canonical map or queue */ void writeExternalEntry(@NotNull Bytes entry, @NotNull Bytes destination, int chronicleId); @@ -180,20 +175,20 @@ public interface Replica extends Closeable { } /** - * Implemented typically by a replicator, This interface provides the event, which will get - * called whenever a put() or remove() has occurred to the map + * Implemented typically by a replicator, This interface provides the event, which will get called + * whenever a put() or remove() has occurred to the map */ abstract class EntryCallback { /** * Called whenever a put() or remove() has occurred to a replicating map. * - * @param entry the entry you will receive, this does not have to be locked, - * as locking is already provided from the caller. + * @param entry the entry you will receive, this does not have to be locked, as locking is + * already provided from the caller. * @param chronicleId only assigned when clustering - * @return {@code false} if this entry should be ignored because the identifier - * of the source node is not from one of our changes, WARNING even though we check - * the identifier in the ModificationIterator the entry may have been updated. + * @return {@code false} if this entry should be ignored because the identifier of the source node is + * not from one of our changes, WARNING even though we check the identifier in the + * ModificationIterator the entry may have been updated. */ public abstract boolean onEntry(final Bytes entry, final int chronicleId); diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatingCluster.java b/src/main/java/net/openhft/chronicle/map/ReplicatingChannel.java similarity index 98% rename from src/main/java/net/openhft/chronicle/map/ReplicatingCluster.java rename to src/main/java/net/openhft/chronicle/map/ReplicatingChannel.java index 31dab3118..13ae91e3b 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatingCluster.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatingChannel.java @@ -45,8 +45,8 @@ import static net.openhft.chronicle.map.Replica.ModificationNotifier.NOP; /** * @author Rob Austin. */ -public final class ReplicatingCluster implements Closeable { - private static final Logger LOG = LoggerFactory.getLogger(ReplicatingCluster.class.getName()); +public final class ReplicatingChannel implements Closeable { + private static final Logger LOG = LoggerFactory.getLogger(ReplicatingChannel.class.getName()); private static final byte BOOTSTRAP_MESSAGE = 'B'; final EntryExternalizable asEntryExternalizable = new EntryExternalizable() { @@ -152,7 +152,7 @@ public final class ReplicatingCluster implements Closeable { @Override public void close() throws IOException { - ReplicatingCluster.this.close(); + ReplicatingChannel.this.close(); } }; private final int maxEntrySize; @@ -169,7 +169,7 @@ public final class ReplicatingCluster implements Closeable { private final Set replicators = new CopyOnWriteArraySet(); - ReplicatingCluster(ReplicatingClusterBuilder builder) { + ReplicatingChannel(ReplicatingChannelBuilder builder) { localIdentifier = builder.identifier; maxEntrySize = builder.maxEntrySize; chronicleChannels = new Replica[builder.maxNumberOfChronicles]; @@ -206,7 +206,7 @@ public final class ReplicatingCluster implements Closeable { /** * Returns a replicator, dedicated to the specified channel. Channel is basically just a number, that * should correspond on different servers for instances of the same replicated map. Only one replicator - * per channel could be obtained from a single {@code ReplicatingCluster}. The returned replicator could + * per channel could be obtained from a single {@code ReplicatingChannel}. The returned replicator could * be applied to a map at most once. * * @return a replicator, dedicated to the specified channel @@ -409,7 +409,7 @@ public final class ReplicatingCluster implements Closeable { protected Closeable applyTo(ChronicleMapBuilder builder, Replica map, EntryExternalizable entryExternalizable) { if (builder.entrySize() > maxEntrySize) { - throw new IllegalArgumentException("During ReplicatingClusterBuilder setup, " + + throw new IllegalArgumentException("During ReplicatingChannelBuilder setup, " + "maxEntrySize=" + maxEntrySize + " was specified, but map with " + "entrySize=" + builder.entrySize() + " is attempted to apply" + "to the replicator"); diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatingClusterBuilder.java b/src/main/java/net/openhft/chronicle/map/ReplicatingChannelBuilder.java similarity index 83% rename from src/main/java/net/openhft/chronicle/map/ReplicatingClusterBuilder.java rename to src/main/java/net/openhft/chronicle/map/ReplicatingChannelBuilder.java index c5a85fc82..23e095896 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatingClusterBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatingChannelBuilder.java @@ -21,7 +21,7 @@ import java.io.IOException; /** * @author Rob Austin. */ -public final class ReplicatingClusterBuilder { +public final class ReplicatingChannelBuilder { final byte identifier; final int maxEntrySize; @@ -29,7 +29,7 @@ public final class ReplicatingClusterBuilder { private UdpReplicationConfig udpReplicationConfig = null; private TcpReplicationConfig tcpReplicationConfig = null; - ReplicatingClusterBuilder(byte identifier, final int maxEntrySize) { + ReplicatingChannelBuilder(byte identifier, final int maxEntrySize) { this.identifier = identifier; this.maxEntrySize = maxEntrySize; if (identifier <= 0) { @@ -38,23 +38,23 @@ public final class ReplicatingClusterBuilder { } } - public ReplicatingClusterBuilder udpReplication(UdpReplicationConfig replicationConfig) { + public ReplicatingChannelBuilder udpReplication(UdpReplicationConfig replicationConfig) { this.udpReplicationConfig = replicationConfig; return this; } - public ReplicatingClusterBuilder tcpReplication(TcpReplicationConfig replicationConfig) { + public ReplicatingChannelBuilder tcpReplication(TcpReplicationConfig replicationConfig) { this.tcpReplicationConfig = replicationConfig; return this; } - public ReplicatingClusterBuilder maxNumberOfChronicles(int maxNumberOfChronicles) { + public ReplicatingChannelBuilder maxNumberOfChronicles(int maxNumberOfChronicles) { this.maxNumberOfChronicles = maxNumberOfChronicles; return this; } - public ReplicatingCluster create() throws IOException { - final ReplicatingCluster replicatingCluster = new ReplicatingCluster(this); + public ReplicatingChannel create() throws IOException { + final ReplicatingChannel replicatingCluster = new ReplicatingChannel(this); if (tcpReplicationConfig != null) { final TcpReplicator tcpReplicator = new TcpReplicator( replicatingCluster.asReplica, diff --git a/src/test/java/net/openhft/chronicle/map/ClusterReplicationTest.java b/src/test/java/net/openhft/chronicle/map/ClusterReplicationTest.java index 9c56df574..941179aef 100644 --- a/src/test/java/net/openhft/chronicle/map/ClusterReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/ClusterReplicationTest.java @@ -40,8 +40,8 @@ public class ClusterReplicationTest { private ChronicleMap map1b; private ChronicleMap map2b; - private ReplicatingCluster clusterB; - private ReplicatingCluster clusterA; + private ReplicatingChannel clusterB; + private ReplicatingChannel clusterA; @Before @@ -52,7 +52,7 @@ public class ClusterReplicationTest { .of(8086, new InetSocketAddress("localhost", 8087)) .heartBeatInterval(1, SECONDS); - clusterA = new ReplicatingClusterBuilder((byte) 1, 1024).tcpReplication(tcpConfig) + clusterA = new ReplicatingChannelBuilder((byte) 1, 1024).tcpReplication(tcpConfig) .create(); map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) @@ -65,7 +65,7 @@ public class ClusterReplicationTest { TcpReplicationConfig tcpConfig = TcpReplicationConfig.of(8087).heartBeatInterval(1, SECONDS); - clusterB = new ReplicatingClusterBuilder((byte) 2, 1024).tcpReplication(tcpConfig) + clusterB = new ReplicatingChannelBuilder((byte) 2, 1024).tcpReplication(tcpConfig) .create(); map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) diff --git a/src/test/java/net/openhft/chronicle/map/PostClusterMapCreationTest.java b/src/test/java/net/openhft/chronicle/map/PostClusterMapCreationTest.java index 76a978389..e9c102f34 100644 --- a/src/test/java/net/openhft/chronicle/map/PostClusterMapCreationTest.java +++ b/src/test/java/net/openhft/chronicle/map/PostClusterMapCreationTest.java @@ -43,10 +43,10 @@ public class PostClusterMapCreationTest { private ChronicleMap map1b; private ChronicleMap map2b; - private ReplicatingCluster clusterB; - private ReplicatingCluster clusterA; + private ReplicatingChannel clusterB; + private ReplicatingChannel clusterA; - private ReplicatingClusterBuilder replicatingClusterBuilder1; + private ReplicatingChannelBuilder replicatingClusterBuilder1; public static File getPersistenceFile() { @@ -66,7 +66,7 @@ public class PostClusterMapCreationTest { .of(8086, new InetSocketAddress("localhost", 8087)) .heartBeatInterval(1, SECONDS); - clusterA = new ReplicatingClusterBuilder((byte) 1, 1024) + clusterA = new ReplicatingChannelBuilder((byte) 1, 1024) .tcpReplication(tcpReplicationConfig).create(); // this is how you add maps after the custer is created @@ -87,7 +87,7 @@ public class PostClusterMapCreationTest { .of(8087, new InetSocketAddress("localhost", 8086)) .heartBeatInterval(1, SECONDS); - clusterB = new ReplicatingClusterBuilder((byte) 2, 1024) + clusterB = new ReplicatingChannelBuilder((byte) 2, 1024) .tcpReplication(tcpReplicationConfig).create(); // this is how you add maps after the custer is created diff --git a/src/test/java/net/openhft/chronicle/map/SingleMapClusterTest.java b/src/test/java/net/openhft/chronicle/map/SingleMapClusterTest.java index 6fd4a9df0..af26c450f 100644 --- a/src/test/java/net/openhft/chronicle/map/SingleMapClusterTest.java +++ b/src/test/java/net/openhft/chronicle/map/SingleMapClusterTest.java @@ -41,8 +41,8 @@ public class SingleMapClusterTest { private ChronicleMap map1b; - private ReplicatingCluster clusterB; - private ReplicatingCluster clusterA; + private ReplicatingChannel clusterB; + private ReplicatingChannel clusterA; public static File getPersistenceFile() { @@ -61,7 +61,7 @@ public class SingleMapClusterTest { .of(8086, new InetSocketAddress("localhost", 8087)) .heartBeatInterval(1, SECONDS); - clusterA = new ReplicatingClusterBuilder((byte) 1, 1024) + clusterA = new ReplicatingChannelBuilder((byte) 1, 1024) .tcpReplication(tcpReplicationConfig).create(); // this is how you add maps after the custer is created map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) @@ -76,7 +76,7 @@ public class SingleMapClusterTest { .of(8087, new InetSocketAddress("localhost", 8086)) .heartBeatInterval(1, SECONDS); - clusterB = new ReplicatingClusterBuilder((byte) 2, 1024) + clusterB = new ReplicatingChannelBuilder((byte) 2, 1024) .tcpReplication(tcpReplicationConfig).create(); // this is how you add maps after the custer is created map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)