diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java index ecbbdad9e..ce4d94227 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChannelReplicator.java @@ -120,6 +120,11 @@ abstract class AbstractChannelReplicator implements Closeable { closeables.closeQuietly(channel); } + /** + * forces the TCP and UDP replicators to re-bootstrap + * This is called whenever a new CHM is added to a custer + */ + public abstract void forceBootstrap(); void checkThrottleInterval() throws ClosedChannelException { if (throttler != null) diff --git a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java index 515d77d62..0dda8b663 100644 --- a/src/main/java/net/openhft/chronicle/map/TcpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/TcpReplicator.java @@ -36,8 +36,8 @@ import static java.nio.channels.SelectionKey.*; import static java.util.concurrent.TimeUnit.MILLISECONDS; /** - * Used with a {@see net.openhft.map.ReplicatedSharedHashMap} to send data between the maps using a socket - * connection

{@see net.openhft.map.OutSocketReplicator} + * Used with a {@see net.openhft.map.ReplicatedSharedHashMap} to send data between the maps using a + * socket connection

{@see net.openhft.map.OutSocketReplicator} * * @author Rob Austin. */ @@ -64,9 +64,9 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable { /** * @param maxEntrySizeBytes used to check that the last entry will fit into the buffer, it can not be - * smaller than the size of and entry, if it is set smaller the buffer will over - * flow, it can be larger then the entry, but setting it too large reduces the - * workable space in the buffer. + * smaller than the size of and entry, if it is set smaller the buffer will + * over flow, it can be larger then the entry, but setting it too large + * reduces the workable space in the buffer. * @throws IOException */ TcpReplicator(@NotNull final Replica replica, @@ -295,6 +295,11 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable { closeEarlyAndQuietly(key.channel()); } + @Override + public void forceBootstrap() { + forceBootstrap.lazySet(true); + } + /** * called when the selector receives a OP_CONNECT message */ @@ -517,9 +522,9 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable { /** * sets interestOps to "selector keys",The change to interestOps much be on the same thread as the - * selector. This class, allows via {@link AbstractChannelReplicator .KeyInterestUpdater#set(int)} to - * holds a pending change in interestOps ( via a bitset ), this change is processed later on the same - * thread as the selector + * selector. This class, allows via {@link AbstractChannelReplicator + * .KeyInterestUpdater#set(int)} to holds a pending change in interestOps ( via a bitset ), this change + * is processed later on the same thread as the selector */ private static class KeyInterestUpdater { diff --git a/src/main/java/net/openhft/chronicle/map/UdpReplicator.java b/src/main/java/net/openhft/chronicle/map/UdpReplicator.java index e71383896..3d91081ee 100644 --- a/src/main/java/net/openhft/chronicle/map/UdpReplicator.java +++ b/src/main/java/net/openhft/chronicle/map/UdpReplicator.java @@ -91,6 +91,11 @@ class UdpReplicator extends AbstractChannelReplicator implements Replica.Modific } + @Override + public void forceBootstrap() { + modificationIterator = replica.acquireModificationIterator( + ChronicleMapBuilder.UDP_REPLICATION_MODIFICATION_ITERATOR_ID, this); + } /** * binds to the server socket and process data This method will block until interrupted