Package org.elasticsearch.persistent
Class PersistentTasksExecutor<Params extends PersistentTaskParams>
java.lang.Object
org.elasticsearch.persistent.PersistentTasksExecutor<Params>
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 Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
PersistentTasksExecutor(String taskName, String executor)
-
Method Summary
Modifier and TypeMethodDescriptionprotected AllocatedPersistentTask
createTask(long id, String type, String action, TaskId parentTaskId, PersistentTasksCustomMetadata.PersistentTask<Params> taskInProgress, Map<String,String> headers)
Creates a AllocatedPersistentTask for communicating with task managergetAssignment(Params params, Collection<DiscoveryNode> candidateNodes, ClusterState clusterState)
Returns the node id where the params has to be executed,protected String
getDescription(PersistentTasksCustomMetadata.PersistentTask<Params> taskInProgress)
Returns task description that will be available via task managerprotected abstract void
nodeOperation(AllocatedPersistentTask task, Params params, PersistentTaskState state)
This operation will be executed on the executor node.protected DiscoveryNode
selectLeastLoadedNode(ClusterState clusterState, Collection<DiscoveryNode> candidateNodes, Predicate<DiscoveryNode> selector)
Finds the least loaded node from amongs the candidate node collection that satisfies the selector criteriavoid
validate(Params params, ClusterState clusterState)
Checks the current cluster state for compatibility with the params
-
Field Details
-
NO_NODE_FOUND
-
-
Constructor Details
-
PersistentTasksExecutor
-
-
Method Details
-
getTaskName
-
getAssignment
public PersistentTasksCustomMetadata.Assignment getAssignment(Params params, Collection<DiscoveryNode> candidateNodes, ClusterState clusterState)Returns the node id where the params has to be executed,The default implementation returns the least loaded data node from amongst the collection of candidate nodes
-
selectLeastLoadedNode
protected DiscoveryNode selectLeastLoadedNode(ClusterState clusterState, Collection<DiscoveryNode> candidateNodes, Predicate<DiscoveryNode> selector)Finds the least loaded node from amongs the candidate node collection that satisfies the selector criteria -
validate
Checks the current cluster state for compatibility with the paramsThrows an exception if the supplied params cannot be executed on the cluster in the current state.
-
createTask
protected AllocatedPersistentTask createTask(long id, String type, String action, TaskId parentTaskId, PersistentTasksCustomMetadata.PersistentTask<Params> taskInProgress, Map<String,String> headers)Creates a AllocatedPersistentTask for communicating with task manager -
getDescription
protected 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
-