Package jenkins.metrics.util
Class HealthChecksThreadPool
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
jenkins.metrics.util.HealthChecksThreadPool
- All Implemented Interfaces:
Executor
,ExecutorService
Thread pool for running health checks. We set the pool size to 4 by default (configurable with system property
jenkins.metrics.util.HealthChecksThreadPool.maxThreadNumber) and we keep threads around for 5 seconds as this is a
bursty pool used once per minute.
The queue size is limited to the current number of health checks dynamically, minus the 4 threads in the pool, plus
one, as the
Metrics.HealthChecker
itself is executed in the pool too. For example for 10 health checks we have the
thread pool (4) + the queue (7) = 11 for the 10 health checks and the HealthChecker.
The RejectedExecutionHandler
is configured to drop oldest items in the queue as new ones come in, to avoid
running more than one health check in each recurrence period.- Since:
- 3.1.2.3
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
Constructor Summary
ConstructorsConstructorDescriptionHealthChecksThreadPool
(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
beforeExecute
(Thread t, Runnable r) Manually handle the queue size so it doesn't grow over our calculated queue capacity based on the number of health checksstatic long
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Details
-
HealthChecksThreadPool
public HealthChecksThreadPool(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry)
-
-
Method Details
-
beforeExecute
Manually handle the queue size so it doesn't grow over our calculated queue capacity based on the number of health checks- Overrides:
beforeExecute
in classThreadPoolExecutor
-
getRejectedExecutions
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static long getRejectedExecutions()
-