Class HealthChecksThreadPool

  • All Implemented Interfaces:
    Executor, ExecutorService

    public class HealthChecksThreadPool
    extends ThreadPoolExecutor
    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
    • Constructor Detail

      • HealthChecksThreadPool

        public HealthChecksThreadPool​(com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry)
    • Method Detail

      • beforeExecute

        protected 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 checks
        Overrides:
        beforeExecute in class ThreadPoolExecutor
      • getRejectedExecutions

        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        public static long getRejectedExecutions()