org.opennms.bb.dp.actiond.components
Class ActionLaunchManager

java.lang.Object
  |
  +--org.opennms.bb.dp.actiond.components.ActionLaunchManager

public class ActionLaunchManager
extends Object

ActionLaunchManager is responsible for launching any auto actions
 associated with the incoming event - it maintains a pool of 'ActionLauncher'
 threads to do this.

Version:
$Revision: 1.2 $
Author:
Mike*, Sowmya Kumaraswamy, Brian Weaver, OpenNMS.org

Field Summary
private static long COMMAND_TIMEOUT
          Length of time (in milliseconds) to wait for a command to finish before forcing it to terminate.
private static int INIT_NUM_LAUNCHERS
          The initial number of launcher threads.
private  PCQueue m_actionQ
          The queue to which the actions that are to be executed are added.
private  List m_launcherThreads
          The pool of launcher threads.
private static int max_launchers
          The max number of threads in the thread pool - this is configurable through the actiond properties.
private static String PROP_COMMAND_TIMEOUT
          The property name that contains the number of milliseconds to wait for an external command to complete before considering it hung.
private static String PROP_MAX_ACTION_LAUNCHER_THREADS
          The property name that contains the maximum number of threads to be used by the ActionLaunchManager.
 
Constructor Summary
ActionLaunchManager(PCQueue actionQ)
          Constructs the ActionLaunchManager - creates the 'ActionLauncher' thread pool and starts the INIT_NUM_LAUNCHERS number of the threads The maximum number of threads in the pool can be configured via the PROP_MAX_ACTION_LAUNCHER_THREADS property - the maximum number defaults to 10 The command timeout is the number of milliseconds that the launcher should wait for a launched command to complete.
 
Method Summary
 void pauseOperation()
          This method goes through and pauses all threads in the thread pool
 void resumeOperation()
          This method goes through and resumes all threads in the thread pool
 void shutdown()
          This method goes through and shuts down all threads in the thread pool
protected  void threadsVsQueueSizeCheck()
          After each read from the actionQ, the threads in the thread pool call this method to adjust the number of threads in the pool if necessary If the number of entries in the queue is more than double the number of threads, the number of threads is increased by one until the configurable maximum number of threads is reached If the number of threads in thepool is more than double the number of entries in the queue, the number of threads is decreased by one until the predefined initial number of threads is reached
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PROP_MAX_ACTION_LAUNCHER_THREADS

private static final String PROP_MAX_ACTION_LAUNCHER_THREADS

The property name that contains the maximum number of threads to be used by the ActionLaunchManager.


INIT_NUM_LAUNCHERS

private static int INIT_NUM_LAUNCHERS

The initial number of launcher threads.


max_launchers

private static int max_launchers

The max number of threads in the thread pool - this is configurable through the actiond properties.


PROP_COMMAND_TIMEOUT

private static final String PROP_COMMAND_TIMEOUT

The property name that contains the number of milliseconds to wait for an external command to complete before considering it hung.


COMMAND_TIMEOUT

private static long COMMAND_TIMEOUT

Length of time (in milliseconds) to wait for a command to finish before forcing it to terminate. This value is configurable through the actiond property PROP_COMMAND_TIMEOUT.


m_actionQ

private PCQueue m_actionQ

The queue to which the actions that are to be executed are added.


m_launcherThreads

private List m_launcherThreads

The pool of launcher threads.

Constructor Detail

ActionLaunchManager

public ActionLaunchManager(PCQueue actionQ)
Constructs the ActionLaunchManager - creates the 'ActionLauncher' thread pool and starts the INIT_NUM_LAUNCHERS number of the threads The maximum number of threads in the pool can be configured via the PROP_MAX_ACTION_LAUNCHER_THREADS property - the maximum number defaults to 10 The command timeout is the number of milliseconds that the launcher should wait for a launched command to complete. If this period is exceeded the command is considered hung and is terminated. This value can be configured via the PROP_COMMAND_TIMEOUT property. This value defaults to 60 seconds.
Parameters:
actionQ - queue from which actions to be executed are read
Method Detail

threadsVsQueueSizeCheck

protected void threadsVsQueueSizeCheck()
After each read from the actionQ, the threads in the thread pool call this method to adjust the number of threads in the pool if necessary If the number of entries in the queue is more than double the number of threads, the number of threads is increased by one until the configurable maximum number of threads is reached If the number of threads in thepool is more than double the number of entries in the queue, the number of threads is decreased by one until the predefined initial number of threads is reached

pauseOperation

public void pauseOperation()
This method goes through and pauses all threads in the thread pool

resumeOperation

public void resumeOperation()
This method goes through and resumes all threads in the thread pool

shutdown

public void shutdown()
This method goes through and shuts down all threads in the thread pool