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 21:02:46 UTC
lucene-solr:branch_6x: SOLR-10193: Improve
MiniSolrCloudCluster#shutdown.
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x ed6090138 -> 5d76917cf
SOLR-10193: Improve MiniSolrCloudCluster#shutdown.
# Conflicts:
# solr/test-framework/src/java/org/apache/solr/cloud/MiniSolrCloudCluster.java
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/5d76917c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5d76917c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5d76917c
Branch: refs/heads/branch_6x
Commit: 5d76917cf53a0db7a39ab6ca92eb53d9fe54a412
Parents: ed60901
Author: markrmiller <ma...@apache.org>
Authored: Wed Feb 22 15:58:12 2017 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Wed Feb 22 15:59:48 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/5d76917c/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 078125e..4510eb9 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
@@ -38,7 +38,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.SolrServerException;
@@ -59,6 +58,7 @@ import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.NamedList;
+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;
@@ -106,8 +106,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();
/**
@@ -248,7 +249,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 {
@@ -516,21 +517,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();