Class ScheduledExecutorServiceScheduler

java.lang.Object
org.elasticsearch.threadpool.ScheduledExecutorServiceScheduler
All Implemented Interfaces:
Scheduler

public final class ScheduledExecutorServiceScheduler extends Object implements Scheduler
A Scheduler which wraps a ScheduledExecutorService. It always runs the delayed command on the scheduler thread, so the provided Executor must always be EsExecutors.DIRECT_EXECUTOR_SERVICE.
  • Constructor Details

  • Method Details

    • schedule

      public Scheduler.ScheduledCancellable schedule(Runnable command, TimeValue delay, Executor unused)
      Description copied from interface: Scheduler
      Schedules a one-shot command to be run after a given delay. The command is run in the context of the calling thread. Implementations may choose to run the command on the given executor or on the scheduler thread. If executor is EsExecutors.DIRECT_EXECUTOR_SERVICE then the command runs on the scheduler thread in all cases. Do not run blocking calls on the scheduler thread.
      Specified by:
      schedule in interface Scheduler
      Parameters:
      command - the command to run
      delay - delay before the task executes
      unused - the executor that has to execute this task.
      Returns:
      a ScheduledFuture whose Future.get() will return when the task has been added to its target thread pool and throws 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 cannot interact with it.