mirror of https://github.com/apache/lucene.git
SOLR-8615: Just like creating cores, we should use multiple threads when closing cores.
This commit is contained in:
parent
784124e100
commit
ea21b8fae8
|
@ -483,6 +483,9 @@ Optimizations
|
||||||
|
|
||||||
* SOLR-8501: Specify the entity request size when known in HttpSolrClient. (Mark Miller)
|
* 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
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@ package org.apache.solr.core;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.solr.common.SolrException;
|
import org.apache.solr.common.SolrException;
|
||||||
|
import org.apache.solr.common.util.ExecutorUtil;
|
||||||
import org.apache.solr.logging.MDCLoggingContext;
|
import org.apache.solr.logging.MDCLoggingContext;
|
||||||
|
import org.apache.solr.util.DefaultSolrThreadFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -32,7 +34,10 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,19 +122,32 @@ class SolrCores {
|
||||||
coreList.addAll(pendingCloses);
|
coreList.addAll(pendingCloses);
|
||||||
pendingCloses.clear();
|
pendingCloses.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SolrCore core : coreList) {
|
for (SolrCore core : coreList) {
|
||||||
MDCLoggingContext.setCore(core);
|
ExecutorService coreCloseExecutor = ExecutorUtil.newMDCAwareFixedThreadPool(Integer.MAX_VALUE,
|
||||||
|
new DefaultSolrThreadFactory("coreCloseExecutor"));
|
||||||
try {
|
try {
|
||||||
core.close();
|
coreCloseExecutor.submit(new Callable<SolrCore>() {
|
||||||
} catch (Throwable e) {
|
@Override
|
||||||
SolrException.log(log, "Error shutting down core", e);
|
public SolrCore call() throws Exception {
|
||||||
if (e instanceof Error) {
|
MDCLoggingContext.setCore(core);
|
||||||
throw (Error) e;
|
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 {
|
} finally {
|
||||||
MDCLoggingContext.clear();
|
ExecutorUtil.shutdownAndAwaitTermination(coreCloseExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} while (coreList.size() > 0);
|
} while (coreList.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue