OpenNMS API 1.2.3

org.opennms.netmgt.scriptd
Class Executor

java.lang.Object
  extended byorg.opennms.netmgt.scriptd.Executor
All Implemented Interfaces:
Fiber, PausableFiber, java.lang.Runnable

final class Executor
extends java.lang.Object
implements java.lang.Runnable, PausableFiber

This class is used as a thread for launching scripts to handle received events.

Author:
Jim Doble , OpenNMS

Field Summary
private  ScriptdConfigFactory m_config
          The configuration.
private  java.util.Hashtable m_eventScriptMap
          The configured scripts (UEI specified).
private  java.util.ArrayList m_eventScripts
          The configured scripts (no UEI specified).
private  FifoQueue m_execQ
          The input queue of events.
private  com.ibm.bsf.BSFManager m_mgr
          The BSF manager
private  java.lang.String m_name
          The name of this Fiber
private  int m_status
          The status of this fiber.
private  java.lang.Thread m_worker
          The worker thread that executes the run method.
 
Fields inherited from interface org.opennms.core.fiber.PausableFiber
PAUSE_PENDING, PAUSED, RESUME_PENDING
 
Fields inherited from interface org.opennms.core.fiber.Fiber
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
 
Constructor Summary
(package private) Executor(FifoQueue execQ, ScriptdConfigFactory config)
          Constructs a new action daemon execution environment.
 
Method Summary
 java.lang.String getName()
          Returns the name of this fiber.
 int getStatus()
          Returns the current status of the pausable fiber.
private  void loadConfig()
          Load the m_scripts and m_scriptMap data structures from the configuration.
 void pause()
          Pauses a currently running fiber.
 void resume()
          Resumes the fiber if it is paused.
 void run()
          The main worker of the fiber.
 void start()
          Starts the fiber.
 void stop()
          Stops a currently running fiber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_execQ

private FifoQueue m_execQ
The input queue of events.


m_worker

private java.lang.Thread m_worker
The worker thread that executes the run method.


m_name

private java.lang.String m_name
The name of this Fiber


m_status

private int m_status
The status of this fiber.


m_config

private ScriptdConfigFactory m_config
The configuration.


m_eventScripts

private java.util.ArrayList m_eventScripts
The configured scripts (no UEI specified).


m_eventScriptMap

private java.util.Hashtable m_eventScriptMap
The configured scripts (UEI specified).


m_mgr

private com.ibm.bsf.BSFManager m_mgr
The BSF manager

Constructor Detail

Executor

Executor(FifoQueue execQ,
         ScriptdConfigFactory config)
Constructs a new action daemon execution environment. The constructor takes two arguments that define the source of commands to be executed and the maximum time that a command may run.

Parameters:
execQ - The execution queue
config - The Scriptd configuration.
Method Detail

loadConfig

private void loadConfig()
Load the m_scripts and m_scriptMap data structures from the configuration.


run

public void run()
The main worker of the fiber. This method is executed by the encapsulated thread to read events from the execution queue and to execute any configured scripts, allowing these scripts to react to the received event. If the thread is interrupted or the status changes to STOP_PENDING then the method will return as quickly as possible.

Specified by:
run in interface java.lang.Runnable

start

public void start()
Starts the fiber. If the fiber has already been run or is currently running then an exception is generated. The status of the fiber is updated to STARTING and will transition to RUNNING when the fiber finishes initializing and begins processing the encapsulaed queue.

Specified by:
start in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the fiber is stopped or has never run.

stop

public void stop()
Stops a currently running fiber. If the fiber has already been stopped then the command is silently ignored. If the fiber was never started then an exception is generated.

Specified by:
stop in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the fiber was never started.

pause

public void pause()
Pauses a currently running fiber. If the fiber was not in a running or resuming state then the command is silently discarded. If the fiber is not running or has terminated then an exception is generated.

Specified by:
pause in interface PausableFiber
Throws:
java.lang.IllegalStateException - Thrown if the fiber is stopped or has never run.

resume

public void resume()
Resumes the fiber if it is paused. If the fiber was not in a paused or pause pending state then the request is discarded. If the fiber has not been started or has already stopped then an exception is generated.

Specified by:
resume in interface PausableFiber
Throws:
java.lang.IllegalStateException - Thrown if the fiber is stopped or has never run.

getName

public java.lang.String getName()
Returns the name of this fiber.

Specified by:
getName in interface Fiber
Returns:
The name of the fiber.

getStatus

public int getStatus()
Returns the current status of the pausable fiber.

Specified by:
getStatus in interface Fiber
Returns:
The current status of the fiber.
See Also:
PausableFiber, Fiber

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.