Class EsExecutors


  • public class EsExecutors
    extends Object
    • Field Detail

      • PROCESSORS_SETTING

        public static final Setting<Integer> 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

        public static final Setting<Integer> NODE_PROCESSORS_SETTING
        Setting to manually set the number of available processors. This setting is used to adjust thread pool sizes per node.
    • Method Detail

      • numberOfProcessors

        public static int numberOfProcessors​(Settings settings)
        Returns the number of available processors. Defaults to Runtime.availableProcessors() but can be overridden by passing a Settings instance with the key "processors" set to the desired value.
        Parameters:
        settings - a Settings instance from which to derive the available processors
        Returns:
        the number of available processors
      • newAutoQueueFixed

        public static EsThreadPoolExecutor newAutoQueueFixed​(String name,
                                                             int size,
                                                             int initialQueueCapacity,
                                                             int minQueueSize,
                                                             int maxQueueSize,
                                                             int frameSize,
                                                             TimeValue targetedResponseTime,
                                                             ThreadFactory threadFactory,
                                                             ThreadContext contextHolder)
        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 tasks
        initialQueueCapacity - initial size of the executor queue
        minQueueSize - minimum queue size that the queue can be adjusted to
        maxQueueSize - maximum queue size that the queue can be adjusted to
        frameSize - number of tasks during which stats are collected before adjusting queue size
      • rethrowErrors

        public static Throwable rethrowErrors​(Runnable runnable)
        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

        public static ExecutorService newDirectExecutorService()
        Returns an ExecutorService 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