|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jumpi.impl.taskscheduler.TaskSchedulerImpl
A TaskSchedulerImpl implementation using an internal Thread pool to run concurrent Tasks.
Constructor Summary | |
TaskSchedulerImpl()
|
Method Summary | |
void |
configure(java.lang.String name,
Properties props)
Configure the TaskSchedulerImpl. |
java.lang.String |
getName()
Get the fully qualified name of the instance. |
void |
manage(Component root,
Component parent,
java.lang.String operation,
java.util.Hashtable parameters)
Perform a recursive management operation through the Jumpi component tree, using the parameters provided. |
void |
run()
All thread pool threads call run() to take the next available tasks for running, and run them until the task is no longer schedulable. |
void |
schedule(Task task)
Schedule the given Task to run as soon as possible, using one of the threads in the TaskSchedulerImpl's internal thread pool. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TaskSchedulerImpl()
Method Detail |
public void configure(java.lang.String name, Properties props) throws java.lang.Exception
Configure the TaskSchedulerImpl.
The following configuration attributes are defined:
minthreads - optional integer [0..MAX-INT] default 1
The number of threads to run continuously to service tasks regardless of the number of tasks ready to be scheduled.
maxthreads - optional integer [$minthreads..MAX-INT] default 10
The maximum number of threads to run concurrently to service tasks.
maxschedules - optional integer [1..MAX-INT] default 10
The maximum number of tasks which can be expected to be scheduled simultaneously.
keepaliveinterval - optional integer [1000..MAX-INT] default 1000
The time to keep threads running in the absence of schedulable tasks, before allowing the thread to finish.
jointestinterval - optional integer [1000..MAX-INT] default 1000
The time in milliseconds to check if the controller has finished during shutdown.
joinfailinterval - integer[$jointestinterval..MAX-INT] - optional[30000].
The time in milliseconds to before shutdown must complete, regardless if the controller are still running.
configure
in interface Configurable
name
- the fully qualified instance name.props
- the read-only properties to configure the instance with.
java.lang.Exception
- when configuration is unsuccessful.
java.lang.IllegalArgumentException
- if name or props are missing.public void manage(Component root, Component parent, java.lang.String operation, java.util.Hashtable parameters) throws java.lang.Exception
The following management actions are handled:
manage
in interface Manageable
root
- the Jumpi instance at the root of the component tree.parent
- the immediate parent of the component.operation
- the operation.parameters
- the operation parameters.
java.lang.Exception
- if any failure to perform management occurs.
java.lang.IllegalArgumentException
- when parameters are missing.public void schedule(Task task)
Schedule the given Task to run as soon as possible, using one of the threads in the TaskSchedulerImpl's internal thread pool.
A Task is run as long as it is schedulable once a thread has been assigned to handle it. Even if the run method exits or exits through a runtime exception , the assigned thread re-runs the method.
A Task should never call schedule for itself from a synchronized block which shares a synchronization with isSchedulable(). This could cause deadlock.
schedule
in interface TaskScheduler
task
- the Task to schedule.
java.lang.IllegalArgumentException
- if task is null.
java.lang.IllegalStateException
- if scheduler not started.public void run()
All thread pool threads call run() to take the next available tasks for running, and run them until the task is no longer schedulable.
If a Task is long running, then the thread pool thread is taken out of the pool and allowed to run the task until completion. Threads for long running tasks exit after the task is no longer schedulable, and are not reclaimed to the thread pool.
run
in interface java.lang.Runnable
public java.lang.String getName()
getName
in interface Configurable
configure(java.lang.String, org.jumpi.spi.Properties)
|
Jumpi v1.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |