You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2017/02/22 20:58:19 UTC

lucene-solr:master: SOLR-10193: Improve MiniSolrCloudCluster#shutdown.

Repository: lucene-solr
Updated Branches:
  refs/heads/master d6337ac3e -> 29a5ea44a


SOLR-10193: Improve MiniSolrCloudCluster#shutdown.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/29a5ea44
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/29a5ea44
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/29a5ea44

Branch: refs/heads/master
Commit: 29a5ea44a7f010e27a8c8951d697fc0fbb8d5403
Parents: d6337ac
Author: markrmiller <ma...@apache.org>
Authored: Wed Feb 22 15:58:12 2017 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Wed Feb 22 15:58:12 2017 -0500

----------------------------------------------------------------------
 .../apache/solr/cloud/MiniSolrCloudCluster.java | 21 +++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/29a5ea44/solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
----------------------------------------------------------------------
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 7eb9b0d..e8a0c08 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
@@ -36,7 +36,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.solr.client.solrj.embedded.JettyConfig;
@@ -50,6 +49,7 @@ import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkConfigManager;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.IOUtils;
 import org.apache.solr.common.util.SolrjNamedThreadFactory;
 import org.apache.solr.core.CoreContainer;
 import org.apache.zookeeper.KeeperException;
@@ -97,8 +97,9 @@ public class MiniSolrCloudCluster {
   private final CloudSolrClient solrClient;
   private final JettyConfig jettyConfig;
 
-  private final ExecutorService executor = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("jetty-launcher"));
-
+  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();
 
   /**
@@ -239,7 +240,7 @@ public class MiniSolrCloudCluster {
       startups.add(() -> startJettySolrRunner(newNodeName(), jettyConfig.context, jettyConfig));
     }
 
-    Collection<Future<JettySolrRunner>> futures = executor.invokeAll(startups);
+    Collection<Future<JettySolrRunner>> futures = executorLauncher.invokeAll(startups);
     Exception startupError = checkForExceptions("Error starting up MiniSolrCloudCluster", futures);
     if (startupError != null) {
       try {
@@ -443,21 +444,23 @@ public class MiniSolrCloudCluster {
    */
   public void shutdown() throws Exception {
     try {
-      if (solrClient != null)
-        solrClient.close();
+    
+      IOUtils.closeQuietly(solrClient);
+      // accept no new tasks
+      executorLauncher.shutdown();
       List<Callable<JettySolrRunner>> shutdowns = new ArrayList<>(jettys.size());
       for (final JettySolrRunner jetty : jettys) {
         shutdowns.add(() -> stopJettySolrRunner(jetty));
       }
       jettys.clear();
-      Collection<Future<JettySolrRunner>> futures = executor.invokeAll(shutdowns);
+      Collection<Future<JettySolrRunner>> futures = executorCloser.invokeAll(shutdowns);
       Exception shutdownError = checkForExceptions("Error shutting down MiniSolrCloudCluster", futures);
       if (shutdownError != null) {
         throw shutdownError;
       }
     } finally {
-      executor.shutdown();
-      executor.awaitTermination(15, TimeUnit.SECONDS);
+      ExecutorUtil.shutdownAndAwaitTermination(executorLauncher);
+      ExecutorUtil.shutdownAndAwaitTermination(executorCloser);
       try {
         if (!externalZkServer) {
           zkServer.shutdown();