Package org.opensearch.tasks
Class CancellableTask
java.lang.Object
org.opensearch.tasks.Task
org.opensearch.tasks.CancellableTask
- Direct Known Subclasses:
AllocatedPersistentTask
,BulkByScrollTask
,SearchShardTask
,SearchTask
public abstract class CancellableTask extends Task
A task that can be canceled
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CancellableTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers)
CancellableTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers, org.opensearch.common.unit.TimeValue cancelAfterTimeInterval)
-
Method Summary
Modifier and Type Method Description boolean
cancelOnParentLeaving()
Returns true if this task should be automatically cancelled if the coordinating node that requested this task left the cluster.org.opensearch.common.unit.TimeValue
getCancellationTimeout()
java.lang.String
getReasonCancelled()
The reason the task was cancelled or null if it hasn't been cancelled.boolean
isCancelled()
protected void
onCancelled()
Called after the task is cancelled so that it can take any actions that it has to take.abstract boolean
shouldCancelChildrenOnCancellation()
Returns true if this task can potentially have children that need to be cancelled when it parent is cancelled.Methods inherited from class org.opensearch.tasks.Task
getAction, getDescription, getHeader, getId, getParentTaskId, getStartTime, getStartTimeNanos, getStatus, getType, result, result, taskInfo, taskInfo
-
Constructor Details
-
CancellableTask
public CancellableTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers) -
CancellableTask
public CancellableTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers, org.opensearch.common.unit.TimeValue cancelAfterTimeInterval)
-
-
Method Details
-
cancelOnParentLeaving
public boolean cancelOnParentLeaving()Returns true if this task should be automatically cancelled if the coordinating node that requested this task left the cluster. -
shouldCancelChildrenOnCancellation
public abstract boolean shouldCancelChildrenOnCancellation()Returns true if this task can potentially have children that need to be cancelled when it parent is cancelled. -
isCancelled
public boolean isCancelled() -
getCancellationTimeout
public org.opensearch.common.unit.TimeValue getCancellationTimeout() -
getReasonCancelled
@Nullable public final java.lang.String getReasonCancelled()The reason the task was cancelled or null if it hasn't been cancelled. -
onCancelled
protected void onCancelled()Called after the task is cancelled so that it can take any actions that it has to take.
-