org.duraspace.fcrepo.cloudsync.service.backend
Class TaskManager

java.lang.Object
  extended by java.lang.Thread
      extended by 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

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".


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TaskManager(TaskDao taskDao, TaskLogDao taskLogDao, ObjectSetDao objectSetDao, ObjectStoreDao objectStoreDao, HttpClientConfig httpClientConfig)
           
 
Method Summary
 void run()
           
 void shutdown()
           
 Date taskCanceled(Task task)
           
 Date taskFailed(Task task, Throwable cause)
           
 Date taskSucceeded(Task task)
           
 
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskManager

public TaskManager(TaskDao taskDao,
                   TaskLogDao taskLogDao,
                   ObjectSetDao objectSetDao,
                   ObjectStoreDao objectStoreDao,
                   HttpClientConfig httpClientConfig)
Method Detail

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.