Skip to content

Commit

Permalink
Remove sleep when waiting for node closure (#1722)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied authored Apr 6, 2022
1 parent 2972bd1 commit f2edade
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -247,18 +248,18 @@ public final void stopCluster() throws Exception {

private void closeAllNodes() throws Exception {
//close non master nodes
opensearchNodes.stream().filter(n->!n.isMasterEligible()).forEach(node->closeNode(node));
opensearchNodes.stream().filter(n->!n.isMasterEligible()).forEach(ClusterHelper::closeNode);

//close master nodes
opensearchNodes.stream().filter(n->n.isMasterEligible()).forEach(node->closeNode(node));
opensearchNodes.stream().filter(n->n.isMasterEligible()).forEach(ClusterHelper::closeNode);
opensearchNodes.clear();
clusterState = ClusterState.STOPPED;
}

private static void closeNode(Node node) {
try {
node.close();
Thread.sleep(250);
node.awaitClose(250, TimeUnit.MILLISECONDS);
} catch (Throwable e) {
//ignore
}
Expand Down

0 comments on commit f2edade

Please sign in to comment.