Class EsExecutors


public class EsExecutors extends Object
  • Field Details


      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.

      public static final Setting<Integer> 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 is Runtime.availableProcessors() but should be manually controlled if not all processors on the machine are available to Elasticsearch (e.g., because of CPU limits).

      public static final ExecutorService DIRECT_EXECUTOR_SERVICE
      ExecutorService that executes submitted tasks on the current thread. This executor service does not support being shutdown.
  • Method Details

    • allocatedProcessors

      public static int allocatedProcessors(Settings settings)
      Returns the number of allocated processors. Defaults to Runtime.availableProcessors() but can be overridden by passing a Settings instance with the key node.processors set to the desired value.
      settings - a Settings instance from which to derive the allocated processors
      the number of allocated processors
    • newSinglePrioritizing

      public static PrioritizedEsThreadPoolExecutor newSinglePrioritizing(String name, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer, PrioritizedEsThreadPoolExecutor.StarvationWatcher starvationWatcher)
    • newScaling

      public static EsThreadPoolExecutor newScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, boolean rejectAfterShutdown, ThreadFactory threadFactory, ThreadContext contextHolder)
    • newFixed

      public static EsThreadPoolExecutor newFixed(String name, int size, int queueCapacity, ThreadFactory threadFactory, ThreadContext contextHolder)
    • 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.
      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.
      runnable - the runnable to inspect, should be a RunnableFuture
      non fatal exception or null if no exception.
    • threadName

      public static String threadName(Settings settings, String namePrefix)
    • threadName

      public static String threadName(String nodeName, String namePrefix)
    • daemonThreadFactory

      public static ThreadFactory daemonThreadFactory(Settings settings, String namePrefix)
    • daemonThreadFactory

      public static ThreadFactory daemonThreadFactory(String nodeName, String namePrefix)
    • daemonThreadFactory

      public static ThreadFactory daemonThreadFactory(String namePrefix)