mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -46,7 +46,6 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TcpReplicator.class.getName());
|
||||
private static final int BUFFER_SIZE = 0x100000; // 1MB
|
||||
final AtomicBoolean forceBootstrap = new AtomicBoolean();
|
||||
private final Map<SocketAddress, AbstractConnector> connectorBySocket = new ConcurrentHashMap<SocketAddress, AbstractConnector>();
|
||||
private final SelectionKey[] selectionKeysStore = new SelectionKey[Byte.MAX_VALUE + 1];
|
||||
// used to instruct the selector thread to set OP_WRITE on a key correlated by the bit index in the
|
||||
// bitset
|
||||
@@ -101,15 +100,11 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable {
|
||||
void process() throws IOException {
|
||||
try {
|
||||
final Details serverDetails = new Details(serverInetSocketAddress, localIdentifier);
|
||||
connectorBySocket.put(serverInetSocketAddress, new ServerConnector(serverDetails));
|
||||
new ServerConnector(serverDetails).connect();
|
||||
|
||||
for (InetSocketAddress client : endpoints) {
|
||||
final Details clientDetails = new Details(client, localIdentifier);
|
||||
connectorBySocket.put(client, new ClientConnector(clientDetails));
|
||||
}
|
||||
|
||||
for (AbstractConnector connector : connectorBySocket.values()) {
|
||||
connector.connect();
|
||||
new ClientConnector(clientDetails).connect();
|
||||
}
|
||||
|
||||
while (selector.isOpen()) {
|
||||
@@ -277,19 +272,13 @@ class TcpReplicator extends AbstractChannelReplicator implements Closeable {
|
||||
|
||||
final SocketChannel channel = (SocketChannel) key.channel();
|
||||
|
||||
if (approxTimeOutTime > attached.entryReader.lastHeartBeatReceived + attached.remoteHeartbeatInterval) {
|
||||
if (approxTimeOutTime >
|
||||
attached.entryReader.lastHeartBeatReceived + attached.remoteHeartbeatInterval) {
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("lost connection, attempting to reconnect. " +
|
||||
"missed heartbeat from identifier=" + attached.remoteIdentifier);
|
||||
try {
|
||||
channel.socket().close();
|
||||
channel.close();
|
||||
activeKeys.clear(attached.remoteIdentifier);
|
||||
closeables.remove(channel);
|
||||
} catch (IOException e) {
|
||||
LOG.debug("", e);
|
||||
}
|
||||
|
||||
activeKeys.clear(attached.remoteIdentifier);
|
||||
closeables.closeQuietly(channel.socket());
|
||||
attached.connector.connectLater();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user