Package org.elasticsearch.persistent
Class PersistentTasksClusterService
org.elasticsearch.persistent.PersistentTasksClusterService
- All Implemented Interfaces:
,
,
ClusterStateListener
public class PersistentTasksClusterService
extends
implements
Component that runs only on the master node and is responsible for assigning running tasks to nodes
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPersistentTasksClusterService(Settings settings, PersistentTasksExecutorRegistry registry, ClusterService clusterService, ThreadPool threadPool)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.void
id, long allocationId, failure, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
Restarts a record about a running persistent task from cluster state<Params extends PersistentTaskParams>
voidtaskId, taskName, Params taskParams, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
Creates a new persistent task on master nodestatic boolean
needsReassignment(PersistentTasksCustomMetadata.Assignment assignment, DiscoveryNodes nodes)
Returns true if the task is not assigned or is assigned to a non-existing nodevoid
id, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
Removes the persistent taskvoid
setRecheckInterval(org.elasticsearch.core.TimeValue recheckInterval)
void
taskId, long taskAllocationId, reason, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
This unassigns a task from any node, i.e.void
taskId, long taskAllocationId, PersistentTaskState taskState, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)
Update the state of a persistent taskMethods inherited from class java.lang.
, , , , , , , , , ,
-
Field Details
-
CLUSTER_TASKS_ALLOCATION_RECHECK_INTERVAL_SETTING
public static final Setting<org.elasticsearch.core.TimeValue> CLUSTER_TASKS_ALLOCATION_RECHECK_INTERVAL_SETTING
-
-
Constructor Details
-
PersistentTasksClusterService
public PersistentTasksClusterService(Settings settings, PersistentTasksExecutorRegistry registry, ClusterService clusterService, ThreadPool threadPool)
-
-
Method Details
-
setRecheckInterval
public void setRecheckInterval(org.elasticsearch.core.TimeValue recheckInterval) -
close
public void close()- Specified by:
in interface
- Specified by:
in interface
-
createPersistentTask
public <Params extends taskId, 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( id, long allocationId, 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( 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( 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
-
unassignPersistentTask
public void unassignPersistentTask( taskId, long taskAllocationId, reason, ActionListener<PersistentTasksCustomMetadata.PersistentTask<?>> listener)This unassigns a task from any node, i.e. it is assigned to anull
node with the provided reason. Since the assignment executor node is null, thePersistentTasksClusterService
will attempt to reassign it to a valid node quickly.- Parameters:
taskId
- the id of a persistent tasktaskAllocationId
- the expected allocation id of the persistent taskreason
- the reason for unassigning the task from any nodelistener
- the listener that will be called when task is unassigned
-
clusterChanged
Description copied from interface:ClusterStateListener
Called when cluster state changes.- Specified by:
clusterChanged
in 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
-