Class AllocatedPersistentTask

Direct Known Subclasses:

public class AllocatedPersistentTask extends CancellableTask
Represents a executor node operation that corresponds to a persistent task
  • Constructor Details

  • Method Details

    • getStatus

      public Task.Status 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.
      getStatus in class Task
    • 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 String getPersistentTaskId()
    • init

      protected void init(PersistentTasksService persistentTasksService, TaskManager taskManager, String persistentTaskId, long allocationId)
    • getFailure

      public Exception getFailure()
    • getAllocationId

      public long getAllocationId()
    • waitForPersistentTask

      Waits for a given persistent task to comply with a given predicate, then call back the listener accordingly.
      predicate - the persistent task predicate to evaluate
      timeout - a timeout for waiting
      listener - the callback listener
    • isCompleted

      protected final boolean isCompleted()
      For external purposes, locally aborted and completed are the same.
      Is this task completed on the current node?
    • markAsCancelled

      protected boolean markAsCancelled()
    • markAsCompleted

      public void markAsCompleted()
    • markAsFailed

      public void markAsFailed(Exception e)
    • markAsLocallyAborted

      public void markAsLocallyAborted(String localAbortReason)
      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.
      localAbortReason - Reason for the task being aborted on this node. This will be recorded as the reason for unassignment of the persistent task.
      IllegalStateException - This exception will be thrown if the cluster contains nodes that are too old to understand the concept of locally aborting tasks. In this situation callers should revert to whatever the functionality was prior to local abort being possible. It is possible to check if local abort is possible before starting a sequence of steps that will end in a local abort by calling PersistentTasksService.isLocalAbortSupported().