Class PersistentTasksClusterService

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ClusterStateListener

    public class PersistentTasksClusterService
    extends java.lang.Object
    implements ClusterStateListener, java.io.Closeable
    Component that runs only on the master node and is responsible for assigning running tasks to nodes
    • Field Detail

      • CLUSTER_TASKS_ALLOCATION_RECHECK_INTERVAL_SETTING

        public static final Setting<TimeValue> CLUSTER_TASKS_ALLOCATION_RECHECK_INTERVAL_SETTING
    • Method Detail

      • setRecheckInterval

        public void setRecheckInterval​(TimeValue recheckInterval)
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • createPersistentTask

        public <Params extends PersistentTaskParams> void createPersistentTask​(java.lang.String taskId,
                                                                               java.lang.String taskName,
                                                                               Params taskParams,
                                                                               ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
        Creates a new persistent task on master node
        Parameters:
        taskId - the task's id
        taskName - the task's name
        taskParams - the task's parameters
        listener - the listener that will be called when task is started
      • completePersistentTask

        public void completePersistentTask​(java.lang.String id,
                                           long allocationId,
                                           java.lang.Exception failure,
                                           ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
        Restarts a record about a running persistent task from cluster state
        Parameters:
        id - the id of the persistent task
        allocationId - the allocation id of the persistent task
        failure - the reason for restarting the task or null if the task completed successfully
        listener - the listener that will be called when task is removed
      • removePersistentTask

        public void removePersistentTask​(java.lang.String id,
                                         ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
        Removes the persistent task
        Parameters:
        id - the id of a persistent task
        listener - the listener that will be called when task is removed
      • updatePersistentTaskState

        public void updatePersistentTaskState​(java.lang.String taskId,
                                              long taskAllocationId,
                                              PersistentTaskState taskState,
                                              ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
        Update the state of a persistent task
        Parameters:
        taskId - the id of a persistent task
        taskAllocationId - the expected allocation id of the persistent task
        taskState - new state
        listener - the listener that will be called when task is removed
      • unassignPersistentTask

        public void unassignPersistentTask​(java.lang.String taskId,
                                           long taskAllocationId,
                                           java.lang.String reason,
                                           ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)
        This unassigns a task from any node, i.e. it is assigned to a null node with the provided reason. Since the assignment executor node is null, the PersistentTasksClusterService will attempt to reassign it to a valid node quickly.
        Parameters:
        taskId - the id of a persistent task
        taskAllocationId - the expected allocation id of the persistent task
        reason - the reason for unassigning the task from any node
        listener - the listener that will be called when task is unassigned