Class ThreadPool

org.elasticsearch.threadpool.ThreadPool
All Implemented Interfaces:
ReportingService<ThreadPoolInfo>, Scheduler

public class ThreadPool extends implements ReportingService<ThreadPoolInfo>, Scheduler
  • Field Details

    • THREAD_POOL_TYPES

      public static final <,​ThreadPool.ThreadPoolType> THREAD_POOL_TYPES
    • ESTIMATED_TIME_INTERVAL_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> ESTIMATED_TIME_INTERVAL_SETTING
    • LATE_TIME_INTERVAL_WARN_THRESHOLD_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> LATE_TIME_INTERVAL_WARN_THRESHOLD_SETTING
    • SLOW_SCHEDULER_TASK_WARN_THRESHOLD_SETTING

      public static final Setting<org.elasticsearch.core.TimeValue> SLOW_SCHEDULER_TASK_WARN_THRESHOLD_SETTING
  • Constructor Details

  • Method Details

    • builders

      public <ExecutorBuilder> builders()
    • relativeTimeInMillis

      public long relativeTimeInMillis()
      Returns a value of milliseconds that may be used for relative time calculations. This method should only be used for calculating time deltas. For an epoch based timestamp, see absoluteTimeInMillis().
    • relativeTimeInNanos

      public long relativeTimeInNanos()
      Returns a value of nanoseconds that may be used for relative time calculations. This method should only be used for calculating time deltas. For an epoch based timestamp, see absoluteTimeInMillis().
    • absoluteTimeInMillis

      public long absoluteTimeInMillis()
      Returns the value of milliseconds since UNIX epoch. This method should only be used for exact date/time formatting. For calculating time deltas that should not suffer from negative deltas, which are possible with this method, see relativeTimeInMillis().
    • info

      public ThreadPoolInfo info()
      Specified by:
      info in interface ReportingService<ThreadPoolInfo>
    • info

      public  name)
    • stats

      public ThreadPoolStats stats()
    • generic

      public  generic()
      Get the generic . This executor service method will run the it is given in the ThreadContext of the thread that queues it.

      Warning: this will not throw if you submit a task while it shutdown. It will instead silently queue it and not run it.

    • executor

      public  executor( name)
      Get the with the given name. This executor service's method will run the it is given in the ThreadContext of the thread that queues it.

      Warning: this might not throw if you submit a task while it shutdown. It will instead silently queue it and not run it.

      Parameters:
      name - the name of the executor service to obtain
      Throws:
      - if no executor service with the specified name exists
    • schedule

      public  command, org.elasticsearch.core.TimeValue delay,  executor)
      Schedules a one-shot command to run after a given delay. The command is run in the context of the calling thread.
      Specified by:
      schedule in interface Scheduler
      Parameters:
      command - the command to run
      delay - delay before the task executes
      executor - the name of the thread pool on which to execute this task. SAME means "execute on the scheduler thread" which changes the meaning of the ScheduledFuture returned by this method. In that case the ScheduledFuture will complete only when the command completes.
      Returns:
      a ScheduledFuture who's get will return when the task is has been added to its target thread pool and throw an exception if the task is canceled before it was added to its target thread pool. Once the task has been added to its target thread pool the ScheduledFuture will cannot interact with it.
      Throws:
      EsRejectedExecutionException - if the task cannot be scheduled for execution
    • scheduleUnlessShuttingDown

      public void scheduleUnlessShuttingDown(org.elasticsearch.core.TimeValue delay,  executor,  command)
    • scheduleWithFixedDelay

      public  command, org.elasticsearch.core.TimeValue interval,  executor)
      Description copied from interface: Scheduler
      Schedules a periodic action that runs on scheduler thread. Do not run blocking calls on the scheduler thread. Subclasses may allow to execute on a different executor, in which case blocking calls are allowed.
      Specified by:
      scheduleWithFixedDelay in interface Scheduler
      Parameters:
      command - the action to take
      interval - the delay interval
      executor - the name of the executor that has to execute this task. Ignored in the default implementation but can be used by subclasses that support multiple executors.
      Returns:
      a Scheduler.Cancellable that can be used to cancel the subsequent runs of the command. If the command is running, it will not be interrupted.
    • stopCachedTimeThread

      protected final void stopCachedTimeThread()
    • shutdown

      public void shutdown()
    • shutdownNow

      public void shutdownNow()
    • awaitTermination

      public boolean awaitTermination(long timeout,  unit) throws
      Throws:
    • scheduler

      public  scheduler()
    • searchThreadPoolSize

      public static int searchThreadPoolSize(int allocatedProcessors)
    • terminate

      public static boolean terminate( service, long timeout,  timeUnit)
      Returns true if the given service was terminated successfully. If the termination timed out, the service is null this method will return false.
    • terminate

      public static boolean terminate(ThreadPool pool, long timeout,  timeUnit)
      Returns true if the given pool was terminated successfully. If the termination timed out, the service is null this method will return false.
    • getThreadContext

      public ThreadContext getThreadContext()
    • assertNotScheduleThread

      public static boolean assertNotScheduleThread( reason)
    • assertCurrentMethodIsNotCalledRecursively

      public static boolean assertCurrentMethodIsNotCalledRecursively()