HCOLL-128 cleanup Replicators closeables handling, fixed small defect -- AbstractConnector.connectLater didn't remove channel from closeables

This commit is contained in:
leventov
2014-09-10 03:11:14 +04:00
parent 41a39fe228
commit 2ef875ef91
4 changed files with 113 additions and 68 deletions
@@ -277,19 +277,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();
}
}