Class DeterministicTaskQueue
- java.lang.Object
-
- org.elasticsearch.cluster.coordination.DeterministicTaskQueue
-
public class DeterministicTaskQueue extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description DeterministicTaskQueue(Settings settings, java.util.Random random)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceTime()Advance the current time to the time of the next deferred task, and update the sets of deferred and runnable tasks accordingly.longgetCurrentTimeMillis()longgetExecutionDelayVariabilityMillis()java.util.concurrent.ExecutorServicegetExecutorService()java.util.concurrent.ExecutorServicegetExecutorService(java.util.function.Function<java.lang.Runnable,java.lang.Runnable> runnableWrapper)longgetLatestDeferredExecutionTime()ThreadPoolgetThreadPool()ThreadPoolgetThreadPool(java.util.function.Function<java.lang.Runnable,java.lang.Runnable> runnableWrapper)booleanhasDeferredTasks()booleanhasRunnableTasks()voidrunAllRunnableTasks()voidrunAllTasks()voidrunAllTasksInTimeOrder()voidrunRandomTask()Runs an arbitrary runnable task.voidscheduleAt(long executionTimeMillis, java.lang.Runnable task)Schedule a task for future execution.voidscheduleNow(java.lang.Runnable task)Schedule a task for immediate execution.voidsetExecutionDelayVariabilityMillis(long executionDelayVariabilityMillis)
-
-
-
Constructor Detail
-
DeterministicTaskQueue
public DeterministicTaskQueue(Settings settings, java.util.Random random)
-
-
Method Detail
-
getExecutionDelayVariabilityMillis
public long getExecutionDelayVariabilityMillis()
-
setExecutionDelayVariabilityMillis
public void setExecutionDelayVariabilityMillis(long executionDelayVariabilityMillis)
-
runAllRunnableTasks
public void runAllRunnableTasks()
-
runAllTasks
public void runAllTasks()
-
runAllTasksInTimeOrder
public void runAllTasksInTimeOrder()
-
hasRunnableTasks
public boolean hasRunnableTasks()
- Returns:
- whether there are any runnable tasks.
-
hasDeferredTasks
public boolean hasDeferredTasks()
- Returns:
- whether there are any deferred tasks, i.e. tasks that are scheduled for the future.
-
getCurrentTimeMillis
public long getCurrentTimeMillis()
- Returns:
- the current (simulated) time, in milliseconds.
-
runRandomTask
public void runRandomTask()
Runs an arbitrary runnable task.
-
scheduleNow
public void scheduleNow(java.lang.Runnable task)
Schedule a task for immediate execution.
-
scheduleAt
public void scheduleAt(long executionTimeMillis, java.lang.Runnable task)Schedule a task for future execution.
-
advanceTime
public void advanceTime()
Advance the current time to the time of the next deferred task, and update the sets of deferred and runnable tasks accordingly.
-
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
- Returns:
- A
ExecutorServicethat uses this task queue.
-
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService(java.util.function.Function<java.lang.Runnable,java.lang.Runnable> runnableWrapper)
- Returns:
- A
ExecutorServicethat uses this task queue and wrapsRunnables in the given wrapper.
-
getThreadPool
public ThreadPool getThreadPool()
- Returns:
- A
ThreadPoolthat uses this task queue.
-
getThreadPool
public ThreadPool getThreadPool(java.util.function.Function<java.lang.Runnable,java.lang.Runnable> runnableWrapper)
- Returns:
- A
ThreadPoolthat uses this task queue and wrapsRunnables in the given wrapper.
-
getLatestDeferredExecutionTime
public long getLatestDeferredExecutionTime()
-
-