Class OpenSearchExecutors
java.lang.Object
org.opensearch.common.util.concurrent.OpenSearchExecutors
Executors.
- Opensearch.internal:
-
Field Summary
FieldsModifier and TypeFieldDescriptionSetting to manually control the number of allocated processors.Setting to manually set the number of available processors. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
allocatedProcessors
(Settings settings) Returns the number of allocated processors.static ThreadFactory
daemonThreadFactory
(String namePrefix) static ThreadFactory
daemonThreadFactory
(String nodeName, String namePrefix) static ThreadFactory
daemonThreadFactory
(Settings settings, String namePrefix) static OpenSearchThreadPoolExecutor
newAutoQueueFixed
(String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, org.opensearch.common.unit.TimeValue targetedResponseTime, ThreadFactory threadFactory, ThreadContext contextHolder) static OpenSearchThreadPoolExecutor
newAutoQueueFixed
(String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, org.opensearch.common.unit.TimeValue targetedResponseTime, ThreadFactory threadFactory, ThreadContext contextHolder, AtomicReference<RunnableTaskExecutionListener> runnableTaskListener) Return a new executor that will automatically adjust the queue size based on queue throughput.static ExecutorService
Returns anExecutorService
that executes submitted tasks on the current thread.static OpenSearchThreadPoolExecutor
newFixed
(String name, int size, int queueCapacity, ThreadFactory threadFactory, ThreadContext contextHolder) static OpenSearchThreadPoolExecutor
newScaling
(String name, int min, int max, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, ThreadContext contextHolder) newSinglePrioritizing
(String name, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer) static ThreadFactory
privilegedDaemonThreadFactory
(String namePrefix) static ThreadFactory
privilegedDaemonThreadFactory
(String nodeName, String namePrefix) static ThreadFactory
privilegedDaemonThreadFactory
(Settings settings, String namePrefix) static Throwable
rethrowErrors
(Runnable runnable) Checks if the runnable arose from asynchronous submission of a task to an executor.static String
threadName
(String nodeName, String namePrefix) static String
threadName
(Settings settings, String namePrefix)
-
Field Details
-
PROCESSORS_SETTING
Setting to manually set the number of available processors. This setting is used to adjust thread pool sizes per node. -
NODE_PROCESSORS_SETTING
Setting to manually control the number of allocated processors. This setting is used to adjust thread pool sizes per node. The default value isRuntime.availableProcessors()
but should be manually controlled if not all processors on the machine are available to OpenSearch (e.g., because of CPU limits).
-
-
Method Details
-
allocatedProcessors
Returns the number of allocated processors. Defaults toRuntime.availableProcessors()
but can be overridden by passing aSettings
instance with the keynode.processors
set to the desired value.- Parameters:
settings
- aSettings
instance from which to derive the allocated processors- Returns:
- the number of allocated processors
-
newSinglePrioritizing
public static PrioritizedOpenSearchThreadPoolExecutor newSinglePrioritizing(String name, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer) -
newScaling
public static OpenSearchThreadPoolExecutor newScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, ThreadContext contextHolder) -
newFixed
public static OpenSearchThreadPoolExecutor newFixed(String name, int size, int queueCapacity, ThreadFactory threadFactory, ThreadContext contextHolder) -
newAutoQueueFixed
public static OpenSearchThreadPoolExecutor newAutoQueueFixed(String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, org.opensearch.common.unit.TimeValue targetedResponseTime, ThreadFactory threadFactory, ThreadContext contextHolder) -
newAutoQueueFixed
public static OpenSearchThreadPoolExecutor newAutoQueueFixed(String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, org.opensearch.common.unit.TimeValue targetedResponseTime, ThreadFactory threadFactory, ThreadContext contextHolder, AtomicReference<RunnableTaskExecutionListener> runnableTaskListener) Return a new executor that will automatically adjust the queue size based on queue throughput.- Parameters:
size
- number of fixed threads to use for executing tasksinitialQueueCapacity
- initial size of the executor queueminQueueSize
- minimum queue size that the queue can be adjusted tomaxQueueSize
- maximum queue size that the queue can be adjusted toframeSize
- number of tasks during which stats are collected before adjusting queue sizerunnableTaskListener
- callback listener for a TaskAwareRunnable
-
rethrowErrors
Checks if the runnable arose from asynchronous submission of a task to an executor. If an uncaught exception was thrown during the execution of this task, we need to inspect this runnable and see if it is an error that should be propagated to the uncaught exception handler.- Parameters:
runnable
- the runnable to inspect, should be a RunnableFuture- Returns:
- non fatal exception or null if no exception.
-
newDirectExecutorService
Returns anExecutorService
that executes submitted tasks on the current thread. This executor service does not support being shutdown.- Returns:
- an
ExecutorService
that executes submitted tasks on the current thread
-
threadName
-
threadName
-
daemonThreadFactory
-
daemonThreadFactory
-
daemonThreadFactory
-
privilegedDaemonThreadFactory
-
privilegedDaemonThreadFactory
-
privilegedDaemonThreadFactory
-