Package org.opennms.netmgt.notifd
Class DefaultQueueHandler
- java.lang.Object
-
- org.opennms.netmgt.notifd.DefaultQueueHandler
-
- All Implemented Interfaces:
java.lang.Runnable
,Fiber
,PausableFiber
,NotifdQueueHandler
public class DefaultQueueHandler extends java.lang.Object implements NotifdQueueHandler
This class is used as a thread for executing notices for events that are discovered by the notice daemon. The notices are read from an scheduler 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.- Author:
- Jason Johns,
-
-
Field Summary
-
Fields inherited from interface org.opennms.core.fiber.Fiber
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
-
Fields inherited from interface org.opennms.core.fiber.PausableFiber
PAUSE_PENDING, PAUSED, RESUME_PENDING
-
-
Constructor Summary
Constructors Constructor Description DefaultQueueHandler()
Constructor for DefaultQueueHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
processQueue()
processQueuevoid
resume()
Resumes the fiber if it is paused.void
run()
The main worker of the fiber.void
setInterval(java.lang.String interval)
setIntervalvoid
setNoticeQueue(NoticeQueue noticeQueue)
setNoticeQueuevoid
setQueueID(java.lang.String queueID)
setQueueIDvoid
start()
Starts the fiber.void
stop()
Stops a currently running fiber.
-
-
-
-
Method Detail
-
setQueueID
public void setQueueID(java.lang.String queueID)
setQueueID
- Specified by:
setQueueID
in interfaceNotifdQueueHandler
- Parameters:
queueID
- aString
object.
-
setNoticeQueue
public void setNoticeQueue(NoticeQueue noticeQueue)
setNoticeQueue
- Specified by:
setNoticeQueue
in interfaceNotifdQueueHandler
- Parameters:
noticeQueue
- aNoticeQueue
object.
-
setInterval
public void setInterval(java.lang.String interval)
setInterval
- Specified by:
setInterval
in interfaceNotifdQueueHandler
- Parameters:
interval
- aString
object.
-
run
public void run()
The main worker of the fiber. This method is executed by the encapsulated thread to read commands from the execution queue and to execute those commands. If the thread is interrupted or the status changes toSTOP_PENDING
then the method will return as quickly as possible.- Specified by:
run
in interfacejava.lang.Runnable
-
processQueue
public void processQueue()
processQueue
- Specified by:
processQueue
in interfaceNotifdQueueHandler
-
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 toSTARTING
and will transition toRUNNING
when the fiber finishes initializing and begins processing the encapsulated queue.
-
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.
-
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 interfacePausableFiber
- 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 interfacePausableFiber
- 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.
-
getStatus
public int getStatus()
Returns the current status of the pausable fiber.- Specified by:
getStatus
in interfaceFiber
- Returns:
- The current status of the fiber.
- See Also:
PausableFiber
,Fiber
-
-