- All Known Implementing Classes:
ClusterPersistentTasksCustomMetadata,PersistentTasksCustomMetadata
public interface PersistentTasks
The common data structure for persistent tasks, both cluster-scoped and project-scoped.
It is meant to be used in places where both type of tasks are processed similarly to achieve better code reuse.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classPersistentTasks.Builder<T extends PersistentTasks.Builder<T>>static classstatic classstatic classPrivate builder used in XContent parser to build task-specific portion (params and state) -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final PersistentTasksCustomMetadata.Assignmentstatic final PersistentTasksCustomMetadata.Assignment -
Method Summary
Modifier and TypeMethodDescriptiondefault Iterator<? extends ToXContent> default voiddoWriteTo(StreamOutput out) findTasks(String taskName, Predicate<PersistentTasksCustomMetadata.PersistentTask<?>> predicate) static Stream<Tuple<ProjectId, PersistentTasks>> getAllTasks(ClusterState currentState) longstatic longgetMaxLastAllocationId(ClusterState clusterState) default longgetNumberOfTasksOnNode(String nodeId, String taskName) default PersistentTasksCustomMetadata.PersistentTask<?> static PersistentTasksgetTasks(ClusterState clusterState, ProjectId projectId) Retrieve the persistent tasks for the specified project or the cluster.taskMap()tasks()static StringtaskTypeString(String projectId) static StringtaskTypeString(ProjectId projectId) Convert the PersistentTasks object into the corresponding builder
-
Field Details
-
API_CONTEXT
-
LOST_NODE_ASSIGNMENT
-
INITIAL_ASSIGNMENT
-
-
Method Details
-
getLastAllocationId
long getLastAllocationId()- Returns:
- The last allocation id for the tasks.
-
taskMap
Map<String,PersistentTasksCustomMetadata.PersistentTask<?>> taskMap()- Returns:
- The map of actual tasks keyed by task ID.
-
tasks
- Returns:
- A collection of all tasks
-
getTask
- Parameters:
id- The task ID- Returns:
- The task with the specified task ID
-
findTasks
default Collection<PersistentTasksCustomMetadata.PersistentTask<?>> findTasks(String taskName, Predicate<PersistentTasksCustomMetadata.PersistentTask<?>> predicate) - Parameters:
taskName- The task name, see alsoPersistentTasksExecutor.getTaskName()predicate- The filter for the matching tasks- Returns:
- A collection of tasks matching the specified taskName and predicate
-
getNumberOfTasksOnNode
- Parameters:
nodeId- The node ID where the task runstaskName- The task name, see alsoPersistentTasksExecutor.getTaskName()- Returns:
- The number of tasks of the taskName currently running on the specified nodeId
-
doWriteTo
- Throws:
IOException
-
doToXContentChunked
-
toBuilder
PersistentTasks.Builder<?> toBuilder()Convert the PersistentTasks object into the corresponding builder -
getTasks
Retrieve the persistent tasks for the specified project or the cluster.- Parameters:
clusterState- The cluster stateprojectId- The project for which the persistent tasks should be retrieved.nullfor cluster-scoped tasks.- Returns:
- The persistent tasks associated to the specific project or the cluster if the projectId is null.
-
getAllTasks
-
taskTypeString
-
taskTypeString
-
getMaxLastAllocationId
-