use of org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler in project crate by crate.
the class NodeThreadPoolExpression method addChildImplementations.
private void addChildImplementations() {
childImplementations.put(POOL_NAME, new LiteralReferenceImplementation<>(name));
childImplementations.put(ACTIVE, threadPoolExecutor::getActiveCount);
childImplementations.put(REJECTED, () -> {
long rejected = -1;
RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
}
return rejected;
});
childImplementations.put(LARGEST, threadPoolExecutor::getLargestPoolSize);
childImplementations.put(COMPLETED, threadPoolExecutor::getCompletedTaskCount);
childImplementations.put(THREADS, threadPoolExecutor::getPoolSize);
childImplementations.put(QUEUE, () -> threadPoolExecutor.getQueue().size());
}
use of org.elasticsearch.common.util.concurrent.XRejectedExecutionHandler in project elasticsearch by elastic.
the class ThreadPool method stats.
public ThreadPoolStats stats() {
List<ThreadPoolStats.Stats> stats = new ArrayList<>();
for (ExecutorHolder holder : executors.values()) {
String name = holder.info.getName();
// no need to have info on "same" thread pool
if ("same".equals(name)) {
continue;
}
int threads = -1;
int queue = -1;
int active = -1;
long rejected = -1;
int largest = -1;
long completed = -1;
if (holder.executor() instanceof ThreadPoolExecutor) {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor();
threads = threadPoolExecutor.getPoolSize();
queue = threadPoolExecutor.getQueue().size();
active = threadPoolExecutor.getActiveCount();
largest = threadPoolExecutor.getLargestPoolSize();
completed = threadPoolExecutor.getCompletedTaskCount();
RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler();
if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) {
rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected();
}
}
stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest, completed));
}
return new ThreadPoolStats(stats);
}
Aggregations