|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.task.TaskManager
The Waveset Task Manager.
There is ordinarilly one task manager object created by the Server as part of server initialization. The task manager provides the internal API for task operations, some of which is exposed through the Session interface.
The task manager will launch a singleton Scheduler thread object. You could in theory have more than one TaskManager, though there will be only one Scheduler.
Field Summary | |
static java.lang.String |
code_id
|
Constructor Summary | |
TaskManager(LighthouseContext lh)
Build a new TaskManager supplying handles to system resources we need. |
Method Summary | |
static Event |
buildEvent(java.lang.String taskId,
TaskState state,
java.lang.String user)
Static utility method to build a suitable event object. |
static Event |
buildEvent(java.lang.String taskId,
TaskState state,
java.lang.String user,
GenericObject attributes)
|
void |
deleteTask(java.lang.String taskId,
java.lang.String user)
Deletes a task. |
void |
deleteTaskInstance(TaskInstance ti,
java.lang.String repoUser)
|
TaskInstance |
executeTask(java.lang.String id)
Execute a suspended (or ready) task now synchronously. |
RepositoryResult |
getExtendedResult(java.lang.String taskId,
java.util.Map options)
Retrieves all extended results for a task. |
void |
getStatus(java.lang.StringBuffer b)
Return interesting status. |
java.util.List |
getTaskDefinitions()
Get a list of all known task definitions. |
TaskInstance |
getTaskInstance(java.lang.String defName,
java.lang.String nameOrId)
Return the task instance associated with this name. |
QueryResult |
getTaskInstances(TaskState state,
java.lang.String owner,
java.lang.String defName)
Get the set of task instances. |
TaskInstance |
launchTask(TaskTemplate tmp)
Launch a task. |
void |
postEvent(java.lang.String taskId,
TaskState state,
java.lang.String user)
Post a task evnt. |
void |
postEvent(java.lang.String taskId,
TaskState state,
java.lang.String user,
GenericObject attrs)
|
void |
restoreSchedulerCycleTimes()
Restores the scheduler cycle times to their defaults. |
void |
resumeTask(java.lang.String taskId,
java.lang.String user)
Resume a task. |
void |
runScheduler()
Request that the scheduler go through a cycle immediately. |
void |
runScheduler(long waitMillis)
Request that the scheduler go through a cycle immediately and wait for the scheduler to finish processing tasks. |
void |
setSchedulerCycleTime(TaskState state,
int seconds)
Set the scheduler cycle time for a particular task state. |
void |
setTrace(boolean trace)
Turn on the debug trace flag. |
static void |
shutdown()
Shut down the task manager, freeing any resources we have accumualted. |
void |
startScheduler()
Resume the scheduler if it is not already running. |
void |
stopScheduler()
Stop the scheduler thread if it is running. |
void |
suspendTask(java.lang.String taskId,
java.lang.String user)
Suspend a task. |
void |
terminateTask(java.lang.String taskId,
java.lang.String user)
Terminates a task. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
Constructor Detail |
public TaskManager(LighthouseContext lh) throws WavesetException
Server
object, but we don't
want to introduce a dependency on that object here.
Method Detail |
public static void shutdown()
Server
object
when we're in the process of shutting down the entire server.
This needs to block until the scheduler thread is shutdown
because the next thing that happens is the repository is shut
down and that should not happen under the scheduler...
public void startScheduler() throws WavesetException
WavesetException
public void stopScheduler() throws WavesetException
WavesetException
public void runScheduler() throws WavesetException
WavesetException
public void runScheduler(long waitMillis) throws WavesetException
waitMillis
- - wait this long. (If -1, wait indefinitely.)
WavesetException
public void setSchedulerCycleTime(TaskState state, int seconds)
public void restoreSchedulerCycleTimes()
public java.util.List getTaskDefinitions() throws WavesetException
At the moment, this is just a simple repository access, but we
encapsulated it here in case we wanted to support
definitions that were stored under more than one Type
.
I hope we don't evolve that way, if so, we could eliminate this
and just use the generic object interface.
We'll use the cache so we have to return a List rather than a RepositoryResult.
WavesetException
public QueryResult getTaskInstances(TaskState state, java.lang.String owner, java.lang.String defName) throws WavesetException
Like TaskDefinition, we have our own accessor so we can encapsulate the repository types that are used to assemble the list. This wouldn't be necessary if we cound ensure that all TaskInstance subclasses forced themeslves into the Type.TASK_INSTANCE table. Think..
Since we're using the repository not the cache, its more convenient to return QueryResult, thought that's now inconsistent with getTaskDefinitions.
WavesetException
public TaskInstance getTaskInstance(java.lang.String defName, java.lang.String nameOrId) throws WavesetException
defName
- - the definition in case we implement namespacesnameOrId
- - the name of the task
WavesetException
public TaskInstance launchTask(TaskTemplate tmp) throws WavesetException
WavesetException
public TaskInstance executeTask(java.lang.String id) throws WavesetException
WavesetException
public void postEvent(java.lang.String taskId, TaskState state, java.lang.String user) throws WavesetException
WavesetException
public void postEvent(java.lang.String taskId, TaskState state, java.lang.String user, GenericObject attrs) throws WavesetException
WavesetException
public static Event buildEvent(java.lang.String taskId, TaskState state, java.lang.String user) throws WavesetException
WavesetException
public static Event buildEvent(java.lang.String taskId, TaskState state, java.lang.String user, GenericObject attributes) throws WavesetException
WavesetException
public void suspendTask(java.lang.String taskId, java.lang.String user) throws WavesetException
WavesetException
public void resumeTask(java.lang.String taskId, java.lang.String user) throws WavesetException
WavesetException
public void terminateTask(java.lang.String taskId, java.lang.String user) throws WavesetException
WavesetException
public void deleteTask(java.lang.String taskId, java.lang.String user) throws WavesetException
If it is running we first must terminate it? Hmm, could dance around with locks here, it seems sufficient to just delete it out from under the scheduler (after attempting to notify it) and having the scheduler handle that.
WavesetException
public void deleteTaskInstance(TaskInstance ti, java.lang.String repoUser) throws WavesetException
WavesetException
public RepositoryResult getExtendedResult(java.lang.String taskId, java.util.Map options) throws WavesetException
WavesetException
public void setTrace(boolean trace) throws WavesetException
WavesetException
public void getStatus(java.lang.StringBuffer b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |