parent
7afffbe13b
commit
41e4ee22e6
|
@ -139,7 +139,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
public ThreadPoolInfo info() {
|
public ThreadPoolInfo info() {
|
||||||
List<Info> infos = new ArrayList<Info>();
|
List<Info> infos = new ArrayList<Info>();
|
||||||
for (ExecutorHolder holder : executors.values()) {
|
for (ExecutorHolder holder : executors.values()) {
|
||||||
String name = holder.info.name();
|
String name = holder.info.getName();
|
||||||
// no need to have info on "same" thread pool
|
// no need to have info on "same" thread pool
|
||||||
if ("same".equals(name)) {
|
if ("same".equals(name)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -152,7 +152,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
public ThreadPoolStats stats() {
|
public ThreadPoolStats stats() {
|
||||||
List<ThreadPoolStats.Stats> stats = new ArrayList<ThreadPoolStats.Stats>();
|
List<ThreadPoolStats.Stats> stats = new ArrayList<ThreadPoolStats.Stats>();
|
||||||
for (ExecutorHolder holder : executors.values()) {
|
for (ExecutorHolder holder : executors.values()) {
|
||||||
String name = holder.info.name();
|
String name = holder.info.getName();
|
||||||
// no need to have info on "same" thread pool
|
// no need to have info on "same" thread pool
|
||||||
if ("same".equals(name)) {
|
if ("same".equals(name)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -258,7 +258,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
settings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
settings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||||
}
|
}
|
||||||
Info previousInfo = previousExecutorHolder != null ? previousExecutorHolder.info : null;
|
Info previousInfo = previousExecutorHolder != null ? previousExecutorHolder.info : null;
|
||||||
String type = settings.get("type", previousInfo != null ? previousInfo.type() : defaultSettings.get("type"));
|
String type = settings.get("type", previousInfo != null ? previousInfo.getType() : defaultSettings.get("type"));
|
||||||
ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(this.settings, name);
|
ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(this.settings, name);
|
||||||
if ("same".equals(type)) {
|
if ("same".equals(type)) {
|
||||||
if (previousExecutorHolder != null) {
|
if (previousExecutorHolder != null) {
|
||||||
|
@ -270,17 +270,17 @@ public class ThreadPool extends AbstractComponent {
|
||||||
} else if ("cached".equals(type)) {
|
} else if ("cached".equals(type)) {
|
||||||
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
||||||
if (previousExecutorHolder != null) {
|
if (previousExecutorHolder != null) {
|
||||||
if ("cached".equals(previousInfo.type())) {
|
if ("cached".equals(previousInfo.getType())) {
|
||||||
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.keepAlive());
|
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.getKeepAlive());
|
||||||
if (!previousInfo.keepAlive().equals(updatedKeepAlive)) {
|
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive)) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setKeepAliveTime(updatedKeepAlive.millis(), TimeUnit.MILLISECONDS);
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setKeepAliveTime(updatedKeepAlive.millis(), TimeUnit.MILLISECONDS);
|
||||||
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, -1, -1, updatedKeepAlive, null));
|
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, -1, -1, updatedKeepAlive, null));
|
||||||
}
|
}
|
||||||
return previousExecutorHolder;
|
return previousExecutorHolder;
|
||||||
}
|
}
|
||||||
if (previousInfo.keepAlive() != null) {
|
if (previousInfo.getKeepAlive() != null) {
|
||||||
defaultKeepAlive = previousInfo.keepAlive();
|
defaultKeepAlive = previousInfo.getKeepAlive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TimeValue keepAlive = settings.getAsTime("keep_alive", defaultKeepAlive);
|
TimeValue keepAlive = settings.getAsTime("keep_alive", defaultKeepAlive);
|
||||||
|
@ -296,55 +296,55 @@ public class ThreadPool extends AbstractComponent {
|
||||||
return new ExecutorHolder(executor, new Info(name, type, -1, -1, keepAlive, null));
|
return new ExecutorHolder(executor, new Info(name, type, -1, -1, keepAlive, null));
|
||||||
} else if ("fixed".equals(type)) {
|
} else if ("fixed".equals(type)) {
|
||||||
int defaultSize = defaultSettings.getAsInt("size", Runtime.getRuntime().availableProcessors() * 5);
|
int defaultSize = defaultSettings.getAsInt("size", Runtime.getRuntime().availableProcessors() * 5);
|
||||||
SizeValue defaultCapacity = defaultSettings.getAsSize("queue", defaultSettings.getAsSize("queue_size", null));
|
SizeValue defaultQueueSize = defaultSettings.getAsSize("queue", defaultSettings.getAsSize("queue_size", null));
|
||||||
String defaultRejectSetting = defaultSettings.get("reject_policy", "abort");
|
String defaultRejectSetting = defaultSettings.get("reject_policy", "abort");
|
||||||
String defaultQueueType = defaultSettings.get("queue_type", "linked");
|
String defaultQueueType = defaultSettings.get("queue_type", "linked");
|
||||||
|
|
||||||
if (previousExecutorHolder != null) {
|
if (previousExecutorHolder != null) {
|
||||||
if ("fixed".equals(previousInfo.type())) {
|
if ("fixed".equals(previousInfo.getType())) {
|
||||||
SizeValue updatedCapacity = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", previousInfo.capacity())));
|
SizeValue updatedQueueSize = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", previousInfo.getQueueSize())));
|
||||||
String updatedQueueType = settings.get("queue_type", previousInfo.queueType());
|
String updatedQueueType = settings.get("queue_type", previousInfo.getQueueType());
|
||||||
if (Objects.equal(previousInfo.capacity(), updatedCapacity) && previousInfo.queueType().equals(updatedQueueType)) {
|
if (Objects.equal(previousInfo.getQueueSize(), updatedQueueSize) && previousInfo.getQueueType().equals(updatedQueueType)) {
|
||||||
int updatedSize = settings.getAsInt("size", previousInfo.max());
|
int updatedSize = settings.getAsInt("size", previousInfo.getMax());
|
||||||
String updatedRejectSetting = settings.get("reject_policy", previousInfo.rejectSetting());
|
String updatedRejectSetting = settings.get("reject_policy", previousInfo.getRejectSetting());
|
||||||
if (previousInfo.max() != updatedSize) {
|
if (previousInfo.getMax() != updatedSize) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, updatedSize, updatedCapacity, updatedRejectSetting, updatedQueueType);
|
logger.debug("updating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, updatedSize, updatedQueueSize, updatedRejectSetting, updatedQueueType);
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setCorePoolSize(updatedSize);
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setCorePoolSize(updatedSize);
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setMaximumPoolSize(updatedSize);
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setMaximumPoolSize(updatedSize);
|
||||||
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedSize, updatedSize, null, updatedCapacity, null, updatedRejectSetting, updatedQueueType));
|
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedSize, updatedSize, null, updatedQueueSize, null, updatedRejectSetting, updatedQueueType));
|
||||||
}
|
}
|
||||||
if (!previousInfo.rejectSetting().equals(updatedRejectSetting)) {
|
if (!previousInfo.getRejectSetting().equals(updatedRejectSetting)) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, updatedSize, updatedCapacity, updatedRejectSetting, updatedQueueType);
|
logger.debug("updating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, updatedSize, updatedQueueSize, updatedRejectSetting, updatedQueueType);
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setRejectedExecutionHandler(newRejectedExecutionHandler(name, updatedRejectSetting));
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setRejectedExecutionHandler(newRejectedExecutionHandler(name, updatedRejectSetting));
|
||||||
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedSize, updatedSize, null, updatedCapacity, null, updatedRejectSetting, updatedQueueType));
|
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedSize, updatedSize, null, updatedQueueSize, null, updatedRejectSetting, updatedQueueType));
|
||||||
}
|
}
|
||||||
return previousExecutorHolder;
|
return previousExecutorHolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (previousInfo.max() >= 0) {
|
if (previousInfo.getMax() >= 0) {
|
||||||
defaultSize = previousInfo.max();
|
defaultSize = previousInfo.getMax();
|
||||||
}
|
}
|
||||||
defaultCapacity = previousInfo.capacity();
|
defaultQueueSize = previousInfo.getQueueSize();
|
||||||
if (previousInfo.rejectSetting != null) {
|
if (previousInfo.rejectSetting != null) {
|
||||||
defaultRejectSetting = previousInfo.rejectSetting;
|
defaultRejectSetting = previousInfo.rejectSetting;
|
||||||
}
|
}
|
||||||
if (previousInfo.queueType() != null) {
|
if (previousInfo.getQueueType() != null) {
|
||||||
defaultQueueType = previousInfo.queueType();
|
defaultQueueType = previousInfo.getQueueType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = settings.getAsInt("size", defaultSize);
|
int size = settings.getAsInt("size", defaultSize);
|
||||||
SizeValue capacity = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultCapacity)));
|
SizeValue queueSize = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultQueueSize)));
|
||||||
String rejectSetting = settings.get("reject_policy", defaultRejectSetting);
|
String rejectSetting = settings.get("reject_policy", defaultRejectSetting);
|
||||||
RejectedExecutionHandler rejectedExecutionHandler = newRejectedExecutionHandler(name, rejectSetting);
|
RejectedExecutionHandler rejectedExecutionHandler = newRejectedExecutionHandler(name, rejectSetting);
|
||||||
String queueType = settings.get("queue_type", defaultQueueType);
|
String queueType = settings.get("queue_type", defaultQueueType);
|
||||||
BlockingQueue<Runnable> workQueue = newQueue(capacity, queueType);
|
BlockingQueue<Runnable> workQueue = newQueue(queueSize, queueType);
|
||||||
logger.debug("creating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, size, capacity, rejectSetting, queueType);
|
logger.debug("creating thread_pool [{}], type [{}], size [{}], queue_size [{}], reject_policy [{}], queue_type [{}]", name, type, size, queueSize, rejectSetting, queueType);
|
||||||
Executor executor = new EsThreadPoolExecutor(size, size,
|
Executor executor = new EsThreadPoolExecutor(size, size,
|
||||||
0L, TimeUnit.MILLISECONDS,
|
0L, TimeUnit.MILLISECONDS,
|
||||||
workQueue,
|
workQueue,
|
||||||
threadFactory, rejectedExecutionHandler);
|
threadFactory, rejectedExecutionHandler);
|
||||||
return new ExecutorHolder(executor, new Info(name, type, size, size, null, capacity, null, rejectSetting, queueType));
|
return new ExecutorHolder(executor, new Info(name, type, size, size, null, queueSize, null, rejectSetting, queueType));
|
||||||
} else if ("scaling".equals(type)) {
|
} else if ("scaling".equals(type)) {
|
||||||
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
||||||
int defaultMin = defaultSettings.getAsInt("min", 1);
|
int defaultMin = defaultSettings.getAsInt("min", 1);
|
||||||
|
@ -354,7 +354,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.getKeepAlive());
|
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.getKeepAlive());
|
||||||
int updatedMin = settings.getAsInt("min", previousInfo.getMin());
|
int updatedMin = settings.getAsInt("min", previousInfo.getMin());
|
||||||
int updatedSize = settings.getAsInt("max", settings.getAsInt("size", previousInfo.getMax()));
|
int updatedSize = settings.getAsInt("max", settings.getAsInt("size", previousInfo.getMax()));
|
||||||
if (!previousInfo.keepAlive().equals(updatedKeepAlive) || previousInfo.min() != updatedMin || previousInfo.max() != updatedSize) {
|
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive) || previousInfo.getMin() != updatedMin || previousInfo.getMax() != updatedSize) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
||||||
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive)) {
|
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive)) {
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setKeepAliveTime(updatedKeepAlive.millis(), TimeUnit.MILLISECONDS);
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setKeepAliveTime(updatedKeepAlive.millis(), TimeUnit.MILLISECONDS);
|
||||||
|
@ -393,17 +393,17 @@ public class ThreadPool extends AbstractComponent {
|
||||||
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
TimeValue defaultKeepAlive = defaultSettings.getAsTime("keep_alive", timeValueMinutes(5));
|
||||||
int defaultMin = defaultSettings.getAsInt("min", 1);
|
int defaultMin = defaultSettings.getAsInt("min", 1);
|
||||||
int defaultSize = defaultSettings.getAsInt("size", Runtime.getRuntime().availableProcessors() * 5);
|
int defaultSize = defaultSettings.getAsInt("size", Runtime.getRuntime().availableProcessors() * 5);
|
||||||
SizeValue defaultCapacity = defaultSettings.getAsSize("queue_size", new SizeValue(1000));
|
SizeValue defaultQueueSize = defaultSettings.getAsSize("queue_size", new SizeValue(1000));
|
||||||
TimeValue defaultWaitTime = defaultSettings.getAsTime("wait_time", timeValueSeconds(60));
|
TimeValue defaultWaitTime = defaultSettings.getAsTime("wait_time", timeValueSeconds(60));
|
||||||
if (previousExecutorHolder != null) {
|
if (previousExecutorHolder != null) {
|
||||||
if ("blocking".equals(previousInfo.getType())) {
|
if ("blocking".equals(previousInfo.getType())) {
|
||||||
SizeValue updatedCapacity = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultCapacity)));
|
SizeValue updatedQueueSize = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultQueueSize)));
|
||||||
TimeValue updatedWaitTime = settings.getAsTime("wait_time", defaultWaitTime);
|
TimeValue updatedWaitTime = settings.getAsTime("wait_time", defaultWaitTime);
|
||||||
if (previousInfo.capacity().equals(updatedCapacity) && previousInfo.waitTime().equals(updatedWaitTime)) {
|
if (previousInfo.getQueueSize().equals(updatedQueueSize) && previousInfo.getWaitTime().equals(updatedWaitTime)) {
|
||||||
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.getKeepAlive());
|
TimeValue updatedKeepAlive = settings.getAsTime("keep_alive", previousInfo.getKeepAlive());
|
||||||
int updatedMin = settings.getAsInt("min", previousInfo.getMin());
|
int updatedMin = settings.getAsInt("min", previousInfo.getMin());
|
||||||
int updatedSize = settings.getAsInt("max", settings.getAsInt("size", previousInfo.getMax()));
|
int updatedSize = settings.getAsInt("max", settings.getAsInt("size", previousInfo.getMax()));
|
||||||
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive) || !previousInfo.waitTime().equals(settings.getAsTime("wait_time", defaultWaitTime)) ||
|
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive) || !previousInfo.getWaitTime().equals(settings.getAsTime("wait_time", defaultWaitTime)) ||
|
||||||
previousInfo.getMin() != updatedMin || previousInfo.getMax() != updatedSize) {
|
previousInfo.getMin() != updatedMin || previousInfo.getMax() != updatedSize) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
logger.debug("updating thread_pool [{}], type [{}], keep_alive [{}]", name, type, updatedKeepAlive);
|
||||||
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive)) {
|
if (!previousInfo.getKeepAlive().equals(updatedKeepAlive)) {
|
||||||
|
@ -415,7 +415,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
if (previousInfo.getMax() != updatedSize) {
|
if (previousInfo.getMax() != updatedSize) {
|
||||||
((EsThreadPoolExecutor) previousExecutorHolder.executor).setMaximumPoolSize(updatedSize);
|
((EsThreadPoolExecutor) previousExecutorHolder.executor).setMaximumPoolSize(updatedSize);
|
||||||
}
|
}
|
||||||
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedMin, updatedSize, updatedKeepAlive, updatedCapacity, updatedWaitTime));
|
return new ExecutorHolder(previousExecutorHolder.executor, new Info(name, type, updatedMin, updatedSize, updatedKeepAlive, updatedQueueSize, updatedWaitTime));
|
||||||
}
|
}
|
||||||
return previousExecutorHolder;
|
return previousExecutorHolder;
|
||||||
}
|
}
|
||||||
|
@ -429,25 +429,25 @@ public class ThreadPool extends AbstractComponent {
|
||||||
if (previousInfo.getMax() >= 0) {
|
if (previousInfo.getMax() >= 0) {
|
||||||
defaultSize = previousInfo.getMax();
|
defaultSize = previousInfo.getMax();
|
||||||
}
|
}
|
||||||
if (previousInfo.getCapacity() != null) {
|
if (previousInfo.getQueueSize() != null) {
|
||||||
defaultCapacity = previousInfo.getCapacity();
|
defaultQueueSize = previousInfo.getQueueSize();
|
||||||
}
|
}
|
||||||
if (previousInfo.waitTime() != null) {
|
if (previousInfo.getWaitTime() != null) {
|
||||||
defaultWaitTime = previousInfo.getKeepAlive();
|
defaultWaitTime = previousInfo.getWaitTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TimeValue keepAlive = settings.getAsTime("keep_alive", defaultKeepAlive);
|
TimeValue keepAlive = settings.getAsTime("keep_alive", defaultKeepAlive);
|
||||||
int min = settings.getAsInt("min", defaultMin);
|
int min = settings.getAsInt("min", defaultMin);
|
||||||
int size = settings.getAsInt("max", settings.getAsInt("size", defaultSize));
|
int size = settings.getAsInt("max", settings.getAsInt("size", defaultSize));
|
||||||
SizeValue capacity = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultCapacity)));
|
SizeValue queueSize = settings.getAsSize("capacity", settings.getAsSize("queue", settings.getAsSize("queue_size", defaultQueueSize)));
|
||||||
TimeValue waitTime = settings.getAsTime("wait_time", defaultWaitTime);
|
TimeValue waitTime = settings.getAsTime("wait_time", defaultWaitTime);
|
||||||
if (previousExecutorHolder != null) {
|
if (previousExecutorHolder != null) {
|
||||||
logger.debug("updating thread_pool [{}], type [{}], min [{}], size [{}], queue_size [{}], keep_alive [{}], wait_time [{}]", name, type, min, size, capacity.singles(), keepAlive, waitTime);
|
logger.debug("updating thread_pool [{}], type [{}], min [{}], size [{}], queue_size [{}], keep_alive [{}], wait_time [{}]", name, type, min, size, queueSize.singles(), keepAlive, waitTime);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("creating thread_pool [{}], type [{}], min [{}], size [{}], queue_size [{}], keep_alive [{}], wait_time [{}]", name, type, min, size, capacity.singles(), keepAlive, waitTime);
|
logger.debug("creating thread_pool [{}], type [{}], min [{}], size [{}], queue_size [{}], keep_alive [{}], wait_time [{}]", name, type, min, size, queueSize.singles(), keepAlive, waitTime);
|
||||||
}
|
}
|
||||||
Executor executor = EsExecutors.newBlockingExecutorService(min, size, keepAlive.millis(), TimeUnit.MILLISECONDS, threadFactory, (int) capacity.singles(), waitTime.millis(), TimeUnit.MILLISECONDS);
|
Executor executor = EsExecutors.newBlockingExecutorService(min, size, keepAlive.millis(), TimeUnit.MILLISECONDS, threadFactory, (int) queueSize.singles(), waitTime.millis(), TimeUnit.MILLISECONDS);
|
||||||
return new ExecutorHolder(executor, new Info(name, type, min, size, keepAlive, capacity, waitTime));
|
return new ExecutorHolder(executor, new Info(name, type, min, size, keepAlive, queueSize, waitTime));
|
||||||
}
|
}
|
||||||
throw new ElasticSearchIllegalArgumentException("No type found [" + type + "], for [" + name + "]");
|
throw new ElasticSearchIllegalArgumentException("No type found [" + type + "], for [" + name + "]");
|
||||||
}
|
}
|
||||||
|
@ -476,14 +476,14 @@ public class ThreadPool extends AbstractComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockingQueue<Runnable> newQueue(SizeValue capacity, String queueType) {
|
private BlockingQueue<Runnable> newQueue(SizeValue queueSize, String queueType) {
|
||||||
if (capacity == null) {
|
if (queueSize == null) {
|
||||||
return ConcurrentCollections.newBlockingQueue();
|
return ConcurrentCollections.newBlockingQueue();
|
||||||
} else if ((int) capacity.singles() > 0) {
|
} else if ((int) queueSize.singles() > 0) {
|
||||||
if ("linked".equals(queueType)) {
|
if ("linked".equals(queueType)) {
|
||||||
return new LinkedBlockingQueue<Runnable>((int) capacity.singles());
|
return new LinkedBlockingQueue<Runnable>((int) queueSize.singles());
|
||||||
} else if ("array".equals(queueType)) {
|
} else if ("array".equals(queueType)) {
|
||||||
return new ArrayBlockingQueue<Runnable>((int) capacity.singles());
|
return new ArrayBlockingQueue<Runnable>((int) queueSize.singles());
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticSearchIllegalArgumentException("illegal queue_type set to [" + queueType + "], should be either linked or array");
|
throw new ElasticSearchIllegalArgumentException("illegal queue_type set to [" + queueType + "], should be either linked or array");
|
||||||
}
|
}
|
||||||
|
@ -635,7 +635,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
private int min;
|
private int min;
|
||||||
private int max;
|
private int max;
|
||||||
private TimeValue keepAlive;
|
private TimeValue keepAlive;
|
||||||
private SizeValue capacity;
|
private SizeValue queueSize;
|
||||||
private TimeValue waitTime;
|
private TimeValue waitTime;
|
||||||
private String rejectSetting;
|
private String rejectSetting;
|
||||||
private String queueType;
|
private String queueType;
|
||||||
|
@ -652,81 +652,50 @@ public class ThreadPool extends AbstractComponent {
|
||||||
this(name, type, size, size, null, null);
|
this(name, type, size, size, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue capacity) {
|
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue queueSize) {
|
||||||
this(name, type, min, max, keepAlive, capacity, null);
|
this(name, type, min, max, keepAlive, queueSize, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue capacity, @Nullable TimeValue waitTime) {
|
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue queueSize, @Nullable TimeValue waitTime) {
|
||||||
this(name, type, min, max, keepAlive, capacity, waitTime, null, null);
|
this(name, type, min, max, keepAlive, queueSize, waitTime, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue capacity, @Nullable TimeValue waitTime, String rejectSetting, String queueType) {
|
public Info(String name, String type, int min, int max, @Nullable TimeValue keepAlive, @Nullable SizeValue queueSize, @Nullable TimeValue waitTime, String rejectSetting, String queueType) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
this.keepAlive = keepAlive;
|
this.keepAlive = keepAlive;
|
||||||
this.capacity = capacity;
|
this.queueSize = queueSize;
|
||||||
this.waitTime = waitTime;
|
this.waitTime = waitTime;
|
||||||
this.rejectSetting = rejectSetting;
|
this.rejectSetting = rejectSetting;
|
||||||
this.queueType = queueType;
|
this.queueType = queueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String type() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int min() {
|
|
||||||
return this.min;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
return this.min;
|
return this.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int max() {
|
|
||||||
return this.max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMax() {
|
public int getMax() {
|
||||||
return this.max;
|
return this.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public TimeValue keepAlive() {
|
|
||||||
return this.keepAlive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TimeValue getKeepAlive() {
|
public TimeValue getKeepAlive() {
|
||||||
return this.keepAlive;
|
return this.keepAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public SizeValue capacity() {
|
public SizeValue getQueueSize() {
|
||||||
return this.capacity;
|
return this.queueSize;
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public SizeValue getCapacity() {
|
|
||||||
return this.capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public TimeValue waitTime() {
|
|
||||||
return this.waitTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -734,21 +703,11 @@ public class ThreadPool extends AbstractComponent {
|
||||||
return this.waitTime;
|
return this.waitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String rejectSetting() {
|
|
||||||
return this.rejectSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getRejectSetting() {
|
public String getRejectSetting() {
|
||||||
return this.rejectSetting;
|
return this.rejectSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public String queueType() {
|
|
||||||
return this.queueType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getQueueType() {
|
public String getQueueType() {
|
||||||
return this.queueType;
|
return this.queueType;
|
||||||
|
@ -765,7 +724,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
keepAlive = TimeValue.readTimeValue(in);
|
keepAlive = TimeValue.readTimeValue(in);
|
||||||
}
|
}
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
capacity = SizeValue.readSizeValue(in);
|
queueSize = SizeValue.readSizeValue(in);
|
||||||
}
|
}
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
waitTime = TimeValue.readTimeValue(in);
|
waitTime = TimeValue.readTimeValue(in);
|
||||||
|
@ -786,11 +745,11 @@ public class ThreadPool extends AbstractComponent {
|
||||||
out.writeBoolean(true);
|
out.writeBoolean(true);
|
||||||
keepAlive.writeTo(out);
|
keepAlive.writeTo(out);
|
||||||
}
|
}
|
||||||
if (capacity == null) {
|
if (queueSize == null) {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
} else {
|
} else {
|
||||||
out.writeBoolean(true);
|
out.writeBoolean(true);
|
||||||
capacity.writeTo(out);
|
queueSize.writeTo(out);
|
||||||
}
|
}
|
||||||
if (waitTime == null) {
|
if (waitTime == null) {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
|
@ -815,8 +774,8 @@ public class ThreadPool extends AbstractComponent {
|
||||||
if (keepAlive != null) {
|
if (keepAlive != null) {
|
||||||
builder.field(Fields.KEEP_ALIVE, keepAlive.toString());
|
builder.field(Fields.KEEP_ALIVE, keepAlive.toString());
|
||||||
}
|
}
|
||||||
if (capacity != null) {
|
if (queueSize != null) {
|
||||||
builder.field(Fields.CAPACITY, capacity.toString());
|
builder.field(Fields.QUEUE_SIZE, queueSize.toString());
|
||||||
}
|
}
|
||||||
if (waitTime != null) {
|
if (waitTime != null) {
|
||||||
builder.field(Fields.WAIT_TIME, waitTime.toString());
|
builder.field(Fields.WAIT_TIME, waitTime.toString());
|
||||||
|
@ -836,7 +795,7 @@ public class ThreadPool extends AbstractComponent {
|
||||||
static final XContentBuilderString MIN = new XContentBuilderString("min");
|
static final XContentBuilderString MIN = new XContentBuilderString("min");
|
||||||
static final XContentBuilderString MAX = new XContentBuilderString("max");
|
static final XContentBuilderString MAX = new XContentBuilderString("max");
|
||||||
static final XContentBuilderString KEEP_ALIVE = new XContentBuilderString("keep_alive");
|
static final XContentBuilderString KEEP_ALIVE = new XContentBuilderString("keep_alive");
|
||||||
static final XContentBuilderString CAPACITY = new XContentBuilderString("capacity");
|
static final XContentBuilderString QUEUE_SIZE = new XContentBuilderString("queue_size");
|
||||||
static final XContentBuilderString WAIT_TIME = new XContentBuilderString("wait_time");
|
static final XContentBuilderString WAIT_TIME = new XContentBuilderString("wait_time");
|
||||||
static final XContentBuilderString REJECT_POLICY = new XContentBuilderString("reject_policy");
|
static final XContentBuilderString REJECT_POLICY = new XContentBuilderString("reject_policy");
|
||||||
static final XContentBuilderString QUEUE_TYPE = new XContentBuilderString("queue_type");
|
static final XContentBuilderString QUEUE_TYPE = new XContentBuilderString("queue_type");
|
||||||
|
|
|
@ -103,10 +103,10 @@ public class SimpleThreadPoolTests extends AbstractNodesTests {
|
||||||
NodeInfo nodeInfo = nodesInfoResponse.getNodes()[i];
|
NodeInfo nodeInfo = nodesInfoResponse.getNodes()[i];
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ThreadPool.Info info : nodeInfo.getThreadPool()) {
|
for (ThreadPool.Info info : nodeInfo.getThreadPool()) {
|
||||||
if (info.name().equals(Names.SEARCH)) {
|
if (info.getName().equals(Names.SEARCH)) {
|
||||||
assertThat(info.type(), equalTo("fixed"));
|
assertThat(info.getType(), equalTo("fixed"));
|
||||||
assertThat(info.rejectSetting(), equalTo("abort"));
|
assertThat(info.getRejectSetting(), equalTo("abort"));
|
||||||
assertThat(info.queueType(), equalTo("linked"));
|
assertThat(info.getQueueType(), equalTo("linked"));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,11 @@ public class SimpleThreadPoolTests extends AbstractNodesTests {
|
||||||
NodeInfo nodeInfo = nodesInfoResponse.getNodes()[i];
|
NodeInfo nodeInfo = nodesInfoResponse.getNodes()[i];
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (ThreadPool.Info info : nodeInfo.getThreadPool()) {
|
for (ThreadPool.Info info : nodeInfo.getThreadPool()) {
|
||||||
if (info.name().equals(Names.SEARCH)) {
|
if (info.getName().equals(Names.SEARCH)) {
|
||||||
assertThat(info.type(), equalTo("blocking"));
|
assertThat(info.getType(), equalTo("blocking"));
|
||||||
assertThat(info.capacity().singles(), equalTo(100L));
|
assertThat(info.getQueueSize().singles(), equalTo(100L));
|
||||||
assertThat(info.waitTime().seconds(), equalTo(10L));
|
assertThat(info.getWaitTime().seconds(), equalTo(10L));
|
||||||
assertThat(info.keepAlive().seconds(), equalTo(15L));
|
assertThat(info.getKeepAlive().seconds(), equalTo(15L));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class SimpleThreadPoolTests extends AbstractNodesTests {
|
||||||
assertThat(found, equalTo(true));
|
assertThat(found, equalTo(true));
|
||||||
|
|
||||||
Map<String, Object> poolMap = getPoolSettingsThroughJson(nodeInfo.getThreadPool(), Names.SEARCH);
|
Map<String, Object> poolMap = getPoolSettingsThroughJson(nodeInfo.getThreadPool(), Names.SEARCH);
|
||||||
assertThat(poolMap.get("capacity").toString(), equalTo("100"));
|
assertThat(poolMap.get("queue_size").toString(), equalTo("100"));
|
||||||
assertThat(poolMap.get("wait_time").toString(), equalTo("10s"));
|
assertThat(poolMap.get("wait_time").toString(), equalTo("10s"));
|
||||||
assertThat(poolMap.get("keep_alive").toString(), equalTo("15s"));
|
assertThat(poolMap.get("keep_alive").toString(), equalTo("15s"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
|
|
||||||
private ThreadPool.Info info(ThreadPool threadPool, String name) {
|
private ThreadPool.Info info(ThreadPool threadPool, String name) {
|
||||||
for (ThreadPool.Info info : threadPool.info()) {
|
for (ThreadPool.Info info : threadPool.info()) {
|
||||||
if (info.name().equals(name)) {
|
if (info.getName().equals(name)) {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,13 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
@Test
|
@Test
|
||||||
public void testCachedExecutorType() {
|
public void testCachedExecutorType() {
|
||||||
ThreadPool threadPool = new ThreadPool(ImmutableSettings.settingsBuilder().put("threadpool.search.type", "cached").build(), null);
|
ThreadPool threadPool = new ThreadPool(ImmutableSettings.settingsBuilder().put("threadpool.search.type", "cached").build(), null);
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("cached"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("cached"));
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(5L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(5L));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
// Replace with different type
|
// Replace with different type
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "same").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "same").build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("same"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("same"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(ListeningExecutorService.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(ListeningExecutorService.class));
|
||||||
|
|
||||||
// Replace with different type again
|
// Replace with different type again
|
||||||
|
@ -63,37 +63,37 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
.put("threadpool.search.type", "scaling")
|
.put("threadpool.search.type", "scaling")
|
||||||
.put("threadpool.search.keep_alive", "10m")
|
.put("threadpool.search.keep_alive", "10m")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("scaling"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("scaling"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(1));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(1));
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
||||||
|
|
||||||
// Put old type back
|
// Put old type back
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "cached").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.type", "cached").build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("cached"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("cached"));
|
||||||
// Make sure keep alive value reused
|
// Make sure keep alive value reused
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
// Change keep alive
|
// Change keep alive
|
||||||
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.keep_alive", "1m").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.keep_alive", "1m").build());
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(1L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(1L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
||||||
// Make sure executor didn't change
|
// Make sure executor didn't change
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("cached"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("cached"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
|
||||||
// Set the same keep alive
|
// Set the same keep alive
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.keep_alive", "1m").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.keep_alive", "1m").build());
|
||||||
// Make sure keep alive value didn't change
|
// Make sure keep alive value didn't change
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(1L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(1L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(1L));
|
||||||
// Make sure executor didn't change
|
// Make sure executor didn't change
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("cached"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("cached"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
|
||||||
threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
|
@ -102,8 +102,8 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
@Test
|
@Test
|
||||||
public void testFixedExecutorType() {
|
public void testFixedExecutorType() {
|
||||||
ThreadPool threadPool = new ThreadPool(settingsBuilder().put("threadpool.search.type", "fixed").build(), null);
|
ThreadPool threadPool = new ThreadPool(settingsBuilder().put("threadpool.search.type", "fixed").build(), null);
|
||||||
assertThat(info(threadPool, Names.SEARCH).rejectSetting(), equalTo("abort"));
|
assertThat(info(threadPool, Names.SEARCH).getRejectSetting(), equalTo("abort"));
|
||||||
assertThat(info(threadPool, Names.SEARCH).queueType(), equalTo("linked"));
|
assertThat(info(threadPool, Names.SEARCH).getQueueType(), equalTo("linked"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
// Replace with different type
|
// Replace with different type
|
||||||
|
@ -113,26 +113,26 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
.put("threadpool.search.min", "2")
|
.put("threadpool.search.min", "2")
|
||||||
.put("threadpool.search.size", "15")
|
.put("threadpool.search.size", "15")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("scaling"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("scaling"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(2));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(2));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(15));
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
||||||
|
|
||||||
// Put old type back
|
// Put old type back
|
||||||
threadPool.updateSettings(settingsBuilder()
|
threadPool.updateSettings(settingsBuilder()
|
||||||
.put("threadpool.search.type", "fixed")
|
.put("threadpool.search.type", "fixed")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("fixed"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("fixed"));
|
||||||
// Make sure keep alive value is not used
|
// Make sure keep alive value is not used
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive(), nullValue());
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive(), nullValue());
|
||||||
// Make sure keep pool size value were reused
|
// Make sure keep pool size value were reused
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(15));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(15));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(15));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
||||||
|
@ -141,19 +141,19 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.size", "10").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.size", "10").build());
|
||||||
// Make sure size values changed
|
// Make sure size values changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(10));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(10));
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(10));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(10));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(10));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(10));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(10));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(10));
|
||||||
// Make sure executor didn't change
|
// Make sure executor didn't change
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("fixed"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("fixed"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
|
||||||
// Change queue capacity
|
// Change queue capacity
|
||||||
threadPool.updateSettings(settingsBuilder()
|
threadPool.updateSettings(settingsBuilder()
|
||||||
.put("threadpool.search.queue", "500")
|
.put("threadpool.search.queue", "500")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).queueType(), equalTo("linked"));
|
assertThat(info(threadPool, Names.SEARCH).getQueueType(), equalTo("linked"));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getQueue(), instanceOf(LinkedBlockingQueue.class));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getQueue(), instanceOf(LinkedBlockingQueue.class));
|
||||||
|
|
||||||
// Set different queue and size type
|
// Set different queue and size type
|
||||||
|
@ -162,19 +162,19 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
.put("threadpool.search.size", "12")
|
.put("threadpool.search.size", "12")
|
||||||
.build());
|
.build());
|
||||||
// Make sure keep size changed
|
// Make sure keep size changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("fixed"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("fixed"));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(12));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(12));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(12));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(12));
|
||||||
assertThat(info(threadPool, Names.SEARCH).queueType(), equalTo("array"));
|
assertThat(info(threadPool, Names.SEARCH).getQueueType(), equalTo("array"));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getQueue(), instanceOf(ArrayBlockingQueue.class));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getQueue(), instanceOf(ArrayBlockingQueue.class));
|
||||||
|
|
||||||
// Change rejection policy
|
// Change rejection policy
|
||||||
oldExecutor = threadPool.executor(Names.SEARCH);
|
oldExecutor = threadPool.executor(Names.SEARCH);
|
||||||
assertThat(info(threadPool, Names.SEARCH).rejectSetting(), equalTo("abort"));
|
assertThat(info(threadPool, Names.SEARCH).getRejectSetting(), equalTo("abort"));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getRejectedExecutionHandler(), instanceOf(EsAbortPolicy.class));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getRejectedExecutionHandler(), instanceOf(EsAbortPolicy.class));
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.reject_policy", "caller").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.reject_policy", "caller").build());
|
||||||
// Make sure rejection handler changed
|
// Make sure rejection handler changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).rejectSetting(), equalTo("caller"));
|
assertThat(info(threadPool, Names.SEARCH).getRejectSetting(), equalTo("caller"));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getRejectedExecutionHandler(), instanceOf(ThreadPoolExecutor.CallerRunsPolicy.class));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getRejectedExecutionHandler(), instanceOf(ThreadPoolExecutor.CallerRunsPolicy.class));
|
||||||
// Make sure executor didn't change
|
// Make sure executor didn't change
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
@ -187,10 +187,10 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
public void testScalingExecutorType() {
|
public void testScalingExecutorType() {
|
||||||
ThreadPool threadPool = new ThreadPool(
|
ThreadPool threadPool = new ThreadPool(
|
||||||
settingsBuilder().put("threadpool.search.type", "scaling").put("threadpool.search.size", 10).build(), null);
|
settingsBuilder().put("threadpool.search.type", "scaling").put("threadpool.search.size", 10).build(), null);
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(1));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(1));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(10));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(10));
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(5L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(5L));
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("scaling"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("scaling"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
// Change settings that doesn't require pool replacement
|
// Change settings that doesn't require pool replacement
|
||||||
|
@ -201,14 +201,14 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
.put("threadpool.search.min", "2")
|
.put("threadpool.search.min", "2")
|
||||||
.put("threadpool.search.size", "15")
|
.put("threadpool.search.size", "15")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("scaling"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("scaling"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(2));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(2));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(15));
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
|
||||||
|
@ -218,10 +218,10 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
@Test
|
@Test
|
||||||
public void testBlockingExecutorType() {
|
public void testBlockingExecutorType() {
|
||||||
ThreadPool threadPool = new ThreadPool(settingsBuilder().put("threadpool.search.type", "blocking").put("threadpool.search.size", "10").build(), null);
|
ThreadPool threadPool = new ThreadPool(settingsBuilder().put("threadpool.search.type", "blocking").put("threadpool.search.size", "10").build(), null);
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(1));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(1));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(10));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(10));
|
||||||
assertThat(info(threadPool, Names.SEARCH).capacity().singles(), equalTo(1000L));
|
assertThat(info(threadPool, Names.SEARCH).getQueueSize().singles(), equalTo(1000L));
|
||||||
assertThat(info(threadPool, Names.SEARCH).waitTime().minutes(), equalTo(1L));
|
assertThat(info(threadPool, Names.SEARCH).getWaitTime().minutes(), equalTo(1L));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
|
|
||||||
// Replace with different type
|
// Replace with different type
|
||||||
|
@ -231,26 +231,26 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
.put("threadpool.search.min", "2")
|
.put("threadpool.search.min", "2")
|
||||||
.put("threadpool.search.size", "15")
|
.put("threadpool.search.size", "15")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("scaling"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("scaling"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(2));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(2));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(15));
|
||||||
// Make sure keep alive value changed
|
// Make sure keep alive value changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getKeepAliveTime(TimeUnit.MINUTES), equalTo(10L));
|
||||||
|
|
||||||
// Put old type back
|
// Put old type back
|
||||||
threadPool.updateSettings(settingsBuilder()
|
threadPool.updateSettings(settingsBuilder()
|
||||||
.put("threadpool.search.type", "blocking")
|
.put("threadpool.search.type", "blocking")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("blocking"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("blocking"));
|
||||||
// Make sure keep alive value is not used
|
// Make sure keep alive value is not used
|
||||||
assertThat(info(threadPool, Names.SEARCH).keepAlive().minutes(), equalTo(10L));
|
assertThat(info(threadPool, Names.SEARCH).getKeepAlive().minutes(), equalTo(10L));
|
||||||
// Make sure keep pool size value were reused
|
// Make sure keep pool size value were reused
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(2));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(2));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(15));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(15));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
assertThat(threadPool.executor(Names.SEARCH), instanceOf(EsThreadPoolExecutor.class));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(2));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(15));
|
||||||
|
@ -259,25 +259,25 @@ public class UpdateThreadPoolSettingsTests {
|
||||||
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
Executor oldExecutor = threadPool.executor(Names.SEARCH);
|
||||||
threadPool.updateSettings(settingsBuilder().put("threadpool.search.size", "10").put("threadpool.search.min", "5").build());
|
threadPool.updateSettings(settingsBuilder().put("threadpool.search.size", "10").put("threadpool.search.min", "5").build());
|
||||||
// Make sure size values changed
|
// Make sure size values changed
|
||||||
assertThat(info(threadPool, Names.SEARCH).min(), equalTo(5));
|
assertThat(info(threadPool, Names.SEARCH).getMin(), equalTo(5));
|
||||||
assertThat(info(threadPool, Names.SEARCH).max(), equalTo(10));
|
assertThat(info(threadPool, Names.SEARCH).getMax(), equalTo(10));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(5));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getCorePoolSize(), equalTo(5));
|
||||||
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(10));
|
assertThat(((EsThreadPoolExecutor) threadPool.executor(Names.SEARCH)).getMaximumPoolSize(), equalTo(10));
|
||||||
// Make sure executor didn't change
|
// Make sure executor didn't change
|
||||||
assertThat(info(threadPool, Names.SEARCH).type(), equalTo("blocking"));
|
assertThat(info(threadPool, Names.SEARCH).getType(), equalTo("blocking"));
|
||||||
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
assertThat(threadPool.executor(Names.SEARCH), sameInstance(oldExecutor));
|
||||||
|
|
||||||
// Change queue capacity
|
// Change queue capacity
|
||||||
threadPool.updateSettings(settingsBuilder()
|
threadPool.updateSettings(settingsBuilder()
|
||||||
.put("threadpool.search.queue_size", "500")
|
.put("threadpool.search.queue_size", "500")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).capacity().singles(), equalTo(500L));
|
assertThat(info(threadPool, Names.SEARCH).getQueueSize().singles(), equalTo(500L));
|
||||||
|
|
||||||
// Change wait time capacity
|
// Change wait time capacity
|
||||||
threadPool.updateSettings(settingsBuilder()
|
threadPool.updateSettings(settingsBuilder()
|
||||||
.put("threadpool.search.wait_time", "2m")
|
.put("threadpool.search.wait_time", "2m")
|
||||||
.build());
|
.build());
|
||||||
assertThat(info(threadPool, Names.SEARCH).waitTime().minutes(), equalTo(2L));
|
assertThat(info(threadPool, Names.SEARCH).getWaitTime().minutes(), equalTo(2L));
|
||||||
|
|
||||||
threadPool.shutdown();
|
threadPool.shutdown();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue