|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.components.thread.DefaultRunnableManager
public class DefaultRunnableManager
The DefaultRunnableManager implements the RunnableManager interface
and is responsible to create ThreadPools and run Runnables
in them as background commands.
The configuration of the DefaultRunnableManager:
<thread-factory>org.apache.cocoon.components.thread.DefaultThreadFactory</thread-factory>
<thread-pools>
<thread-pool>
<name>default</name>
<priority>NORM</priority>
<daemon>false</daemon>
<queue-size>-1</queue-size>
<max-pool-size>-1</max-pool-size>
<min-pool-size>2</min-pool-size>
<keep-alive-time-ms>20000</keep-alive-time-ms>
<block-policy>RUN</block-policy>
<shutdown-graceful>false</shutdown-graceful>
<shutdown-wait-time-ms>-1</shutdown-wait-time-ms>
</thread-pool>
</thread-pools>
Have a look at
http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html,
PooledExecutor or the cocoon.xconf
file for more information.
| Field Summary | |
|---|---|
static boolean |
DEFAULT_DAEMON_MODE
The default daemon mode |
static long |
DEFAULT_KEEP_ALIVE_TIME
The default keep alive time |
static int |
DEFAULT_MAX_POOL_SIZE
The default maximum pool size |
static int |
DEFAULT_MIN_POOL_SIZE
The default minimum pool size |
static int |
DEFAULT_QUEUE_SIZE
The default queue size |
static boolean |
DEFAULT_SHUTDOWN_GRACEFUL
The default way to shutdown gracefully |
static int |
DEFAULT_SHUTDOWN_WAIT_TIME
The default shutdown waittime time |
static String |
DEFAULT_THREAD_FACTORY
The default ThreadFactory |
static String |
DEFAULT_THREAD_PRIORITY
The default thread priority |
static String |
DEFAULT_THREADPOOL_NAME
The default shutdown waittime time |
protected SortedSet |
m_commandStack
Sorted set of ExecutionInfo instances, based on their next
execution time. |
| Fields inherited from interface org.apache.cocoon.components.thread.RunnableManager |
|---|
ROLE |
| Constructor Summary | |
|---|---|
DefaultRunnableManager()
|
|
| Method Summary | |
|---|---|
void |
configure(Configuration config)
|
ThreadPool |
createPool(int queueSize,
int maxPoolSize,
int minPoolSize,
int priority,
boolean isDaemon,
long keepAliveTime,
String blockPolicy,
boolean shutdownGraceful,
int shutdownWaitTime)
Create a private ThreadPool |
void |
createPool(String name,
int queueSize,
int maxPoolSize,
int minPoolSize,
int priority,
boolean isDaemon,
long keepAliveTime,
String blockPolicy,
boolean shutdownGraceful,
int shutdownWaitTime)
Create a shared ThreadPool |
void |
dispose()
|
void |
execute(Runnable command)
Run a Runnable in the background using a ThreadPool |
void |
execute(Runnable command,
long delay)
Run a Runnable in the background using a ThreadPool |
void |
execute(Runnable command,
long delay,
long interval)
Run a Runnable in the background using a ThreadPool |
void |
execute(String threadPoolName,
Runnable command)
Run a Runnable in the background using a ThreadPool |
void |
execute(String threadPoolName,
Runnable command,
long delay)
Run a Runnable in the background using a ThreadPool |
void |
execute(String threadPoolName,
Runnable command,
long delay,
long interval)
Run a Runnable in the background using a ThreadPool |
void |
remove(Runnable command)
Remove a Runnable from the command stack |
void |
run()
The heart of the command manager |
void |
start()
Start the managing thread |
void |
stop()
Stop the managing thread |
| Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
|---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_THREAD_FACTORY
ThreadFactory
public static final int DEFAULT_QUEUE_SIZE
public static final int DEFAULT_MAX_POOL_SIZE
public static final int DEFAULT_MIN_POOL_SIZE
public static final String DEFAULT_THREAD_PRIORITY
public static final boolean DEFAULT_DAEMON_MODE
public static final long DEFAULT_KEEP_ALIVE_TIME
public static final boolean DEFAULT_SHUTDOWN_GRACEFUL
public static final int DEFAULT_SHUTDOWN_WAIT_TIME
public static final String DEFAULT_THREADPOOL_NAME
protected SortedSet m_commandStack
ExecutionInfo instances, based on their next
execution time.
| Constructor Detail |
|---|
public DefaultRunnableManager()
| Method Detail |
|---|
public void configure(Configuration config)
throws ConfigurationException
configure in interface ConfigurableConfigurationExceptionConfigurable.configure(org.apache.avalon.framework.configuration.Configuration)
public void createPool(String name,
int queueSize,
int maxPoolSize,
int minPoolSize,
int priority,
boolean isDaemon,
long keepAliveTime,
String blockPolicy,
boolean shutdownGraceful,
int shutdownWaitTime)
createPool in interface RunnableManagername - The name of the thread poolqueueSize - The size of the queuemaxPoolSize - The maximum number of threadsminPoolSize - The maximum number of threadspriority - The priority of threads created by this pool. This is
one of Thread.MIN_PRIORITY, Thread.NORM_PRIORITY, or Thread.MAX_PRIORITYisDaemon - Whether or not thread from the pool should run in daemon
modekeepAliveTime - How long should a thread be alive for new work to
be done before it is GCedblockPolicy - What's the blocking policy is resources are exhaustedshutdownGraceful - Should we wait for the queue to finish all
pending commands?shutdownWaitTime - After what time a normal shutdown should take
into account if a graceful shutdown has not come to an end
IllegalArgumentException - If the pool already exists
public ThreadPool createPool(int queueSize,
int maxPoolSize,
int minPoolSize,
int priority,
boolean isDaemon,
long keepAliveTime,
String blockPolicy,
boolean shutdownGraceful,
int shutdownWaitTime)
createPool in interface RunnableManagerqueueSize - The size of the queuemaxPoolSize - The maximum number of threadsminPoolSize - The maximum number of threadspriority - The priority of threads created by this pool. This is
one of Thread.MIN_PRIORITY, Thread.NORM_PRIORITY, or Thread.MAX_PRIORITYisDaemon - Whether or not thread from the pool should run in daemon
modekeepAliveTime - How long should a thread be alive for new work to
be done before it is GCedblockPolicy - What's the blocking policy is resources are exhaustedshutdownGraceful - Should we wait for the queue to finish all
pending commands?shutdownWaitTime - After what time a normal shutdown should take
into account if a graceful shutdown has not come to an end
ThreadPoolpublic void dispose()
dispose in interface DisposableDisposable.dispose()
public void execute(String threadPoolName,
Runnable command,
long delay,
long interval)
Runnable in the background using a ThreadPool
execute in interface RunnableManagerthreadPoolName - The thread pool name to be usedcommand - The Runnable to executedelay - the delay befor first runinterval - The interval for repeated runs
IllegalArgumentException - DOCUMENT ME!
public void execute(Runnable command,
long delay,
long interval)
Runnable in the background using a ThreadPool
execute in interface RunnableManagercommand - The Runnable to executedelay - the delay befor first runinterval - The interval for repeated runs
public void execute(Runnable command,
long delay)
Runnable in the background using a ThreadPool
execute in interface RunnableManagercommand - The Runnable to executedelay - the delay befor first runpublic void execute(Runnable command)
Runnable in the background using a ThreadPool
execute in interface RunnableManagercommand - The Runnable to execute
public void execute(String threadPoolName,
Runnable command,
long delay)
Runnable in the background using a ThreadPool
execute in interface RunnableManagerthreadPoolName - The thread pool name to be usedcommand - The Runnable to executedelay - the delay befor first run
public void execute(String threadPoolName,
Runnable command)
Runnable in the background using a ThreadPool
execute in interface RunnableManagerthreadPoolName - The thread pool name to be usedcommand - The Runnable to executepublic void remove(Runnable command)
Runnable from the command stack
remove in interface RunnableManagercommand - The Runnable to be removedpublic void run()
run in interface Runnable
public void start()
throws Exception
start in interface StartableException - DOCUMENT ME!
public void stop()
throws Exception
stop in interface StartableException - DOCUMENT ME!
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||