From df07fb33bb2ea0ece6ad9229a50c9661d710fdbe Mon Sep 17 00:00:00 2001 From: Chris Hostetter Date: Thu, 13 Dec 2018 19:59:35 -0700 Subject: [PATCH] SOLR-13043: cleanup suspicious ExecutorService lifecycles in MiniSolrCloudCluster --- .../solr/cloud/MiniSolrCloudCluster.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java index 9b52b802fa4..fd719edad33 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java @@ -122,9 +122,6 @@ public class MiniSolrCloudCluster { private final CloudSolrClient solrClient; private final JettyConfig jettyConfig; - private final ExecutorService executorLauncher = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("jetty-launcher")); - private final ExecutorService executorCloser = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("jetty-closer")); - private final AtomicInteger nodeIds = new AtomicInteger(); /** @@ -272,7 +269,9 @@ public class MiniSolrCloudCluster { startups.add(() -> startJettySolrRunner(newNodeName(), jettyConfig.context, jettyConfig)); } + final ExecutorService executorLauncher = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("jetty-launcher")); Collection> futures = executorLauncher.invokeAll(startups); + ExecutorUtil.shutdownAndAwaitTermination(executorLauncher); Exception startupError = checkForExceptions("Error starting up MiniSolrCloudCluster", futures); if (startupError != null) { try { @@ -294,10 +293,6 @@ public class MiniSolrCloudCluster { private void waitForAllNodes(int numServers, int timeoutSeconds) throws IOException, InterruptedException, TimeoutException { - executorLauncher.shutdown(); - - ExecutorUtil.shutdownAndAwaitTermination(executorLauncher); - int numRunning = 0; TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME); @@ -327,10 +322,6 @@ public class MiniSolrCloudCluster { public void waitForNode(JettySolrRunner jetty, int timeoutSeconds) throws IOException, InterruptedException, TimeoutException { - executorLauncher.shutdown(); - - ExecutorUtil.shutdownAndAwaitTermination(executorLauncher); - ZkStateReader reader = getSolrClient().getZkStateReader(); reader.waitForLiveNodes(30, TimeUnit.SECONDS, (o, n) -> n.contains(jetty.getNodeName())); @@ -577,21 +568,19 @@ public class MiniSolrCloudCluster { try { IOUtils.closeQuietly(solrClient); - // accept no new tasks - executorLauncher.shutdown(); List> shutdowns = new ArrayList<>(jettys.size()); for (final JettySolrRunner jetty : jettys) { shutdowns.add(() -> stopJettySolrRunner(jetty)); } jettys.clear(); + final ExecutorService executorCloser = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("jetty-closer")); Collection> futures = executorCloser.invokeAll(shutdowns); + ExecutorUtil.shutdownAndAwaitTermination(executorCloser); Exception shutdownError = checkForExceptions("Error shutting down MiniSolrCloudCluster", futures); if (shutdownError != null) { throw shutdownError; } } finally { - ExecutorUtil.shutdownAndAwaitTermination(executorLauncher); - ExecutorUtil.shutdownAndAwaitTermination(executorCloser); try { if (!externalZkServer) { zkServer.shutdown();