Package org.elasticsearch.persistent
Class PersistentTasksClusterService
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractComponent
-
- org.elasticsearch.persistent.PersistentTasksClusterService
-
- All Implemented Interfaces:
ClusterStateListener
public class PersistentTasksClusterService extends AbstractComponent implements ClusterStateListener
Component that runs only on the master node and is responsible for assigning running tasks to nodes
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.common.component.AbstractComponent
deprecationLogger, logger, settings
-
-
Constructor Summary
Constructors Constructor Description PersistentTasksClusterService(Settings settings, PersistentTasksExecutorRegistry registry, ClusterService clusterService)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclusterChanged(ClusterChangedEvent event)Called when cluster state changes.voidcompletePersistentTask(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<Params extends PersistentTaskParams>
voidcreatePersistentTask(java.lang.String taskId, java.lang.String taskName, Params taskParams, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)Creates a new persistent task on master nodestatic booleanneedsReassignment(PersistentTasksCustomMetaData.Assignment assignment, DiscoveryNodes nodes)Returns true if the task is not assigned or is assigned to a non-existing nodevoidremovePersistentTask(java.lang.String id, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)Removes the persistent taskvoidupdatePersistentTaskState(java.lang.String taskId, long taskAllocationId, PersistentTaskState taskState, ActionListener<PersistentTasksCustomMetaData.PersistentTask<?>> listener)Update the state of a persistent task-
Methods inherited from class org.elasticsearch.common.component.AbstractComponent
nodeName
-
-
-
-
Constructor Detail
-
PersistentTasksClusterService
public PersistentTasksClusterService(Settings settings, PersistentTasksExecutorRegistry registry, ClusterService clusterService)
-
-
Method Detail
-
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 idtaskName- the task's nametaskParams- the task's parameterslistener- 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 taskallocationId- the allocation id of the persistent taskfailure- the reason for restarting the task or null if the task completed successfullylistener- 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 tasklistener- 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 tasktaskAllocationId- the expected allocation id of the persistent tasktaskState- new statelistener- the listener that will be called when task is removed
-
clusterChanged
public void clusterChanged(ClusterChangedEvent event)
Description copied from interface:ClusterStateListenerCalled when cluster state changes.- Specified by:
clusterChangedin interfaceClusterStateListener
-
needsReassignment
public static boolean needsReassignment(PersistentTasksCustomMetaData.Assignment assignment, DiscoveryNodes nodes)
Returns true if the task is not assigned or is assigned to a non-existing node
-
-