diff options
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java b/container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java index 9a73c98597a..771c1da82b6 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java +++ b/container-core/src/main/java/com/yahoo/container/handler/threadpool/ExecutorServiceWrapper.java @@ -24,32 +24,35 @@ class ExecutorServiceWrapper extends ForwardingExecutorService { private final ThreadPoolMetric metric; private final ProcessTerminator processTerminator; private final long maxThreadExecutionTimeMillis; + private final int queueCapacity; private final Thread metricReporter; private final AtomicBoolean closed = new AtomicBoolean(false); ExecutorServiceWrapper( WorkerCompletionTimingThreadPoolExecutor wrapped, ThreadPoolMetric metric, ProcessTerminator processTerminator, - long maxThreadExecutionTimeMillis) { + long maxThreadExecutionTimeMillis, String name, int queueCapacity) { this.wrapped = wrapped; this.metric = metric; this.processTerminator = processTerminator; this.maxThreadExecutionTimeMillis = maxThreadExecutionTimeMillis; + this.queueCapacity = queueCapacity; metric.reportThreadPoolSize(wrapped.getPoolSize()); metric.reportActiveThreads(wrapped.getActiveCount()); metricReporter = new Thread(this::reportMetrics); + metricReporter.setName(name + "-threadpool-metric-reporter"); metricReporter.setDaemon(true); metricReporter.start(); } - int queuedTasks() { return wrapped.getQueue().size(); } - - private final void reportMetrics() { + private void reportMetrics() { try { while (!closed.get()) { metric.reportThreadPoolSize(wrapped.getPoolSize()); metric.reportActiveThreads(wrapped.getActiveCount()); + metric.reportWorkQueueSize(wrapped.getQueue().size()); + metric.reportWorkQueueCapacity(queueCapacity); Thread.sleep(100); } } catch (InterruptedException e) { } |