Package org.elasticsearch.persistent
Class PersistentTasksService
- java.lang.Object
-
- org.elasticsearch.persistent.PersistentTasksService
-
public class PersistentTasksService extends java.lang.Object
This service is used by persistent tasks and allocated persistent tasks to communicate changes to the master node so that the master can update the cluster state and can track of the states of the persistent tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PersistentTasksService.WaitForPersistentTaskListener<P extends PersistentTaskParams>
-
Constructor Summary
Constructors Constructor Description PersistentTasksService(ClusterService clusterService, ThreadPool threadPool, Client client)
-
Method Summary
Modifier and Type Method Description void
sendCompletionRequest(java.lang.String taskId, long taskAllocationId, java.lang.Exception taskFailure, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
Notifies the master node about the completion of a persistent task.void
sendRemoveRequest(java.lang.String taskId, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
Notifies the master node to remove a persistent task from the cluster state<Params extends PersistentTaskParams>
voidsendStartRequest(java.lang.String taskId, java.lang.String taskName, Params taskParams, ActionListener<PersistentTasksCustomMetaData.PersistentTask<Params>> listener)
Notifies the master node to create new persistent task and to assign it to a node.void
waitForPersistentTaskCondition(java.lang.String taskId, java.util.function.Predicate<PersistentTasksCustomMetaData.PersistentTask<?>> predicate, TimeValue timeout, PersistentTasksService.WaitForPersistentTaskListener<?> listener)
Waits for a given persistent task to comply with a given predicate, then call back the listener accordingly.void
waitForPersistentTasksCondition(java.util.function.Predicate<PersistentTasksCustomMetaData> predicate, TimeValue timeout, ActionListener<java.lang.Boolean> listener)
Waits for persistent tasks to comply with a given predicate, then call back the listener accordingly.
-
-
-
Constructor Detail
-
PersistentTasksService
public PersistentTasksService(ClusterService clusterService, ThreadPool threadPool, Client client)
-
-
Method Detail
-
sendStartRequest
public <Params extends PersistentTaskParams> void sendStartRequest(java.lang.String taskId, java.lang.String taskName, Params taskParams, ActionListener<PersistentTasksCustomMetaData.PersistentTask<Params>> listener)
Notifies the master node to create new persistent task and to assign it to a node.
-
sendCompletionRequest
public void sendCompletionRequest(java.lang.String taskId, long taskAllocationId, @Nullable java.lang.Exception taskFailure, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
Notifies the master node about the completion of a persistent task.When
failure
isnull
, the persistent task is considered as successfully completed.
-
sendRemoveRequest
public void sendRemoveRequest(java.lang.String taskId, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
Notifies the master node to remove a persistent task from the cluster state
-
waitForPersistentTaskCondition
public void waitForPersistentTaskCondition(java.lang.String taskId, java.util.function.Predicate<PersistentTasksCustomMetaData.PersistentTask<?>> predicate, @Nullable TimeValue timeout, PersistentTasksService.WaitForPersistentTaskListener<?> listener)
Waits for a given persistent task to comply with a given predicate, then call back the listener accordingly.- Parameters:
taskId
- the persistent task idpredicate
- the persistent task predicate to evaluatetimeout
- a timeout for waitinglistener
- the callback listener
-
waitForPersistentTasksCondition
public void waitForPersistentTasksCondition(java.util.function.Predicate<PersistentTasksCustomMetaData> predicate, @Nullable TimeValue timeout, ActionListener<java.lang.Boolean> listener)
Waits for persistent tasks to comply with a given predicate, then call back the listener accordingly.- Parameters:
predicate
- the predicate to evaluatetimeout
- a timeout for waitinglistener
- the callback listener
-
-