com.atlassian.jira.task.TaskManager |
Known Indirect Subclasses |
The TaskManager
contains a collection of tasks that are long running. It schedules them to run
at its discretion, but it does try to run them as soon as possible, assuming there is sufficient resources available.
TaskDescriptor
.
NOTE: All task descriptors returned are a snapshot of the task state when the method returns. So while the task may finish, the TaskDescriptor will
not be updated to reflect that. You must always re-ask the TaskManager for a new TaskDescriptor to find out if a task has finished or not.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Waits on the TaskManager until all current active tasks are completed.
| |||||||||||
Cancel a running task.
| |||||||||||
Cancel a running task if it is running on this cluster node.
| |||||||||||
Find the first task that "matches" according to the passed matcher.
| |||||||||||
Find all the tasks that "match" according to the passed matcher.
| |||||||||||
Return a collection of
TaskDescriptor s currently within the manager. | |||||||||||
Return the live task associated with the passed context, if one exists.
| |||||||||||
Return a collection of sumitted or running
TaskDescriptor s in the manager. | |||||||||||
Returns the
TaskDescriptor of the task that is identified by the passed id. | |||||||||||
Returns true if the there are live tasks (running or submitted) that have a task context
that is EQUAL to the passed in taskContext.
| |||||||||||
Returns true if the there are any tasks (submitted, running or finished) that have a task context
that is EQUAL to the passed in taskContext.
| |||||||||||
Returns true if the task can be cancelled.
| |||||||||||
Return true if this task has been cancelled.
| |||||||||||
Remove a task from the manager.
| |||||||||||
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
| |||||||||||
Attempts to aggressively stop all actively executing tasks, halts the processing of waiting tasks.
| |||||||||||
Start the task manager.
| |||||||||||
This submits a
Callable task to the manager which can then be started at the managers discretion, but hopefully very soon. | |||||||||||
This submits a
Callable task to the manager which can then be started at the managers discretion, but hopefully very soon. | |||||||||||
Wait for a specific task to complete.
|
Waits on the TaskManager until all current active tasks are completed. Calling this method does not stop tasks being added.
seconds | the number of seconds to wait. |
---|
Cancel a running task. If the task is not running this message is a no-op.
taskId | the task identifier. |
---|
IllegalStateException | if the task is not cancellable |
---|
Cancel a running task if it is running on this cluster node.
taskId | the task identifier. |
---|
Find the first task that "matches" according to the passed matcher.
matcher | the condition used to find the task. |
---|
null
will be returned
when no matching task can be found.
Find all the tasks that "match" according to the passed matcher.
matcher | the condition used to find the task. |
---|
Return a collection of TaskDescriptor
s currently within the manager. This will include
tasks that are yet to start, tasks that are running and completed tasks.
TaskDescriptor
s. The descriptors returned are a snapshot
of each task state when the method returns will not reflect any future changes. An empty collection
is returned when there are no current tasks.
Return the live task associated with the passed context, if one exists.
taskContext | the context to search for. |
---|
null
will be returned
when no matching task can be found.
Return a collection of sumitted or running TaskDescriptor
s in the manager.
TaskDescriptor
s. The descriptors returned are a snapshot
of each task state when the method returns and will not reflect any future changes. An empty collection
is returned when there are no descriptors to return.
Returns the TaskDescriptor
of the task that is identified by the passed id.
taskId | the id of the task to retrieve, if null then null will be returned |
---|
TaskDescriptor
or null if the manager has not such task. The descriptor returned is a snapshot
of the task state when the method returns will not reflect any future changes. null
will be returned
when no matching task can be found.
Returns true if the there are live tasks (running or submitted) that have a task context that is EQUAL to the passed in taskContext.
taskContext | the specific task context (which implements equals() propertly) |
---|
Returns true if the there are any tasks (submitted, running or finished) that have a task context that is EQUAL to the passed in taskContext.
taskContext | the specific task context (which implements equals() propertly) |
---|
Returns true if the task can be cancelled. This does not take into account if the task is actually running or not.
taskId | the task identifier. |
---|
Return true if this task has been cancelled.
taskId | the task identifier. |
---|
Remove a task from the manager. The task will still continue to execute if it has not already completed.
taskId | the task identifier. |
---|
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. It will wait for at most waitSeconds and then return true if the underlying execution threads are terminated completely.
waitSeconds | the numder of seconds to wait for graceful shutdown. |
---|
Attempts to aggressively stop all actively executing tasks, halts the processing of waiting tasks.
Start the task manager. Normally the task manager starts on construction, but if it is shutdown, you may need to restart it. If the task manager is not shutdown, does nothing.
This submits a Callable
task to the manager which can then be started at the managers discretion, but hopefully very soon.
The TaskDescriptor
returned is a snapshot of the task's state when the method returns and will not change to reflect
the task's future state changes. The task's ID can be found in the returned TaskDescriptor.
The task is not cancellable.
callable | the long running task |
---|---|
taskDescription | the description of the task |
taskContext | some stateful context that the task knows about |
RejectedExecutionException | if the task manager is being shutdown and cannot accept new tasks. |
---|---|
AlreadyExecutingException | if a task with an equal TaskContext is already running in the task manager. |
This submits a Callable
task to the manager which can then be started at the managers discretion, but hopefully very soon.
The TaskDescriptor
returned is a snapshot of the task's state when the method returns and will not change to reflect
the task's future state changes. The task's ID can be found in the returned TaskDescriptor.
callable | the long running task |
---|---|
taskDescription | the description of the task |
taskContext | some stateful context that the task knows about |
cancellable | If set to true indicates that this potentially long running task supports being cancelled. |
RejectedExecutionException | if the task manager is being shutdown and cannot accept new tasks. |
---|---|
AlreadyExecutingException | if a task with an equal TaskContext is already running in the task manager. |
Wait for a specific task to complete.
taskId | Id of task to wait for |
---|