|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.actiond.Executor
This class is used as a thread for launching and executing actions as they are discovered by the action daemon. The actions are read from an execution queue and the processes are created by the fiber. Each created process is added to garbage collection list that is periodically polled and culled based upon the status of the process or how long the process is run. If the process has run long than allocated it is terminated during collection.
Nested Class Summary | |
private static class |
Executor.DatedProc
This class is designed to encapsulated a process and its start time. |
private class |
Executor.Reaper
This class encapsules a singular run method that is used to garbage collect expired processes. |
Field Summary | |
private FifoQueue |
m_execQ
The input queue of runnable commands. |
private int |
m_maxProcCount
The maximum number of outstanding processes. |
private long |
m_maxWait
The maximum time that a command can execute. |
private java.lang.String |
m_name
The name of this Fiber |
private java.util.List |
m_processes
The list of outstanding commands. |
private java.lang.Thread |
m_reaper
The process garbage collection thread. |
private java.lang.Runnable |
m_reaperRun
The garbage collection instance. |
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,
long maxRunTime,
int maxProcesses)
Constructs a new action daemon execution environment. |
Method Summary | |
private static java.lang.String[] |
getExecArguments(java.lang.String cmd)
Converts a single command to an array that can be passed to the exec system call. |
java.lang.String |
getName()
Returns the name of this fiber. |
int |
getStatus()
Returns the current status of the pausable fiber. |
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 |
private FifoQueue m_execQ
private java.util.List m_processes
private long m_maxWait
private int m_maxProcCount
private java.lang.Thread m_reaper
private java.lang.Runnable m_reaperRun
private java.lang.Thread m_worker
run
method.
private java.lang.String m_name
private int m_status
Constructor Detail |
Executor(FifoQueue execQ, long maxRunTime, int maxProcesses)
execQ
- The execution queuemaxRunTime
- The maximum runtime of a process.Method Detail |
private static java.lang.String[] getExecArguments(java.lang.String cmd)
Converts a single command to an array that can be passed to the
exec
system call. The
element at index zero of the array is the name of the executable to run.
Indexs [1..length) are the arguments passed to the executable command.
The input command has is white space trimmed before processing. The basic processing is to split on spaces, except when a double quote or single quote is encountered. Also backspaces(\) should also be handled correctly both in and out of the quotes. Shell escapes with $ are not supported.
cmd
- The command to split into an array.
public void run()
STOP_PENDING
then the method will return as quickly as
possible.
run
in interface java.lang.Runnable
public void start()
STARTING
and will transisition to
RUNNING
when the fiber finishes initializing and begins processing the
encapsulaed queue.
start
in interface Fiber
java.lang.IllegalStateException
- Thrown if the fiber is stopped or has never run.public void stop()
stop
in interface Fiber
java.lang.IllegalStateException
- Thrown if the fiber was never started.public void pause()
pause
in interface PausableFiber
java.lang.IllegalStateException
- Thrown if the fiber is stopped or has never run.public void resume()
resume
in interface PausableFiber
java.lang.IllegalStateException
- Thrown if the fiber is stopped or has never run.public java.lang.String getName()
getName
in interface Fiber
public int getStatus()
getStatus
in interface Fiber
PausableFiber
,
Fiber
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |