Thread Pool: Increase the keep alive time of threads from 60 seconds to 60 minutes, closes #657.

This commit is contained in:
kimchy 2011-01-30 20:34:34 +02:00
parent 5b4846b0b6
commit 8b9ec890c3
3 changed files with 3 additions and 3 deletions

View File

@ -62,7 +62,7 @@ public class BlockingThreadPool extends AbstractThreadPool {
// capacity is set to 0 as it might cause starvation in blocking mode // capacity is set to 0 as it might cause starvation in blocking mode
this.capacity = (int) componentSettings.getAsSize("capacity", new SizeValue(0)).singles(); this.capacity = (int) componentSettings.getAsSize("capacity", new SizeValue(0)).singles();
this.waitTime = componentSettings.getAsTime("wait_time", timeValueSeconds(60)); 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); 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 = 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]")); executorService = DynamicExecutors.newBlockingThreadPool(min, max, keepAlive.millis(), capacity, waitTime.millis(), EsExecutors.daemonThreadFactory(settings, "[tp]"));

View File

@ -50,7 +50,7 @@ public class CachedThreadPool extends AbstractThreadPool {
@Inject public CachedThreadPool(Settings settings) { @Inject public CachedThreadPool(Settings settings) {
super(settings); super(settings);
this.scheduledSize = componentSettings.getAsInt("scheduled_size", 20); 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); logger.debug("Initializing {} thread pool with keep_alive[{}], scheduled_size[{}]", getType(), keepAlive, scheduledSize);
executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE, executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
keepAlive.millis(), TimeUnit.MILLISECONDS, keepAlive.millis(), TimeUnit.MILLISECONDS,

View File

@ -52,7 +52,7 @@ public class ScalingThreadPool extends AbstractThreadPool {
super(settings); super(settings);
this.min = componentSettings.getAsInt("min", 10); this.min = componentSettings.getAsInt("min", 10);
this.max = componentSettings.getAsInt("max", 100); 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); this.scheduledSize = componentSettings.getAsInt("scheduled_size", 20);
logger.debug("Initializing {} thread pool with min[{}], max[{}], keep_alive[{}], scheduled_size[{}]", getType(), min, max, keepAlive, scheduledSize); 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]")); scheduledExecutorService = Executors.newScheduledThreadPool(scheduledSize, EsExecutors.daemonThreadFactory(settings, "[sc]"));