Class TaskExecutionTimeTrackingEsThreadPoolExecutor

All Implemented Interfaces:
Executor, ExecutorService

public final class TaskExecutionTimeTrackingEsThreadPoolExecutor extends EsThreadPoolExecutor
An extension to thread pool executor, which tracks statistics for the task execution time.
  • Method Details

    • wrapRunnable

      protected Runnable wrapRunnable(Runnable command)
      Overrides:
      wrapRunnable in class EsThreadPoolExecutor
    • unwrap

      protected Runnable unwrap(Runnable runnable)
      Overrides:
      unwrap in class EsThreadPoolExecutor
    • getTaskExecutionEWMA

      public double getTaskExecutionEWMA()
      Returns the exponentially weighted moving average of the task execution time
    • getTotalTaskExecutionTime

      public long getTotalTaskExecutionTime()
      Returns the total time (in nanoseconds) spend executing tasks in this executor.
    • getCurrentQueueSize

      public int getCurrentQueueSize()
      Returns the current queue size (operations that are queued)
    • beforeExecute

      protected void beforeExecute(Thread t, Runnable r)
      Overrides:
      beforeExecute in class ThreadPoolExecutor
    • afterExecute

      protected void afterExecute(Runnable r, Throwable t)
      Overrides:
      afterExecute in class EsThreadPoolExecutor
    • appendThreadPoolExecutorDetails

      protected void appendThreadPoolExecutorDetails(StringBuilder sb)
      Description copied from class: EsThreadPoolExecutor
      Append details about this thread pool to the specified StringBuilder. All details should be appended as key/value pairs in the form "%s = %s, "
      Overrides:
      appendThreadPoolExecutorDetails in class EsThreadPoolExecutor
      Parameters:
      sb - the StringBuilder to append to
    • getOngoingTasks

      public Map<Runnable,Long> getOngoingTasks()
      Returns the set of currently running tasks and their start timestamp.

      Note that it is possible for a task that has just finished execution to be temporarily both in the returned map, and its total execution time to be included in the return value of getTotalTaskExecutionTime(). However, it is guaranteed that the task is reflected in at least one of those two values.