Class DefaultLongRunningTaskManager
java.lang.Object
com.atlassian.confluence.util.longrunning.DefaultLongRunningTaskManager
- All Implemented Interfaces:
LongRunningTaskManagerInternal,LongRunningTaskManager
@FieldsAreNonnullByDefault
@ParametersAreNonnullByDefault
@ReturnValuesAreNonnullByDefault
public class DefaultLongRunningTaskManager
extends Object
implements LongRunningTaskManagerInternal
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultLongRunningTaskManager(PermissionManager permissionManager, ActivityMonitor activityMonitor, LongRunningTaskMonitor longRunningTaskMonitor) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Map<LongRunningTaskId, com.atlassian.core.task.longrunning.LongRunningTask> getAllTasks(@Nullable ConfluenceUser asUser) Get all currently-tracked tasks that the specified user can see.@Nullable com.atlassian.core.task.longrunning.LongRunningTaskgetLongRunningTask(@Nullable ConfluenceUser user, LongRunningTaskId taskId) gets a long running task with the given Id that was registered either by this user or the anonymous user.intReturn a count of the current queued and running tasks.voidvoidresume()Resume accepting long-running tasks afterLongRunningTaskManager.stop(java.time.Duration)has been called.voidrunToCompletion(@Nullable ConfluenceUser user, com.atlassian.core.task.longrunning.LongRunningTask task) Starts aLongRunningTaskand waits for it to complete.voidstartIfQueued(LongRunningTaskId taskId) Starts the task in a new thread if it has previously been queued.startLongRunningTask(@Nullable ConfluenceUser user, com.atlassian.core.task.longrunning.LongRunningTask task) Start some task in a new threadvoidStop accepting new long running tasks.voidClean up an old task.protected voidtaskFinished(LongRunningTaskId taskId) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.confluence.util.longrunning.LongRunningTaskManager
stop
-
Constructor Details
-
DefaultLongRunningTaskManager
public DefaultLongRunningTaskManager(PermissionManager permissionManager, ActivityMonitor activityMonitor, LongRunningTaskMonitor longRunningTaskMonitor) - Since:
- 5.7
-
-
Method Details
-
onApplicationStopped
-
startIfQueued
Description copied from interface:LongRunningTaskManagerInternalStarts the task in a new thread if it has previously been queued.- Specified by:
startIfQueuedin interfaceLongRunningTaskManagerInternal- Parameters:
taskId- the ID of the task
-
startLongRunningTask
public LongRunningTaskId startLongRunningTask(@Nullable ConfluenceUser user, com.atlassian.core.task.longrunning.LongRunningTask task) Description copied from interface:LongRunningTaskManagerStart some task in a new thread- Specified by:
startLongRunningTaskin interfaceLongRunningTaskManager- Parameters:
user- the user responsible for the tasktask- the task to perform- Returns:
- an ID that can be used to look up the task
-
runToCompletion
public void runToCompletion(@Nullable ConfluenceUser user, com.atlassian.core.task.longrunning.LongRunningTask task) Description copied from interface:LongRunningTaskManagerInternalStarts aLongRunningTaskand waits for it to complete.- Specified by:
runToCompletionin interfaceLongRunningTaskManagerInternal- Parameters:
user- the user responsible for the tasktask- the task to perform
-
getLongRunningTask
public @Nullable com.atlassian.core.task.longrunning.LongRunningTask getLongRunningTask(@Nullable ConfluenceUser user, LongRunningTaskId taskId) gets a long running task with the given Id that was registered either by this user or the anonymous user.- Specified by:
getLongRunningTaskin interfaceLongRunningTaskManager- Parameters:
user- the user responsible for the tasktaskId- the ID of the task- Returns:
- the task, or null if no task is registered with that ID and user
-
getAllTasks
public Map<LongRunningTaskId,com.atlassian.core.task.longrunning.LongRunningTask> getAllTasks(@Nullable ConfluenceUser asUser) Description copied from interface:LongRunningTaskManagerInternalGet all currently-tracked tasks that the specified user can see.- Specified by:
getAllTasksin interfaceLongRunningTaskManagerInternal
-
getTaskCount
public int getTaskCount()Description copied from interface:LongRunningTaskManagerInternalReturn a count of the current queued and running tasks. The count may include tasks that the current user is not allowed to see.- Specified by:
getTaskCountin interfaceLongRunningTaskManagerInternal
-
stopTrackingLongRunningTask
Description copied from interface:LongRunningTaskManagerClean up an old task. The manager hangs on to tasks that have been completed so their status can be queried. Calling this method will remove the task from the manager entirely.This method does not stop a task from being executed. If the task is already running it will continue to completion, you just won't be able to query its status any more.
- Specified by:
stopTrackingLongRunningTaskin interfaceLongRunningTaskManager- Parameters:
taskId- the ID of the task to remove.
-
destroy
@PreDestroy public void destroy() -
stop
Description copied from interface:LongRunningTaskManagerStop accepting new long running tasks. All tasks that have previously been submitted will be run to completion. If this takes longer than the timeout, the method will throw an exception and the task manager will resume normal operation accepting new tasks.- Specified by:
stopin interfaceLongRunningTaskManager- Parameters:
timeout- the time to wait for running tasks to completeunit- the unit of measurement for the timeout parameter- Throws:
TimeoutException- if the timeout is exceeded
-
resume
public void resume()Description copied from interface:LongRunningTaskManagerResume accepting long-running tasks afterLongRunningTaskManager.stop(java.time.Duration)has been called. If the long-running task manager is not stopped, this method will whistle quietly to itself and do nothing.- Specified by:
resumein interfaceLongRunningTaskManager
-
taskFinished
-