Class PersistentTasksService

java.lang.Object
org.opensearch.persistent.PersistentTasksService

public class PersistentTasksService extends Object
This service is used by persistent tasks and allocated persistent tasks to communicate changes to the cluster-manager node so that the cluster-manager can update the cluster state and can track of the states of the persistent tasks.
Opensearch.internal:
  • Field Details

  • Constructor Details

  • Method Details

    • sendStartRequest

      public <Params extends PersistentTaskParams> void sendStartRequest(String taskId, String taskName, Params taskParams, org.opensearch.core.action.ActionListener<PersistentTasksCustomMetadata.PersistentTask<Params>> listener)
      Notifies the cluster-manager node to create new persistent task and to assign it to a node.
    • sendCompletionRequest

      public void sendCompletionRequest(String taskId, long taskAllocationId, @Nullable Exception taskFailure, org.opensearch.core.action.ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
      Notifies the cluster-manager node about the completion of a persistent task.

      When failure is null, the persistent task is considered as successfully completed.

    • sendRemoveRequest

      public void sendRemoveRequest(String taskId, org.opensearch.core.action.ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
      Notifies the cluster-manager node to remove a persistent task from the cluster state
    • waitForPersistentTaskCondition

      public void waitForPersistentTaskCondition(String taskId, Predicate<PersistentTasksCustomMetadata.PersistentTask<?>> predicate, @Nullable org.opensearch.common.unit.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 id
      predicate - the persistent task predicate to evaluate
      timeout - a timeout for waiting
      listener - the callback listener
    • waitForPersistentTasksCondition

      public void waitForPersistentTasksCondition(Predicate<PersistentTasksCustomMetadata> predicate, @Nullable org.opensearch.common.unit.TimeValue timeout, org.opensearch.core.action.ActionListener<Boolean> listener)
      Waits for persistent tasks to comply with a given predicate, then call back the listener accordingly.
      Parameters:
      predicate - the predicate to evaluate
      timeout - a timeout for waiting
      listener - the callback listener