From 8b9ec890c3c0f2cf29284aabb3d65aef24e523cf Mon Sep 17 00:00:00 2001 From: kimchy Date: Sun, 30 Jan 2011 20:34:34 +0200 Subject: [PATCH] Thread Pool: Increase the keep alive time of threads from 60 seconds to 60 minutes, closes #657. --- .../elasticsearch/threadpool/blocking/BlockingThreadPool.java | 2 +- .../org/elasticsearch/threadpool/cached/CachedThreadPool.java | 2 +- .../org/elasticsearch/threadpool/scaling/ScalingThreadPool.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/blocking/BlockingThreadPool.java b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/blocking/BlockingThreadPool.java index b4ca76b027a..d0cac562eb3 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/blocking/BlockingThreadPool.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/blocking/BlockingThreadPool.java @@ -62,7 +62,7 @@ public class BlockingThreadPool extends AbstractThreadPool { // capacity is set to 0 as it might cause starvation in blocking mode this.capacity = (int) componentSettings.getAsSize("capacity", new SizeValue(0)).singles(); this.waitTime = componentSettings.getAsTime("wait_time", timeValueSeconds(60)); - this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueSeconds(60)); + this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueMinutes(60)); logger.debug("initializing {} thread pool with min[{}], max[{}], keep_alive[{}], capacity[{}], wait_time[{}], scheduled_size[{}]", getType(), min, max, keepAlive, capacity, waitTime, scheduledSize); // executorService = TransferThreadPoolExecutor.newBlockingExecutor(min, max, keepAlive.millis(), TimeUnit.MILLISECONDS, waitTime.millis(), TimeUnit.MILLISECONDS, capacity, EsExecutors.daemonThreadFactory(settings, "[tp]")); executorService = DynamicExecutors.newBlockingThreadPool(min, max, keepAlive.millis(), capacity, waitTime.millis(), EsExecutors.daemonThreadFactory(settings, "[tp]")); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/cached/CachedThreadPool.java b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/cached/CachedThreadPool.java index 826ae15a6f0..0da5aba4337 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/cached/CachedThreadPool.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/cached/CachedThreadPool.java @@ -50,7 +50,7 @@ public class CachedThreadPool extends AbstractThreadPool { @Inject public CachedThreadPool(Settings settings) { super(settings); this.scheduledSize = componentSettings.getAsInt("scheduled_size", 20); - this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueSeconds(60)); + this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueMinutes(60)); logger.debug("Initializing {} thread pool with keep_alive[{}], scheduled_size[{}]", getType(), keepAlive, scheduledSize); executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, keepAlive.millis(), TimeUnit.MILLISECONDS, diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/scaling/ScalingThreadPool.java b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/scaling/ScalingThreadPool.java index e1dc1c3ba27..d8887221fa9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/scaling/ScalingThreadPool.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/threadpool/scaling/ScalingThreadPool.java @@ -52,7 +52,7 @@ public class ScalingThreadPool extends AbstractThreadPool { super(settings); this.min = componentSettings.getAsInt("min", 10); this.max = componentSettings.getAsInt("max", 100); - this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueSeconds(60)); + this.keepAlive = componentSettings.getAsTime("keep_alive", timeValueMinutes(60)); this.scheduledSize = componentSettings.getAsInt("scheduled_size", 20); logger.debug("Initializing {} thread pool with min[{}], max[{}], keep_alive[{}], scheduled_size[{}]", getType(), min, max, keepAlive, scheduledSize); scheduledExecutorService = Executors.newScheduledThreadPool(scheduledSize, EsExecutors.daemonThreadFactory(settings, "[sc]"));