fixed issue with

This commit is contained in:
Rob Austin
2015-10-02 02:46:13 +03:00
committed by leventov
parent fe4b200142
commit cd9aafbe2b
@@ -359,8 +359,7 @@ public final class TcpReplicator<K, V> extends AbstractChannelReplicator impleme
final Attached attached = (Attached) key.attachment();
// we wont attempt to reconnect the server socket
if (attached.isServer || !attached.isHandShakingComplete())
if (attached.isServer && !attached.isHandShakingComplete())
return;
final SocketChannel channel = (SocketChannel) key.channel();
@@ -371,6 +370,8 @@ public final class TcpReplicator<K, V> extends AbstractChannelReplicator impleme
LOG.debug("lost connection, attempting to reconnect. " +
"missed heartbeat from identifier=" + attached.remoteIdentifier);
activeKeys.clear(attached.remoteIdentifier);
quietClose(key, null);
closeables.closeQuietly(channel.socket());
// when node discovery is used ( by nodes broadcasting out their host:port over UDP ),
@@ -390,8 +391,8 @@ public final class TcpReplicator<K, V> extends AbstractChannelReplicator impleme
* @param key the SelectionKey
* @param e the Exception that caused the issue
*/
private void quietClose(@NotNull final SelectionKey key, @NotNull final Exception e) {
if (LOG.isDebugEnabled())
private void quietClose(@NotNull final SelectionKey key, @Nullable final Exception e) {
if (LOG.isDebugEnabled() && e != null)
LOG.debug("", e);
if (key.channel() != null && key.attachment() != null && connectionListener != null)
@@ -589,8 +590,10 @@ public final class TcpReplicator<K, V> extends AbstractChannelReplicator impleme
final SocketChannel channel = (SocketChannel) key.channel();
if (channel != null && channel.socket() != null && connectionListener != null) {
connectionListener.onConnect(channel.socket().getInetAddress(),
attached.remoteIdentifier, attached.isServer);
connectionListener.onConnect(
channel.socket().getInetAddress(),
attached.remoteIdentifier,
attached.isServer);
}
// we use the as iterating the activeKeys via the bitset wont create and Objects
@@ -786,7 +789,7 @@ public final class TcpReplicator<K, V> extends AbstractChannelReplicator impleme
int len = attached.entryReader.readSocketToBuffer(socketChannel);
if (len == -1) {
socketChannel.register(selector, 0);
socketChannel.register(selector, 0, attached);
if (replicationConfig.autoReconnectedUponDroppedConnection()) {
AbstractConnector connector = attached.connector;
if (connector != null)