Skip to content

Commit

Permalink
only print failure to reconnect to node from other nodes after severa…
Browse files Browse the repository at this point in the history
…l retries
  • Loading branch information
kimchy committed Aug 31, 2012
1 parent dea2de3 commit 888b7cc
Showing 1 changed file with 24 additions and 1 deletion.
Expand Up @@ -375,6 +375,9 @@ public void run() {
}

private class ReconnectToNodes implements Runnable {

private ConcurrentMap<DiscoveryNode, Integer> failureCount = ConcurrentCollections.newConcurrentMap();

@Override
public void run() {
// master node will check against all nodes if its alive with certain discoveries implementations,
Expand All @@ -395,12 +398,32 @@ public void run() {
return;
}
if (clusterState.nodes().nodeExists(node.id())) { // double check here as well, maybe its gone?
logger.warn("failed to reconnect to node {}", e, node);
Integer nodeFailureCount = failureCount.get(node);
if (nodeFailureCount == null) {
nodeFailureCount = 1;
} else {
nodeFailureCount = nodeFailureCount + 1;
}
// log every 6th failure
if ((nodeFailureCount % 6) == 0) {
// reset the failure count...
nodeFailureCount = 0;
logger.warn("failed to reconnect to node {}", e, node);
}
failureCount.put(node, nodeFailureCount);
}
}
}
}
}
// go over and remove failed nodes that have been removed
DiscoveryNodes nodes = clusterState.nodes();
for (Iterator<DiscoveryNode> failedNodesIt = failureCount.keySet().iterator(); failedNodesIt.hasNext(); ) {
DiscoveryNode failedNode = failedNodesIt.next();
if (!nodes.nodeExists(failedNode.id())) {
failedNodesIt.remove();
}
}
if (lifecycle.started()) {
reconnectToNodes = threadPool.schedule(reconnectInterval, ThreadPool.Names.GENERIC, this);
}
Expand Down

0 comments on commit 888b7cc

Please sign in to comment.