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:
@@ -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