java.lang.Object
org.elasticsearch.tasks.Task
org.elasticsearch.tasks.CancellableTask
org.elasticsearch.persistent.AllocatedPersistentTask
- Direct Known Subclasses:
HealthNode
,SystemIndexMigrator
Represents a executor node operation that corresponds to a persistent task
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.elasticsearch.tasks.CancellableTask
CancellableTask.CancellationListener
Nested classes/interfaces inherited from class org.elasticsearch.tasks.Task
Task.Status
-
Field Summary
Fields inherited from class org.elasticsearch.tasks.Task
APM_TRACE_CONTEXT, HEADERS_TO_COPY, TRACE_ID, TRACE_PARENT, TRACE_PARENT_HTTP_HEADER, TRACE_START_TIME, TRACE_STATE, X_ELASTIC_PRODUCT_ORIGIN_HTTP_HEADER, X_OPAQUE_ID_HTTP_HEADER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Build a status for this task or null if this task doesn't have status.protected void
init
(PersistentTasksService persistentTasksService, TaskManager taskManager, String persistentTaskId, long allocationId) protected final boolean
For external purposes, locally aborted and completed are the same.protected boolean
void
void
void
markAsLocallyAborted
(String localAbortReason) Indicates that this persistent task is no longer going to run on the local node.void
updatePersistentTaskState
(PersistentTaskState state, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Updates the persistent state for the corresponding persistent task.void
waitForPersistentTask
(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.Methods inherited from class org.elasticsearch.tasks.CancellableTask
addListener, ensureNotCancelled, getReasonCancelled, isCancelled, notifyIfCancelled, onCancelled, shouldCancelChildrenOnCancellation
Methods inherited from class org.elasticsearch.tasks.Task
getAction, getDescription, getHeader, getId, getParentTaskId, getStartTime, getStartTimeNanos, getType, headers, result, result, taskInfo, taskInfo, toString
-
Constructor Details
-
AllocatedPersistentTask
-
-
Method Details
-
getStatus
Description copied from class:Task
Build a status for this task or null if this task doesn't have status. Since most tasks don't have status this defaults to returning null. While this can never perform IO it might be a costly operation, requiring collating lists of results, etc. So only use it if you need the value. -
updatePersistentTaskState
public void updatePersistentTaskState(PersistentTaskState state, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener) Updates the persistent state for the corresponding persistent task.This doesn't affect the status of this allocated task.
-
getPersistentTaskId
-
init
protected void init(PersistentTasksService persistentTasksService, TaskManager taskManager, String persistentTaskId, long allocationId) -
getFailure
-
getAllocationId
public long getAllocationId() -
waitForPersistentTask
public void waitForPersistentTask(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:
predicate
- the persistent task predicate to evaluatetimeout
- a timeout for waitinglistener
- the callback listener
-
isCompleted
protected final boolean isCompleted()For external purposes, locally aborted and completed are the same.- Returns:
- Is this task completed on the current node?
-
markAsCancelled
protected boolean markAsCancelled() -
markAsCompleted
public void markAsCompleted() -
markAsFailed
-
markAsLocallyAborted
Indicates that this persistent task is no longer going to run on the local node. This will cause the local task to be terminated, and the associated persistent task to be reassigned by the master node. The persistent task may be reassigned to the same node unless separate measures have been taken to prevent this. The task should complete any graceful shutdown actions before calling this method.- Parameters:
localAbortReason
- Reason for the task being aborted on this node. This will be recorded as the reason for unassignment of the persistent task.
-