lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject lucene-solr git commit: SOLR-8615: Just like creating cores, we should use multiple threads when closing cores.
Date Tue, 09 Feb 2016 01:55:55 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 784124e10 -> ea21b8fae


SOLR-8615: Just like creating cores, we should use multiple threads when closing cores.


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

Branch: refs/heads/master
Commit: ea21b8fae838da3c8cfe3f03f31cf7892369ad5e
Parents: 784124e
Author: markrmiller <markrmiller@apache.org>
Authored: Mon Feb 8 20:41:04 2016 -0500
Committer: markrmiller <markrmiller@apache.org>
Committed: Mon Feb 8 20:41:04 2016 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 ++
 .../java/org/apache/solr/core/SolrCores.java    | 36 +++++++++++++++-----
 2 files changed, 30 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea21b8fa/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ab2f02a..f973822 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -483,6 +483,9 @@ Optimizations
 
 * SOLR-8501: Specify the entity request size when known in HttpSolrClient. (Mark Miller)
 
+* SOLR-8615: Just like creating cores, we should use multiple threads when closing cores.
+  (Mark Miller)
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ea21b8fa/solr/core/src/java/org/apache/solr/core/SolrCores.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCores.java b/solr/core/src/java/org/apache/solr/core/SolrCores.java
index 3d01d63..5980ca1 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCores.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCores.java
@@ -18,7 +18,9 @@ package org.apache.solr.core;
 
 import com.google.common.collect.Lists;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.logging.MDCLoggingContext;
+import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,7 +34,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 
@@ -117,19 +122,32 @@ class SolrCores {
         coreList.addAll(pendingCloses);
         pendingCloses.clear();
       }
-
+      
       for (SolrCore core : coreList) {
-        MDCLoggingContext.setCore(core);
+        ExecutorService coreCloseExecutor = ExecutorUtil.newMDCAwareFixedThreadPool(Integer.MAX_VALUE,
+            new DefaultSolrThreadFactory("coreCloseExecutor"));
         try {
-          core.close();
-        } catch (Throwable e) {
-          SolrException.log(log, "Error shutting down core", e);
-          if (e instanceof Error) {
-            throw (Error) e;
-          }
+          coreCloseExecutor.submit(new Callable<SolrCore>() {
+            @Override
+            public SolrCore call() throws Exception {
+              MDCLoggingContext.setCore(core);
+              try {
+                core.close();
+              } catch (Throwable e) {
+                SolrException.log(log, "Error shutting down core", e);
+                if (e instanceof Error) {
+                  throw (Error) e;
+                }
+              } finally {
+                MDCLoggingContext.clear();
+              }
+              return core;
+            }
+          });
         } finally {
-          MDCLoggingContext.clear();
+          ExecutorUtil.shutdownAndAwaitTermination(coreCloseExecutor);
         }
+
       }
     } while (coreList.size() > 0);
   }


Mime
View raw message