mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-134 ( release draft cut of the code so that I can test it across my network )
This commit is contained in:
@@ -23,10 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.SocketException;
|
||||
import java.net.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.*;
|
||||
import java.util.BitSet;
|
||||
@@ -86,7 +83,6 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable {
|
||||
|
||||
selectorTimeout = Math.min(heartBeatIntervalMillis, throttleBucketInterval);
|
||||
|
||||
|
||||
this.replica = replica;
|
||||
this.localIdentifier = replica.identifier();
|
||||
this.maxEntrySizeBytes = maxEntrySizeBytes;
|
||||
@@ -424,19 +420,27 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable {
|
||||
|
||||
// this can occur sometimes when if 2 or more remote node attempt to use node discovery at the
|
||||
// same time
|
||||
if (remoteIdentifier == localIdentifier) {
|
||||
|
||||
final NonUniqueIdentifierListener listener = replicationConfig.nonUniqueIdentifierListener();
|
||||
final IdentifierListener identifierListener = replicationConfig.identifierListener;
|
||||
final SocketAddress remoteAddress = socketChannel.getRemoteAddress();
|
||||
|
||||
boolean identifierIsUnique;
|
||||
|
||||
if (identifierListener != null) {
|
||||
identifierIsUnique = identifierListener.isIdentifierUnique(remoteIdentifier, remoteAddress);
|
||||
} else {
|
||||
identifierIsUnique = remoteIdentifier != localIdentifier;
|
||||
}
|
||||
|
||||
if (identifierIsUnique) {
|
||||
|
||||
if (listener != null)
|
||||
listener.onNonUniqueIdentifier(remoteIdentifier);
|
||||
|
||||
// throwing this exception will cause us to disconnect, both the client and server
|
||||
// will be able to detect the the remote and local identifiers are the same,
|
||||
// as the identifier is send early on in the hand shaking via the connect(() and accept()
|
||||
// methods
|
||||
throw new IllegalStateException("dropping connection, as the remote and local-identifier " +
|
||||
"are the same, identifier=" + localIdentifier);
|
||||
throw new IllegalStateException("dropping connection, " +
|
||||
"as the remote-identifier is already being used, identifier=" + remoteIdentifier);
|
||||
}
|
||||
|
||||
attached.remoteModificationIterator = replica.acquireModificationIterator(remoteIdentifier,
|
||||
|
||||
Reference in New Issue
Block a user