Package org.elasticsearch.persistent
Class PersistentTasksService
java.lang.Object
org.elasticsearch.persistent.PersistentTasksService
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
Modifier and TypeClassDescriptionstatic interface
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPersistentTasksService
(ClusterService clusterService, ThreadPool threadPool, Client client) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Is the cluster able to support locally aborting persistent tasks? This requires that every node in the cluster is on versionCompletionPersistentTaskAction.LOCAL_ABORT_AVAILABLE_VERSION
or above.static boolean
void
sendCompletionRequest
(String taskId, long taskAllocationId, Exception taskFailure, String localAbortReason, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Notifies the master node about the completion of a persistent task.void
sendRemoveRequest
(String taskId, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Notifies the master node to remove a persistent task from the cluster state<Params extends PersistentTaskParams>
voidsendStartRequest
(String taskId, 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
Throw an exception if the cluster is not able locally abort persistent tasks.void
waitForPersistentTaskCondition
(String taskId, 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
(Predicate<PersistentTasksCustomMetadata> predicate, TimeValue timeout, ActionListener<Boolean> listener) Waits for persistent tasks to comply with a given predicate, then call back the listener accordingly.
-
Field Details
-
PERSISTENT_TASK_ORIGIN
- See Also:
-
-
Constructor Details
-
PersistentTasksService
-
-
Method Details
-
sendStartRequest
public <Params extends PersistentTaskParams> void sendStartRequest(String taskId, 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(String taskId, long taskAllocationId, @Nullable Exception taskFailure, @Nullable String localAbortReason, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Notifies the master node about the completion of a persistent task.At most one of
failure
andlocalAbortReason
may be provided. When bothfailure
andlocalAbortReason
arenull
, the persistent task is considered as successfully completed.localAbortReason
must not be provided unless all nodes in the cluster are on versionCompletionPersistentTaskAction.LOCAL_ABORT_AVAILABLE_VERSION
or higher. -
sendRemoveRequest
public void sendRemoveRequest(String taskId, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Notifies the master node to remove a persistent task from the cluster state -
isLocalAbortSupported
public boolean isLocalAbortSupported()Is the cluster able to support locally aborting persistent tasks? This requires that every node in the cluster is on versionCompletionPersistentTaskAction.LOCAL_ABORT_AVAILABLE_VERSION
or above. -
isLocalAbortSupported
-
validateLocalAbortSupported
public void validateLocalAbortSupported()Throw an exception if the cluster is not able locally abort persistent tasks. -
waitForPersistentTaskCondition
public void waitForPersistentTaskCondition(String taskId, 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(Predicate<PersistentTasksCustomMetadata> predicate, @Nullable TimeValue timeout, ActionListener<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
-