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/07/21 04:39:28 UTC
[lucene-solr] branch reference_impl updated: @269 Hacking around
until a more permanent solution.
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
The following commit(s) were added to refs/heads/reference_impl by this push:
new 9221a31 @269 Hacking around until a more permanent solution.
9221a31 is described below
commit 9221a31d6181ccf5e35af147263eadd5fad377bf
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Jul 20 23:39:11 2020 -0500
@269 Hacking around until a more permanent solution.
---
.../java/org/apache/solr/core/CoreContainer.java | 2 +-
.../src/java/org/apache/solr/common/ParWork.java | 2 +-
.../org/apache/solr/common/ParWorkExecutor.java | 37 +++++++++++++++++++++-
.../src/java/org/apache/solr/SolrTestCase.java | 6 ++--
4 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index fe504a3..3e6cfab 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -352,7 +352,7 @@ public class CoreContainer implements Closeable {
solrMetricsContext = new SolrMetricsContext(metricManager, registryName, metricTag);
try (ParWork work = new ParWork(this)) {
- if (!Boolean.getBoolean("solr.disablePublicKeyHandler")) {
+ if (Boolean.getBoolean("solr.enablePublicKeyHandler")) {
work.collect(() -> {
try {
containerHandlers.put(PublicKeyHandler.PATH, new PublicKeyHandler(cfg.getCloudConfig()));
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 fd23f91..5182dcd 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWork.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWork.java
@@ -616,7 +616,7 @@ public class ParWork implements Closeable {
public static ExecutorService getExecutorService(int corePoolSize, int maximumPoolSize, int keepAliveTime) {
ThreadPoolExecutor exec;
- exec = new ParWorkExecutor("ParWork", getMaxPoolSize());
+ exec = new ParWorkExecutor("ParWork-" + Thread.currentThread().getName(), getMaxPoolSize());
return exec;
}
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 e1bdc37..1aa442d 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ParWorkExecutor.java
@@ -85,6 +85,17 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
if (task == null) {
throw new NullPointerException();
} else {
+ if (getActiveCount() == getMaximumPoolSize() && getQueue().remainingCapacity() == 0) {
+ try {
+ task.run();
+ } catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException("Exception running task in caller thread");
+ }
+ }
+ return CompletableFuture.completedFuture(new Object());
+ }
RunnableFuture<Object> ftask = super.newTaskFor(task, (Object)null);
try {
this.execute(ftask);
@@ -100,6 +111,17 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
if (task == null) {
throw new NullPointerException();
} else {
+ if (getActiveCount() == getMaximumPoolSize() && getQueue().remainingCapacity() == 0) {
+ try {
+ task.run();
+ } catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException("Exception running task in caller thread");
+ }
+ }
+ return CompletableFuture.completedFuture(result);
+ }
RunnableFuture<T> ftask = this.newTaskFor(task, result);
try {
this.execute(ftask);
@@ -115,7 +137,20 @@ public class ParWorkExecutor extends ThreadPoolExecutor {
if (task == null) {
throw new NullPointerException();
} else {
-
+ if (getActiveCount() == getMaximumPoolSize() && getQueue().remainingCapacity() == 0) {
+ T res = null;
+ try {
+ res = task.call();
+ } catch (Exception e) {
+ if (e instanceof InterruptedException) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException("Exception running task in caller thread");
+ }
+ }
+ CompletableFuture<Object> future = new CompletableFuture<>();
+ future.complete(res);
+ return (Future<T>) future;
+ }
RunnableFuture<T> ftask = this.newTaskFor(task);
try {
this.execute(ftask);
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index e16b789..37663af 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -197,7 +197,7 @@ public class SolrTestCase extends LuceneTestCase {
System.setProperty("solr.clustering.enabled", "false");
System.setProperty("solr.peerSync.useRangeVersions", String.valueOf(random().nextBoolean()));
System.setProperty("zookeeper.nio.directBufferBytes", Integer.toString(32 * 1024 * 2));
-
+ System.setProperty("solr.disablePublicKeyHandler", "true");
if (!TEST_NIGHTLY) {
//TestInjection.randomDelayMaxInCoreCreationInSec = 2;
@@ -243,7 +243,7 @@ public class SolrTestCase extends LuceneTestCase {
System.setProperty("solr.http2solrclient.maxpool.size", "6");
System.setProperty("solr.http2solrclient.pool.keepalive", "5000");
- System.setProperty("solr.disablePublicKeyHandler", "true");
+ System.setProperty("solr.disablePublicKeyHandler", "false");
System.setProperty("solr.dependentupdate.timeout", "1"); // seconds
System.setProperty("lucene.cms.override_core_count", "3");
@@ -377,7 +377,7 @@ public class SolrTestCase extends LuceneTestCase {
ExecutorUtil.shutdownAndAwaitTermination(testExecutor);
testExecutor = null;
}
-
+ if (CoreContainer.solrCoreLoadExecutor != null) CoreContainer.solrCoreLoadExecutor.shutdownNow();
ExecutorUtil.shutdownAndAwaitTermination(CoreContainer.solrCoreLoadExecutor);
CoreContainer.solrCoreLoadExecutor = null;