Package org.elasticsearch.persistent
Class AllocatedPersistentTask
- java.lang.Object
-
- org.elasticsearch.tasks.Task
-
- org.elasticsearch.tasks.CancellableTask
-
- org.elasticsearch.persistent.AllocatedPersistentTask
-
public class AllocatedPersistentTask extends CancellableTask
Represents a executor node operation that corresponds to a persistent task
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAllocatedPersistentTask.State-
Nested classes/interfaces inherited from class org.elasticsearch.tasks.Task
Task.Status
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.tasks.Task
X_OPAQUE_ID
-
-
Constructor Summary
Constructors Constructor Description AllocatedPersistentTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, java.util.Map<java.lang.String,java.lang.String> headers)
-
Method Summary
Modifier and Type Method Description booleancancelOnParentLeaving()Returns true if this task should be automatically cancelled if the coordinating node that requested this task left the cluster.longgetAllocationId()java.lang.ExceptiongetFailure()java.lang.StringgetPersistentTaskId()Task.StatusgetStatus()Build a status for this task or null if this task doesn't have status.protected booleanisCompleted()voidmarkAsCompleted()voidmarkAsFailed(java.lang.Exception e)booleanshouldCancelChildrenOnCancellation()Returns true if this task can potentially have children that need to be cancelled when it parent is cancelled.voidupdatePersistentTaskState(PersistentTaskState state, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)Updates the persistent state for the corresponding persistent task.voidwaitForPersistentTask(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.-
Methods inherited from class org.elasticsearch.tasks.CancellableTask
getReasonCancelled, isCancelled, onCancelled
-
Methods inherited from class org.elasticsearch.tasks.Task
getAction, getDescription, getHeader, getId, getParentTaskId, getStartTime, getType, result, result, taskInfo, taskInfo
-
-
-
-
Constructor Detail
-
AllocatedPersistentTask
public AllocatedPersistentTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, java.util.Map<java.lang.String,java.lang.String> headers)
-
-
Method Detail
-
shouldCancelChildrenOnCancellation
public boolean shouldCancelChildrenOnCancellation()
Description copied from class:CancellableTaskReturns true if this task can potentially have children that need to be cancelled when it parent is cancelled.- Specified by:
shouldCancelChildrenOnCancellationin classCancellableTask
-
cancelOnParentLeaving
public final boolean cancelOnParentLeaving()
Description copied from class:CancellableTaskReturns true if this task should be automatically cancelled if the coordinating node that requested this task left the cluster.- Overrides:
cancelOnParentLeavingin classCancellableTask
-
getStatus
public Task.Status getStatus()
Description copied from class:TaskBuild 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
public java.lang.String getPersistentTaskId()
-
getFailure
public java.lang.Exception getFailure()
-
getAllocationId
public long getAllocationId()
-
waitForPersistentTask
public void waitForPersistentTask(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:
predicate- the persistent task predicate to evaluatetimeout- a timeout for waitinglistener- the callback listener
-
isCompleted
protected final boolean isCompleted()
-
markAsCompleted
public void markAsCompleted()
-
markAsFailed
public void markAsFailed(java.lang.Exception e)
-
-