Index executors: Use directExecutor for negative thread values
This will make it easier to test index-related logic in tests. We still use 0 as a default way of setting the JVM threads. Change-Id: If186a23ee4e79c49306bf9f286a24841d99e6531
This commit is contained in:
@@ -2779,16 +2779,16 @@ Number of threads to use for indexing in normal interactive operations. Setting
|
||||
it to 0 disables the dedicated thread pool and indexing will be done in the same
|
||||
thread as the operation.
|
||||
+
|
||||
If not set or set to a negative value, defaults to 1 plus half of the number of
|
||||
logical CPUs as returned by the JVM.
|
||||
If not set or set to a zero, defaults to the number of logical CPUs as returned
|
||||
by the JVM. If set to a negative value, defaults to a direct executor.
|
||||
|
||||
[[index.batchThreads]]index.batchThreads::
|
||||
+
|
||||
Number of threads to use for indexing in background operations, such as
|
||||
online schema upgrades.
|
||||
+
|
||||
If not set or set to a negative value, defaults to the number of logical
|
||||
CPUs as returned by the JVM.
|
||||
If not set or set to a zero, defaults to the number of logical CPUs as returned
|
||||
by the JVM. If set to a negative value, defaults to a direct executor.
|
||||
|
||||
[[index.onlineUpgrade]]index.onlineUpgrade::
|
||||
+
|
||||
|
@@ -397,6 +397,8 @@ public abstract class AbstractDaemonTest {
|
||||
baseConfig.setString("sshd", null, "listenAddress", "off");
|
||||
}
|
||||
|
||||
baseConfig.setInt("index", null, "batchThreads", -1);
|
||||
|
||||
baseConfig.setInt("receive", null, "changeUpdateThreads", 4);
|
||||
Module module = createModule();
|
||||
if (classDesc.equals(methodDesc) && !classDesc.sandboxed() && !methodDesc.sandboxed()) {
|
||||
|
@@ -104,7 +104,7 @@ public class IndexModule extends LifecycleModule {
|
||||
|
||||
public IndexModule(
|
||||
ListeningExecutorService interactiveExecutor, ListeningExecutorService batchExecutor) {
|
||||
this.threads = -1;
|
||||
this.threads = 0;
|
||||
this.interactiveExecutor = interactiveExecutor;
|
||||
this.batchExecutor = batchExecutor;
|
||||
this.closeExecutorsOnShutdown = false;
|
||||
@@ -211,11 +211,12 @@ public class IndexModule extends LifecycleModule {
|
||||
return interactiveExecutor;
|
||||
}
|
||||
int threads = this.threads;
|
||||
if (threads <= 0) {
|
||||
threads = config.getInt("index", null, "threads", 0);
|
||||
}
|
||||
if (threads <= 0) {
|
||||
threads = Runtime.getRuntime().availableProcessors() / 2 + 1;
|
||||
if (threads < 0) {
|
||||
return MoreExecutors.newDirectExecutorService();
|
||||
} else if (threads == 0) {
|
||||
threads =
|
||||
config.getInt(
|
||||
"index", null, "threads", Runtime.getRuntime().availableProcessors() / 2 + 1);
|
||||
}
|
||||
return MoreExecutors.listeningDecorator(
|
||||
workQueue.createQueue(threads, "Index-Interactive", true));
|
||||
@@ -230,7 +231,9 @@ public class IndexModule extends LifecycleModule {
|
||||
return batchExecutor;
|
||||
}
|
||||
int threads = config.getInt("index", null, "batchThreads", 0);
|
||||
if (threads <= 0) {
|
||||
if (threads < 0) {
|
||||
return MoreExecutors.newDirectExecutorService();
|
||||
} else if (threads == 0) {
|
||||
threads = Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
return MoreExecutors.listeningDecorator(workQueue.createQueue(threads, "Index-Batch", true));
|
||||
|
Reference in New Issue
Block a user