|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.task.TaskManagerImpl
public class TaskManagerImpl
An implementation of a TaskManager
. This manager uses an ExecutorService
to run submitted tasks.
Constructor Summary | |
---|---|
TaskManagerImpl(JiraAuthenticationContext authenticationContext)
|
|
TaskManagerImpl(JiraAuthenticationContext authenticationContext,
edu.emory.mathcs.backport.java.util.concurrent.ExecutorService executorService)
|
Method Summary | |
---|---|
TaskDescriptor |
findFirstTask(TaskMatcher matcher)
Find the first task that "matches" according to the passed matcher. |
Collection |
findTasks(TaskMatcher matcher)
Find all the tasks that "match" according to the passed matcher. |
Collection |
getAllTasks()
Return a collection of TaskDescriptor s currently within the manager. |
TaskDescriptor |
getLiveTask(TaskContext taskContext)
Return the live task associated with the passed context, if one exists. |
Collection |
getLiveTasks()
Return a collection of sumitted or running TaskDescriptor s in the manager. |
TaskDescriptor |
getTask(Long taskId)
Returns the TaskDescriptor of the task that is identified by the passed id. |
boolean |
hasLiveTaskWithContext(TaskContext taskContext)
Returns true if the there are live tasks (running or submitted) that have a task context that is EQUAL to the passed in taskContext. |
boolean |
hasTaskWithContext(TaskContext 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. |
boolean |
removeTask(Long taskId)
Remove a task from the manager. |
boolean |
shutdownAndWait(long waitSeconds)
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
void |
shutdownNow()
Attempts to aggressively stop all actively executing tasks, halts the processing of waiting tasks. |
TaskDescriptor |
submitTask(edu.emory.mathcs.backport.java.util.concurrent.Callable callable,
String taskDescription,
TaskContext taskContext)
This submits a Callable task to the manager which can then be started at the managers discretion, but hopefully very soon. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TaskManagerImpl(JiraAuthenticationContext authenticationContext)
public TaskManagerImpl(JiraAuthenticationContext authenticationContext, edu.emory.mathcs.backport.java.util.concurrent.ExecutorService executorService)
Method Detail |
---|
public TaskDescriptor submitTask(edu.emory.mathcs.backport.java.util.concurrent.Callable callable, String taskDescription, TaskContext taskContext) throws edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionException, AlreadyExecutingException
TaskManager
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.
submitTask
in interface TaskManager
callable
- the long running tasktaskDescription
- the description of the tasktaskContext
- some stateful context that the task knows about
edu.emory.mathcs.backport.java.util.concurrent.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.public boolean removeTask(Long taskId)
TaskManager
removeTask
in interface TaskManager
taskId
- the task identifier.
public boolean shutdownAndWait(long waitSeconds)
TaskManager
shutdownAndWait
in interface TaskManager
waitSeconds
- the numder of seconds to wait for graceful shutdown.
public void shutdownNow()
TaskManager
shutdownNow
in interface TaskManager
public TaskDescriptor getLiveTask(TaskContext taskContext)
TaskManager
getLiveTask
in interface TaskManager
taskContext
- the context to search for.
null
will be returned
when no matching task can be found.public TaskDescriptor getTask(Long taskId)
TaskManager
TaskDescriptor
of the task that is identified by the passed id.
getTask
in interface TaskManager
taskId
- the id of the task to retrieve
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.public boolean hasLiveTaskWithContext(TaskContext taskContext)
TaskManager
hasLiveTaskWithContext
in interface TaskManager
taskContext
- the specific task context (which implements equals() propertly)
public boolean hasTaskWithContext(TaskContext taskContext)
TaskManager
hasTaskWithContext
in interface TaskManager
taskContext
- the specific task context (which implements equals() propertly)
public TaskDescriptor findFirstTask(TaskMatcher matcher)
TaskManager
findFirstTask
in interface TaskManager
matcher
- the condition used to find the task.
null
will be returned
when no matching task can be found.public Collection findTasks(TaskMatcher matcher)
TaskManager
findTasks
in interface TaskManager
matcher
- the condition used to find the task.
public Collection getAllTasks()
TaskManager
TaskDescriptor
s currently within the manager. This will include
tasks that are yet to start, tasks that are running and completed tasks.
The returned collection is sorted by task id, which should be in addition order.
getAllTasks
in interface TaskManager
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.public Collection getLiveTasks()
TaskManager
TaskDescriptor
s in the manager.
The returned collection is sorted by task id, which should be in addition order.
getLiveTasks
in interface TaskManager
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |