Class ExecutorStatusProvider

java.lang.Object
com.github.jpmsilva.jsystemd.ExecutorStatusProvider
All Implemented Interfaces:
StatusProvider

public class ExecutorStatusProvider extends Object implements StatusProvider
Implementation of StatusProvider that provides information regarding a thread pool: the busy threads out of the threads in the pool, and the tasks waiting for a thread, such as workers: 3/10 threads, 5 queued. For a ScheduledThreadPoolExecutor, the tasks waiting are those scheduled to run, including the periodic ones between their runs, such as scheduler: 1/2 threads, 4 scheduled.

The thread pool can be supplied when the status is read, for thread pools that are created after this provider, such as those of Spring's task executors: nothing is reported while the supplier returns null.

Author:
Joao Silva
  • Constructor Details

    • ExecutorStatusProvider

      public ExecutorStatusProvider(String name, ThreadPoolExecutor executor)
      Create a new ExecutorStatusProvider for the given thread pool.
      Parameters:
      name - the name of the thread pool, shown in the status
      executor - the thread pool
    • ExecutorStatusProvider

      public ExecutorStatusProvider(String name, Supplier<? extends @Nullable ThreadPoolExecutor> executor)
      Create a new ExecutorStatusProvider for the thread pool given by the supplier, when the status is read.
      Parameters:
      name - the name of the thread pool, shown in the status
      executor - the supplier of the thread pool, which returns null while there is none
  • Method Details

    • status

      public String status()
      Description copied from interface: StatusProvider
      Exposes status information to send to systemd.
      Specified by:
      status in interface StatusProvider
      Returns:
      the string message to add to the service status