OpenNMS API 1.2.3

org.opennms.netmgt.capsd
Class Scheduler

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

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

This class implements a simple scheduler to ensure that Capsd rescans occurs at the expected intervals.

Author:
Mike Davidson , OpenNMS

Nested Class Summary
(package private)  class Scheduler.NodeInfo
          This class encapsulates the information about a node necessary to schedule the node for rescans.
 
Field Summary
private static java.lang.String FIBER_NAME
          The prefix for the fiber name.
private  long m_initialSleep
          The configured initial sleep (in milliseconds) prior to scheduling rescans
private  long m_interval
          The configured interval (in milliseconds) between rescans
private  java.util.List m_knownNodes
          List of NodeInfo objects representing each of the nodes in the database capability of being scheduled.
private  java.lang.String m_name
          The name of this fiber.
private  FifoQueue m_rescanQ
          The rescan queue where new RescanProcessor objects are enqueued for execution.
private  int m_status
          The status for this fiber.
private  java.lang.Thread m_worker
          The worker thread that executes this instance.
private static int SMB_REPARENTING_IDENTIFIER
          Special identifier used in place of a valid node id in order to schedule an SMB reparenting using the rescan scheduler.
private static java.lang.String SQL_GET_LAST_POLL_TIME
          SQL used to retrieve the last poll time for all the managed interfaces belonging to a particular node.
private static java.lang.String SQL_RETRIEVE_NODES
          SQL used to retrieve list of nodes from the node table.
 
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) Scheduler(FifoQueue rescanQ)
          Constructs a new instance of the scheduler.
 
Method Summary
(package private)  void forceRescan(int nodeId)
          Creates a NodeInfo object representing the specified node and adds it to the rescan queue for immediate rescanning.
 java.lang.String getName()
          Returns the name of this fiber.
 int getStatus()
          Returns the current of this fiber.
private  void loadKnownNodes()
          Builds a list of NodeInfo objects representing each of the nodes in the database capable of being scheduled for rescan.
 void pause()
          Pauses the scheduler if it is current running.
 void resume()
          Resumes the scheduler if it has been paused.
 void run()
          The main method of the scheduler.
(package private)  void scheduleNode(int nodeId)
          Creates a NodeInfo object representing the specified node and adds it to the known node list for scheduling.
 void start()
          Starts the fiber.
 void stop()
          Stops the fiber.
(package private)  void unscheduleNode(int nodeId)
          Removes the specified node from the known node list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIBER_NAME

private static final java.lang.String FIBER_NAME
The prefix for the fiber name.

See Also:
Constant Field Values

SQL_RETRIEVE_NODES

private static final java.lang.String SQL_RETRIEVE_NODES
SQL used to retrieve list of nodes from the node table.

See Also:
Constant Field Values

SQL_GET_LAST_POLL_TIME

private static final java.lang.String SQL_GET_LAST_POLL_TIME
SQL used to retrieve the last poll time for all the managed interfaces belonging to a particular node.

See Also:
Constant Field Values

SMB_REPARENTING_IDENTIFIER

private static final int SMB_REPARENTING_IDENTIFIER
Special identifier used in place of a valid node id in order to schedule an SMB reparenting using the rescan scheduler.

See Also:
Constant Field Values

m_name

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


m_status

private int m_status
The status for this fiber.


m_worker

private java.lang.Thread m_worker
The worker thread that executes this instance.


m_knownNodes

private java.util.List m_knownNodes
List of NodeInfo objects representing each of the nodes in the database capability of being scheduled.


m_interval

private long m_interval
The configured interval (in milliseconds) between rescans


m_initialSleep

private long m_initialSleep
The configured initial sleep (in milliseconds) prior to scheduling rescans


m_rescanQ

private FifoQueue m_rescanQ
The rescan queue where new RescanProcessor objects are enqueued for execution.

Constructor Detail

Scheduler

Scheduler(FifoQueue rescanQ)
    throws java.sql.SQLException
Constructs a new instance of the scheduler.

Method Detail

loadKnownNodes

private void loadKnownNodes()
                     throws java.sql.SQLException
Builds a list of NodeInfo objects representing each of the nodes in the database capable of being scheduled for rescan.

Throws:
java.sql.SQLException - if there is a problem accessing the database.

scheduleNode

void scheduleNode(int nodeId)
            throws java.sql.SQLException
Creates a NodeInfo object representing the specified node and adds it to the known node list for scheduling.

Parameters:
nodeId - Id of node to be scheduled
Throws:
java.sql.SQLException - if there is any problem accessing the database

unscheduleNode

void unscheduleNode(int nodeId)
Removes the specified node from the known node list.

Parameters:
nodeId - Id of node to be removed.

forceRescan

void forceRescan(int nodeId)
Creates a NodeInfo object representing the specified node and adds it to the rescan queue for immediate rescanning.

Parameters:
nodeId - Id of node to be rescanned

start

public void start()
Starts the fiber.

Specified by:
start in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the fiber is already running.

stop

public void stop()
Stops the fiber. If the fiber has never been run then an exception is generated.

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

pause

public void pause()
Pauses the scheduler if it is current running. If the fiber has not been run or has already stopped then an exception is generated.

Specified by:
pause in interface PausableFiber
Throws:
java.lang.IllegalStateException - Throws if the operation could not be completed due to the fiber's state.

resume

public void resume()
Resumes the scheduler if it has been paused. If the fiber has not been run or has already stopped then an exception is generated.

Specified by:
resume in interface PausableFiber
Throws:
java.lang.IllegalStateException - Throws if the operation could not be completed due to the fiber's state.

getStatus

public int getStatus()
Returns the current of this fiber.

Specified by:
getStatus in interface Fiber
Returns:
The current status.

getName

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

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

run

public void run()
The main method of the scheduler. This method is responsible for checking the runnable queues for ready objects and then enqueuing them into the thread pool for execution.

Specified by:
run in interface java.lang.Runnable

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.