From d5e11fdcd9709e14cfa6dcbef20f2771bb88c67d Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Sat, 22 Sep 2012 19:38:34 +0200 Subject: [PATCH] disconnect from unicast nodes before raising event --- .../discovery/zen/ping/unicast/UnicastZenPing.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java index 9bb4f1ae5e8..766e6e23dbb 100644 --- a/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java +++ b/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java @@ -182,12 +182,12 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen public void run() { sendPings(timeout, TimeValue.timeValueMillis(timeout.millis() / 2), sendPingsHandler); ConcurrentMap responses = receivedResponses.remove(sendPingsHandler.id()); - listener.onPing(responses.values().toArray(new PingResponse[responses.size()])); + sendPingsHandler.close(); for (DiscoveryNode node : sendPingsHandler.nodeToDisconnect) { logger.trace("[{}] disconnecting from {}", sendPingsHandler.id(), node); transportService.disconnectFromNode(node); } - sendPingsHandler.close(); + listener.onPing(responses.values().toArray(new PingResponse[responses.size()])); } }); } @@ -226,7 +226,6 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen executor.shutdownNow(); executor = null; } - nodeToDisconnect.clear(); } } @@ -266,6 +265,9 @@ public class UnicastZenPing extends AbstractLifecycleComponent implemen @Override public void run() { try { + if (sendPingsHandler.isClosed()) { + return; + } // connect to the node, see if we manage to do it, if not, bail if (!nodeFoundByAddress) { logger.trace("[{}] connecting (light) to {}", sendPingsHandler.id(), nodeToSend);