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

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.opennms.bb.dp.common.components.PollerThread
              |
              +--org.opennms.bb.dp.actiond.components.ActionLauncher
All Implemented Interfaces:
Runnable

public class ActionLauncher
extends PollerThread

ActionLauncher reads events from the ActiondEventsReader object and runs
 any/all auto actions defined within the event.

 ActionLauncher extends the 'PollerThread' to handle the pause/resume/shutdown
 functionality
 

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

Field Summary
private  PCQueue m_actionQ
          The queue to which completed reader objects are added.
private  ActionLaunchManager m_launchMgr
          The action launch manager.
private  long m_timeout
          Time (in milliseconds) to wait for a command to complete.
static int STATUS_BUSY
          This defines the thread specific bits that mask the thread as busy when its status is STATUS_NORMAL.
static int STATUS_IDLE
          This defines the thread specific bits that mark the thread as idle when its status is STATUS_NORMAL.
 
Fields inherited from class org.opennms.bb.dp.common.components.PollerThread
m_curOpStatus, STATUS_MASK, STATUS_NORMAL, STATUS_PAUSED, STATUS_PAUSING, STATUS_RESUMING, STATUS_SHUTDOWN, STATUS_STARTING, STATUS_TERMINATING
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ
 
Constructor Summary
ActionLauncher(ActionLaunchManager launchMgr, PCQueue actionQ, long timeout)
          Constructs the ActionLauncher thread.
 
Method Summary
private  void launchAndWait(String cmd)
           Receives a single command string as an argument, instantiates a and starts an AutoExec thread object to execute it, blocks waiting for the action to complete or timeout, and writes the results to the log.
private  void processEvents(ActiondEventsReader eventsReader)
          For each event contained within the reader object, sequentially execute all auto actions, notifications and trouble ticket actions.
 void run()
          Loop through and wait for status changes - if status is normal, read an ActiondEventsReader object off of the input actionQ and launch any actions associated with the event in the reader.
 
Methods inherited from class org.opennms.bb.dp.common.components.PollerThread
getCtrlStatus, getOpStatus, pauseOperation, pauseThread, resumeOperation, resumeThread, setCtrlStatus, setOpStatus, setUserStatus, shutdown, shutdownThread
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_IDLE

public static final int STATUS_IDLE

This defines the thread specific bits that mark the thread as idle when its status is STATUS_NORMAL.


STATUS_BUSY

public static final int STATUS_BUSY

This defines the thread specific bits that mask the thread as busy when its status is STATUS_NORMAL.


m_launchMgr

private ActionLaunchManager m_launchMgr

The action launch manager.


m_actionQ

private PCQueue m_actionQ

The queue to which completed reader objects are added.


m_timeout

private long m_timeout

Time (in milliseconds) to wait for a command to complete.

Constructor Detail

ActionLauncher

public ActionLauncher(ActionLaunchManager launchMgr,
                      PCQueue actionQ,
                      long timeout)
Constructs the ActionLauncher thread.
Parameters:
launchMgr - the action launch manager
actionQ - the queue from which actions to be launched are read
timeout - the number of milliseconds to wait for a command to complete
Method Detail

launchAndWait

private void launchAndWait(String cmd)

Receives a single command string as an argument, instantiates a and starts an AutoExec thread object to execute it, blocks waiting for the action to complete or timeout, and writes the results to the log. If the process times out it will be forcefully terminated by calling the interrupt() method on the ActionExec thread.

Parameters:
cmd - Command to be executed

processEvents

private void processEvents(ActiondEventsReader eventsReader)

For each event contained within the reader object, sequentially execute all auto actions, notifications and trouble ticket actions.

Parameters:
eventsReader - the reader that has the events w/ actions to be launched

run

public void run()
Loop through and wait for status changes - if status is normal, read an ActiondEventsReader object off of the input actionQ and launch any actions associated with the event in the reader.
Overrides:
run in class Thread