From bb006b94caafd982c633a2830f1eb9a63d24fc0c Mon Sep 17 00:00:00 2001 From: jonmv Date: Tue, 11 Jul 2023 12:02:13 +0200 Subject: Reinstate public (unused) method, warn when failing ping shutdown --- .../main/java/com/yahoo/search/cluster/ClusterMonitor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'container-search') diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java index d66b6637cd3..d1c212168a6 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterMonitor.java @@ -103,6 +103,11 @@ public class ClusterMonitor { nodeManager.pingIterationCompleted(); } + /** Returns a thread-safe snapshot of the NodeMonitors of all added nodes */ + public Iterator> nodeMonitorIterator() { + return nodeMonitors().iterator(); + } + /** Returns a thread-safe snapshot of the NodeMonitors of all added nodes */ public List> nodeMonitors() { return List.copyOf(nodeMonitors.values()); @@ -137,7 +142,7 @@ public class ClusterMonitor { // for all pings when there are no problems (important because it ensures that // any thread local connections are reused) 2) a new thread will be started to execute // new pings when a ping is not responding - ExecutorService pingExecutor=Executors.newCachedThreadPool(ThreadFactoryFactory.getDaemonThreadFactory("search.ping")); + ExecutorService pingExecutor = Executors.newCachedThreadPool(ThreadFactoryFactory.getDaemonThreadFactory("search.ping")); while (!closed.get()) { try { log.finest("Activating ping"); @@ -159,7 +164,9 @@ public class ClusterMonitor { } pingExecutor.shutdown(); try { - pingExecutor.awaitTermination(10, TimeUnit.SECONDS); + if ( ! pingExecutor.awaitTermination(10, TimeUnit.SECONDS)) { + log.warning("Timeout waiting for ping executor to terminate"); + } } catch (InterruptedException e) { } log.info("Stopped cluster monitor thread " + getName()); } -- cgit v1.2.3