|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dvt.app.threadworks.TaskManager
Runs any asynchronous, runnable tasks.
A TaskManager allows you to dispatch any task(s) to run asynchronously. TaskManager will optionally generate a completion event when the task is completed. TaskManager can also dispatch tasks for you dependent upon the successful completion of other tasks. TaskManager will log any runtime errors encountered. Dispatchable tasks are any class that implements java.lang.Runnable.
TaskManager will optionally terminate a run-away task that runs past a configurable time threshold. TaskManager also generates log information at a configurable interval to assist you with tuning for large, high-volume applications. The default TaskManager configuration will work for most applications.
It is recommended, but not required, that dispatched tasks implement Describable (@see com.dvt.app.common.Describable) as well as Runnable. Describables are capable of producing textual descriptions of themselves. If the task excepts or exceeds its maximum allowed run time, TaskManager will log the probleem. If the task is Describable, TaskManager will log the tasks description as well. This facilitates support.
Typically, TaskManagers are defined as static variables and are shared throughout an application. TaskManager is thread-safe. Examples of TaskManager definitions follow:
private static TaskManager _manager = new TaskManager(5);
DefaultTaskManagerEnvironment env = new DefaultTaskManagerEnvironment(); TaskManager manager = new TaskManager(env);
DefaultTaskManagerEnvironment env = new DefaultTaskManagerEnvironment( new OutputStreamLogger(), 20, Thread.NORM_PRIORITY, 4000, DefaultTaskManagerEnvironment.DEFAULT_DIAGNOSTIC_REPORTING_INTERVAL, DefaultTaskManagerEnvironment.DEFAULT_LOG_LABEL); _manager = new TaskManager(env);
Tasks are dispatched by calling one of the "run" methods. Examples of use follow:
manager.run(logTask); manager.run(customerLookUpTask, lookupCompletionListener);
Copyright: Delta Vortex Technologies, 2001.
Constructor Summary | |
TaskManager(int maxNbrConcurrentTasks)
Starts a TaskManager with a given number of threads. |
|
TaskManager(Logger log,
int maxNbrConcurrentTasks,
int threadPriority,
long maxTaskTimeAllowedInMillis,
long diagnosticReportingIntervalInMillis,
java.lang.String logLabel)
Starts a TaskManager with the given environment information. |
|
TaskManager(java.lang.String propertiesFileName)
Starts a TaskManager using environment defined in a properties file. |
|
TaskManager(TaskManagerEnvironment env)
Starts a TaskManager with the given environment information. |
Method Summary | |
java.lang.String |
getLabel()
Gets labeling information for TaskManager log. |
void |
logDiagnostics()
Logs performance statistics to the logger provided on construction. |
void |
run(java.util.Collection runnableTasks)
Runs a group of asynchronous tasks. |
void |
run(java.util.Collection runnableTasks,
CompletionEventListener listener)
Runs a group of asynchronous tasks. |
void |
run(java.lang.Runnable task)
Runs an asynchronous task. |
void |
run(java.lang.Runnable[] task)
Runs a group of asynchronous tasks. |
void |
run(java.lang.Runnable[] task,
CompletionEventListener listener)
Runs an asynchronous task. |
void |
run(java.lang.Runnable[] dependentTasks,
java.lang.Runnable[] successorTasks,
CompletionEventListener listener)
Runs one or more successor tasks after all dependent tasks are complete. |
void |
run(java.lang.Runnable task,
CompletionEventListener listener)
Runs an asynchronous task. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TaskManager(int maxNbrConcurrentTasks) throws java.io.IOException, ThreadWorksException
Maximum
- Number of Concurrent TasksDefaultTaskManagerEnvironment
public TaskManager(TaskManagerEnvironment env) throws ThreadWorksException
Environment
- public TaskManager(java.lang.String propertiesFileName) throws java.io.IOException, ThreadWorksException
Filename
- public TaskManager(Logger log, int maxNbrConcurrentTasks, int threadPriority, long maxTaskTimeAllowedInMillis, long diagnosticReportingIntervalInMillis, java.lang.String logLabel) throws ThreadWorksException
Message
- loggerMaximum
- Number of Concurrent TasksThread
- PriorityMaximum
- time in millis allowed on a single taskTime
- interval in which to report TaskManager diagnosticsLabel
- used in logging to identify this particular TaskManagerMethod Detail |
public void logDiagnostics()
public void run(java.lang.Runnable task) throws ThreadWorksException
public void run(java.lang.Runnable[] task) throws ThreadWorksException
public void run(java.util.Collection runnableTasks) throws ThreadWorksException
public void run(java.util.Collection runnableTasks, CompletionEventListener listener) throws ThreadWorksException
public void run(java.lang.Runnable task, CompletionEventListener listener) throws ThreadWorksException
public void run(java.lang.Runnable[] task, CompletionEventListener listener) throws ThreadWorksException
public void run(java.lang.Runnable[] dependentTasks, java.lang.Runnable[] successorTasks, CompletionEventListener listener) throws ThreadWorksException
public java.lang.String getLabel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |