Add support for zero queue size in the search thread pool

This commit is contained in:
Igor Motov 2012-06-25 20:33:21 -04:00 committed by Shay Banon
parent eb954a6157
commit 7f77cfada0
1 changed files with 9 additions and 1 deletions

View File

@ -241,9 +241,17 @@ public class ThreadPool extends AbstractComponent {
throw new ElasticSearchIllegalArgumentException("reject_policy [" + rejectSetting + "] not valid for [" + name + "] thread pool"); throw new ElasticSearchIllegalArgumentException("reject_policy [" + rejectSetting + "] not valid for [" + name + "] thread pool");
} }
logger.debug("creating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}]", name, type, size, capacity, rejectSetting); logger.debug("creating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}]", name, type, size, capacity, rejectSetting);
BlockingQueue<Runnable> workQueue;
if (capacity == null) {
workQueue = new LinkedTransferQueue<Runnable>();
} else if ((int) capacity.singles() > 0) {
workQueue = new ArrayBlockingQueue<Runnable>((int) capacity.singles());
} else {
workQueue = new SynchronousQueue<Runnable>();
}
Executor executor = new EsThreadPoolExecutor(size, size, Executor executor = new EsThreadPoolExecutor(size, size,
0L, TimeUnit.MILLISECONDS, 0L, TimeUnit.MILLISECONDS,
capacity == null ? new LinkedTransferQueue<Runnable>() : new ArrayBlockingQueue<Runnable>((int) capacity.singles()), workQueue,
threadFactory, rejectedExecutionHandler); threadFactory, rejectedExecutionHandler);
return new ExecutorHolder(executor, new Info(name, type, size, size, null, capacity)); return new ExecutorHolder(executor, new Info(name, type, size, size, null, capacity));
} else if ("scaling".equals(type)) { } else if ("scaling".equals(type)) {