Class PersistentTasksExecutor<Params extends PersistentTaskParams>

  • 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.
    • Constructor Detail

      • PersistentTasksExecutor

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

      • getTaskName

        public java.lang.String getTaskName()
      • 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.

      • nodeOperation

        protected abstract void nodeOperation​(AllocatedPersistentTask task,
                                              Params params,
                                              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()