Class QueueResizingOpenSearchThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.opensearch.common.util.concurrent.OpenSearchThreadPoolExecutor
org.opensearch.common.util.concurrent.QueueResizingOpenSearchThreadPoolExecutor
- All Implemented Interfaces:
java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
public final class QueueResizingOpenSearchThreadPoolExecutor extends OpenSearchThreadPoolExecutor
An extension to thread pool executor, which automatically adjusts the queue size of the
ResizableBlockingQueue
according to Little's Law.-
Nested Class Summary
Nested classes/interfaces inherited from class org.opensearch.common.util.concurrent.OpenSearchThreadPoolExecutor
OpenSearchThreadPoolExecutor.ShutdownListener
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
-
Field Summary
Fields Modifier and Type Field Description static double
EWMA_ALPHA
-
Method Summary
Modifier and Type Method Description protected void
afterExecute(java.lang.Runnable r, java.lang.Throwable t)
protected void
appendThreadPoolExecutorDetails(java.lang.StringBuilder sb)
Append details about this thread pool to the specifiedStringBuilder
.int
getCurrentQueueSize()
Returns the current queue size (operations that are queued)double
getTaskExecutionEWMA()
Returns the exponentially weighted moving average of the task execution timeprotected java.lang.Runnable
unwrap(java.lang.Runnable runnable)
protected java.lang.Runnable
wrapRunnable(java.lang.Runnable command)
Methods inherited from class org.opensearch.common.util.concurrent.OpenSearchThreadPoolExecutor
execute, getTasks, terminated, toString
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, 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
-
Field Details
-
EWMA_ALPHA
public static double EWMA_ALPHA
-
-
Method Details
-
wrapRunnable
protected java.lang.Runnable wrapRunnable(java.lang.Runnable command)- Overrides:
wrapRunnable
in classOpenSearchThreadPoolExecutor
-
unwrap
protected java.lang.Runnable unwrap(java.lang.Runnable runnable)- Overrides:
unwrap
in classOpenSearchThreadPoolExecutor
-
getTaskExecutionEWMA
public double getTaskExecutionEWMA()Returns the exponentially weighted moving average of the task execution time -
getCurrentQueueSize
public int getCurrentQueueSize()Returns the current queue size (operations that are queued) -
afterExecute
protected void afterExecute(java.lang.Runnable r, java.lang.Throwable t)- Overrides:
afterExecute
in classOpenSearchThreadPoolExecutor
-
appendThreadPoolExecutorDetails
protected void appendThreadPoolExecutorDetails(java.lang.StringBuilder sb)Description copied from class:OpenSearchThreadPoolExecutor
Append details about this thread pool to the specifiedStringBuilder
. All details should be appended as key/value pairs in the form "%s = %s, "- Overrides:
appendThreadPoolExecutorDetails
in classOpenSearchThreadPoolExecutor
- Parameters:
sb
- theStringBuilder
to append to
-