Class PersistentTasksExecutor<Params extends PersistentTaskParams>

java.lang.Object
org.elasticsearch.persistent.PersistentTasksExecutor<Params>

public abstract class PersistentTasksExecutor<Params extends PersistentTaskParams>
extends java.lang.Object
An executor of tasks that can survive restart of requesting or executing node. These tasks are using cluster state rather than only transport service to send requests and responses.
  • Field Details

  • Constructor Details

    • PersistentTasksExecutor

      protected PersistentTasksExecutor​(java.lang.String taskName, java.lang.String executor)
  • Method Details

    • getTaskName

      public java.lang.String getTaskName()
    • getAssignment

      public PersistentTasksCustomMetadata.Assignment getAssignment​(Params params, ClusterState clusterState)
      Returns the node id where the params has to be executed,

      The default implementation returns the least loaded data node

    • selectLeastLoadedNode

      protected DiscoveryNode selectLeastLoadedNode​(ClusterState clusterState, java.util.function.Predicate<DiscoveryNode> selector)
      Finds the least loaded node that satisfies the selector criteria
    • validate

      public void validate​(Params params, ClusterState clusterState)
      Checks the current cluster state for compatibility with the params

      Throws an exception if the supplied params cannot be executed on the cluster in the current state.

    • createTask

      protected AllocatedPersistentTask createTask​(long id, java.lang.String type, java.lang.String action, TaskId parentTaskId, PersistentTasksCustomMetadata.PersistentTask<Params> taskInProgress, java.util.Map<java.lang.String,​java.lang.String> headers)
      Creates a AllocatedPersistentTask for communicating with task manager
    • getDescription

      protected java.lang.String getDescription​(PersistentTasksCustomMetadata.PersistentTask<Params> taskInProgress)
      Returns task description that will be available via task manager
    • nodeOperation

      protected abstract void nodeOperation​(AllocatedPersistentTask task, Params params, @Nullable PersistentTaskState state)
      This operation will be executed on the executor node.

      NOTE: The nodeOperation has to throw an exception, trigger task.markAsCompleted() or task.completeAndNotifyIfNeeded() methods to indicate that the persistent task has finished.

    • getExecutor

      public java.lang.String getExecutor()