Module org.elasticsearch.server
Class TaskExecutionTimeTrackingEsThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor
org.elasticsearch.common.util.concurrent.TaskExecutionTimeTrackingEsThreadPoolExecutor
- All Implemented Interfaces:
AutoCloseable,Executor,ExecutorService
An extension to thread pool executor, which tracks statistics for the task execution time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumNested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterExecute(Runnable r, Throwable t) protected voidAppend details about this thread pool to the specifiedStringBuilder.protected voidbeforeExecute(Thread t, Runnable r) intReturns the current queue size (operations that are queued)doublelongReturns the max queue latency seen since the last time that this method was called.Returns the set of currently running tasks and their start timestamp.doubleReturns the exponentially weighted moving average of the task execution timelongReturns the total time (in nanoseconds) spend executing tasks in this executor.longReturns the queue latency of the next task to be executed that is still in the task queue.doublepollUtilization(TaskExecutionTimeTrackingEsThreadPoolExecutor.UtilizationTrackingPurpose utilizationTrackingPurpose) Returns the fraction of the maximum possible thread time that was actually used since the last time this method was called.setupMetrics(MeterRegistry meterRegistry, String threadPoolName) booleanprotected Runnableprotected RunnablewrapRunnable(Runnable command) Methods inherited from class org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor
execute, getTasks, remove, setCorePoolSize, setMaximumPoolSize, toStringMethods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, setKeepAliveTime, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminatedMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
close
-
Field Details
-
QUEUE_LATENCY_HISTOGRAM_BUCKETS
public static final int QUEUE_LATENCY_HISTOGRAM_BUCKETS- See Also:
-
-
Method Details
-
setupMetrics
-
wrapRunnable
- Overrides:
wrapRunnablein classEsThreadPoolExecutor
-
unwrap
- Overrides:
unwrapin classEsThreadPoolExecutor
-
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) -
getMaxQueueLatencyMillisSinceLastPollAndReset
public long getMaxQueueLatencyMillisSinceLastPollAndReset()Returns the max queue latency seen since the last time that this method was called. Every call will reset the max seen back to zero. Latencies are only observed as tasks are taken off of the queue. This means that tasks in the queue will not contribute to the max latency until they are unqueued and handed to a thread to execute. To see the latency of tasks still in the queue, usepeekMaxQueueLatencyInQueueMillis(). If there have been no tasks in the queue since the last call, then zero latency is returned. -
peekMaxQueueLatencyInQueueMillis
public long peekMaxQueueLatencyInQueueMillis()Returns the queue latency of the next task to be executed that is still in the task queue. Essentially peeks at the front of the queue and calculates how long it has been there. Returns zero if there is no queue. -
pollUtilization
public double pollUtilization(TaskExecutionTimeTrackingEsThreadPoolExecutor.UtilizationTrackingPurpose utilizationTrackingPurpose) Returns the fraction of the maximum possible thread time that was actually used since the last time this method was called. There are two periodic pulling mechanisms that access utilization reporting:TaskExecutionTimeTrackingEsThreadPoolExecutor.UtilizationTrackingPurposedistinguishes the caller.- Returns:
- the utilization as a fraction, in the range [0, 1]. This may return >1 if a task completed in the time range but started earlier, contributing a larger execution time.
-
beforeExecute
- Overrides:
beforeExecutein classThreadPoolExecutor
-
afterExecute
- Overrides:
afterExecutein classEsThreadPoolExecutor
-
appendThreadPoolExecutorDetails
Description copied from class:EsThreadPoolExecutorAppend details about this thread pool to the specifiedStringBuilder. All details should be appended as key/value pairs in the form "%s = %s, "- Overrides:
appendThreadPoolExecutorDetailsin classEsThreadPoolExecutor- Parameters:
sb- theStringBuilderto append to
-
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. -
getExecutionEwmaAlpha
public double getExecutionEwmaAlpha() -
trackingMaxQueueLatency
public boolean trackingMaxQueueLatency()
-