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 2020/08/22 18:42:31 UTC
[lucene-solr] 12/22: @592 Living the executor dream,
all executors all day.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit eafa2395e17b12bd24607043ff1ce634f003ef69
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Aug 20 16:26:55 2020 -0500
@592 Living the executor dream, all executors all day.
---
gradle/testing/defaults-tests.gradle | 2 +-
.../src/java/org/apache/solr/common/ParWork.java | 2 ++
.../java/org/apache/solr/common/ParWorkExecutor.java | 19 +++++++++++++++++++
.../solr/common/ScheduledThreadPoolExecutor.java | 2 --
.../apache/solr/common/util/SolrQueuedThreadPool.java | 4 +++-
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/gradle/testing/defaults-tests.gradle b/gradle/testing/defaults-tests.gradle
index e5824b4..7c4acc8 100644
--- a/gradle/testing/defaults-tests.gradle
+++ b/gradle/testing/defaults-tests.gradle
@@ -69,7 +69,7 @@ allprojects {
minHeapSize = propertyOrDefault("tests.minheapsize", "512m")
maxHeapSize = propertyOrDefault("tests.heapsize", "512m")
- jvmArgs Commandline.translateCommandline(propertyOrDefault("tests.jvmargs", "-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:-UseBiasedLocking -Dorg.apache.xml.dtm.DTMManager=org.apache.xml.dtm.ref.DTMManagerDefault"));
+ jvmArgs Commandline.translateCommandline(propertyOrDefault("tests.jvmargs", "-XX:TieredStopAtLevel=1 -XX:-UseBiasedLocking -Dorg.apache.xml.dtm.DTMManager=org.apache.xml.dtm.ref.DTMManagerDefault -XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=250 -XX:+ExplicitGCInvokesConcurrent"));
systemProperty 'java.util.logging.config.file', file("${commonDir}/tools/junit4/logging.properties")
systemProperty 'java.awt.headless', 'true'
diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWork.java b/solr/solrj/src/java/org/apache/solr/common/ParWork.java
index ad37262..4aebb5a 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWork.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWork.java
@@ -79,6 +79,7 @@ public class ParWork implements Closeable {
synchronized (ParWork.class) {
if (EXEC == null) {
EXEC = (ThreadPoolExecutor) getParExecutorService(2, Integer.MAX_VALUE, 15000, new SynchronousQueue<>());
+ ((ParWorkExecutor)EXEC).closeLock(true);
}
}
}
@@ -89,6 +90,7 @@ public class ParWork implements Closeable {
public static void shutdownExec() {
synchronized (ParWork.class) {
if (EXEC != null) {
+ ((ParWorkExecutor)EXEC).closeLock(false);
EXEC.setKeepAliveTime(1, TimeUnit.NANOSECONDS);
EXEC.allowCoreThreadTimeOut(true);
EXEC.shutdownNow();
diff --git a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
index 9e2ead1..845df6c 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
@@ -20,6 +20,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
@@ -34,6 +36,7 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
private static AtomicInteger threadNumber = new AtomicInteger(0);
private volatile boolean closed;
+ private volatile boolean closeLock;
public ParWorkExecutor(String name, int maxPoolsSize) {
this(name, 0, maxPoolsSize, KEEP_ALIVE_TIME, new SynchronousQueue<>());
@@ -73,7 +76,23 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
}
public void shutdown() {
+ if (closeLock) {
+ throw new IllegalCallerException();
+ }
this.closed = true;
super.shutdown();
}
+
+ public List<Runnable> shutdownNow() {
+ if (closeLock) {
+ throw new IllegalCallerException();
+ }
+ this.closed = true;
+ super.shutdownNow();
+ return Collections.emptyList();
+ }
+
+ public void closeLock(boolean lock) {
+ this.closeLock = lock;
+ }
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/ScheduledThreadPoolExecutor.java b/solr/solrj/src/java/org/apache/solr/common/ScheduledThreadPoolExecutor.java
index 9d6f066..47697d5 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ScheduledThreadPoolExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ScheduledThreadPoolExecutor.java
@@ -19,11 +19,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.RunnableScheduledFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.Condition;
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index 5c4cdd3..deb8025 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -195,7 +195,9 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
super.doStart();
// The threads count set to MIN_VALUE is used to signal to Runners that the pool is stopped.
_counts.set(0, 0); // threads, idle
- ensureThreads();
+ if (!closed) {
+ ensureThreads();
+ }
}
@Override