org.duraspace.fcrepo.cloudsync.service.backend
Class TaskManager
java.lang.Object
java.lang.Thread
org.duraspace.fcrepo.cloudsync.service.backend.TaskManager
- All Implemented Interfaces:
- Runnable, TaskCompletionListener
public class TaskManager
- extends Thread
- implements TaskCompletionListener
This Thread is responsible for managing the execution of tasks.
Signals and State Transitions
- For tasks in the "starting" state, spin up an appropriate
TaskRunner and move to the "running" state in the database.
- For tasks in the "pausing" state, set a flag with the
appropriate TaskRunner, requesting that it pause itself.
Give the task some way to signal that it is actually paused,
during which, among other things, the state in the database is set
to "paused".
- For tasks in the "resuming" state, notify() the appropriate
TaskRunner and move the state to "running" in the database.
- For tasks in the "canceling" state, set a flag with the
appropriate TaskRunner, requesting that it cancel itself.
Give the task some way to signal its completion, during which,
among other things, the state in the database is set to idle.
Note: The requestPause() and requestCancel() methods of a TaskRunner
may be called multiple times in a row. Implementations should ensure these
are not expensive calls to make. In addition, requestCancel() may be
called immediately after requestPause(), before pausing actually occurs.
TaskRunners should be smart enough to assume the request to Pause has
been overridden by the request to cancel.
TaskManager Lifecycle
The requestShutdown() method of this class is expected to be called from
the Servlet Context Listener. The method will loop until all tasks
are in the idle state, then signal to the TaskManager thread to complete.
If any tasks are not in the idle state, they will be set to "canceling".
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
TaskManager
public TaskManager(TaskDao taskDao,
TaskLogDao taskLogDao,
ObjectSetDao objectSetDao,
ObjectStoreDao objectStoreDao,
HttpClientConfig httpClientConfig)
run
public void run()
- Specified by:
run in interface Runnable- Overrides:
run in class Thread
shutdown
public void shutdown()
taskSucceeded
public Date taskSucceeded(Task task)
- Specified by:
taskSucceeded in interface TaskCompletionListener
taskFailed
public Date taskFailed(Task task,
Throwable cause)
- Specified by:
taskFailed in interface TaskCompletionListener
taskCanceled
public Date taskCanceled(Task task)
- Specified by:
taskCanceled in interface TaskCompletionListener
Copyright © 2012 DuraSpace. All Rights Reserved.