Module org.elasticsearch.server
Package org.elasticsearch.threadpool
Class ScheduledExecutorServiceScheduler
java.lang.Object
org.elasticsearch.threadpool.ScheduledExecutorServiceScheduler
- All Implemented Interfaces:
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
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.threadpool.Scheduler
Scheduler.Cancellable, Scheduler.ReschedulingRunnable, Scheduler.SafeScheduledThreadPoolExecutor, Scheduler.ScheduledCancellable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSchedules a one-shot command to be run after a given delay.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.threadpool.Scheduler
scheduleWithFixedDelay
-
Constructor Details
-
ScheduledExecutorServiceScheduler
-
-
Method Details
-
schedule
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 givenexecutor
or on the scheduler thread. Ifexecutor
isEsExecutors.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 interfaceScheduler
- Parameters:
command
- the command to rundelay
- delay before the task executesunused
- 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.
-