public class TaskManager extends AbstractComponent implements ClusterStateListener
deprecationLogger, logger, settings
Constructor and Description |
---|
TaskManager(Settings settings) |
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.String> |
cancel(CancellableTask task,
java.lang.String reason,
java.util.function.Consumer<java.util.Set<java.lang.String>> listener)
Cancels a task
|
void |
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.
|
int |
getBanCount()
Returns the number of currently banned tasks.
|
CancellableTask |
getCancellableTask(long id)
Returns a cancellable task with given id, or null if the task is not found.
|
java.util.Map<java.lang.Long,CancellableTask> |
getCancellableTasks()
Returns the list of currently running tasks on the node that can be cancelled
|
Task |
getTask(long id)
Returns a task with given id, or null if the task is not found.
|
java.util.Map<java.lang.Long,Task> |
getTasks()
Returns the list of currently running tasks on the node
|
<Response extends ActionResponse> |
persistResult(Task task,
Response response,
ActionListener<Response> listener)
Stores the task result
|
<Response extends ActionResponse> |
persistResult(Task task,
java.lang.Throwable error,
ActionListener<Response> listener)
Stores the task failure
|
Task |
register(java.lang.String type,
java.lang.String action,
TransportRequest request)
Registers a task without parent task
|
void |
registerChildTask(Task task,
java.lang.String node) |
void |
removeBan(TaskId parentTaskId)
Removes the ban for the specified parent task.
|
void |
setBan(TaskId parentTaskId,
java.lang.String reason)
Bans all tasks with the specified parent task from execution, cancels all tasks that are currently executing.
|
void |
setTaskResultsService(TaskPersistenceService taskResultsService) |
Task |
unregister(Task task)
Unregister the task
|
void |
waitForTaskCompletion(Task task,
long untilInNanos)
Blocks the calling thread, waiting for the task to vanish from the TaskManager.
|
logDeprecatedSetting, logRemovedSetting, nodeName
public TaskManager(Settings settings)
public void setTaskResultsService(TaskPersistenceService taskResultsService)
public Task register(java.lang.String type, java.lang.String action, TransportRequest request)
Returns the task manager tracked task or null if the task doesn't support the task manager
public java.util.Set<java.lang.String> cancel(CancellableTask task, java.lang.String reason, java.util.function.Consumer<java.util.Set<java.lang.String>> listener)
Returns a set of nodes with child tasks where this task should be cancelled if cancellation was successful, null otherwise.
public <Response extends ActionResponse> void persistResult(Task task, java.lang.Throwable error, ActionListener<Response> listener)
public <Response extends ActionResponse> void persistResult(Task task, Response response, ActionListener<Response> listener)
public java.util.Map<java.lang.Long,Task> getTasks()
public java.util.Map<java.lang.Long,CancellableTask> getCancellableTasks()
public Task getTask(long id)
public CancellableTask getCancellableTask(long id)
public int getBanCount()
Will be used in task manager stats and for debugging.
public void setBan(TaskId parentTaskId, java.lang.String reason)
This method is called when a parent task that has children is cancelled.
public void removeBan(TaskId parentTaskId)
This method is called when a previously banned task finally cancelled
public void clusterChanged(ClusterChangedEvent event)
ClusterStateListener
clusterChanged
in interface ClusterStateListener
public void registerChildTask(Task task, java.lang.String node)
public void waitForTaskCompletion(Task task, long untilInNanos)