org.opennms.bb.dp.discovery
Class Discovery

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

public class Discovery
extends PollerThread

The main class for discovery

Author:
Sowmya, OpenNMS

Field Summary
private  DiscCapsdReceiver m_discCapsdReceiver
          The thread that recieves the confirmation from capsd that a node has been added to the database - once this confirmation is got, the node is acknowledged as 'known'.
private  IPGenerator m_ipGenerator
          The IP Generator object is used to create IP addresses and add those addresses to the passed queue.
private  long m_lNumThreads
          The calcualted number of threads that maximize the use of the packets per second limitiation.
private  long m_lPktsPerSec
          The calculated number of packets per second that discovery can send when querying the network.
private  int m_maxNumMonitorThreads
          The maximum number of threads in the monitor thread pool which will be processing incoming ICMP poll requests from the ICMP service monitor.
private  PCQueue m_monitorRequestQ
          The producer/cosumer queue that is the sink for the MonitorRequestReceiver and the source for the numerous monitor ping threads.
private  MonitorRequestReceiver m_monitorRequestReceiver
          The MonitorRequestReceiver object listens for ICMP poll requests from the ICMP service monitor and adds those requests to the passed queue.
private  DiscPingManager m_pingManager
          The discovery thread manager.
private  PCQueue m_pingRequestQ
          The producer/cosumer queue that is the sink for the IPGenerator and the source for the numerous discovery ping threads.
private static Properties m_properties
          The properties that are specific to the discovery process.
private  String PROP_MAX_MONITOR_POLL_THREADS
          The property name used to get max number of monitor pinger threads to use to service ICMP poll requests.
 
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
Discovery()
          Instantiates the discovery process
 
Method Summary
(package private) static void ()
          Copy the System properties and then load the bluebird and discovery specific files into the property object.
private  void computeNetParameters(float fNetPercent, long lTimeout, int iRetries)
          This method is used by the discovery constructor to determine what the maximum number of packets per second should be and the number of icmp sending threads.
static Properties getProperties()
          Returns the discovery specific properties.
static String getProperty(String key)
          Returns the property identified by 'key' from the discovery specific properties.
private  Set loadDatabaseNodes()
          This method is used by the class constructor to load the currently known IP Addresses from the database into the discovery VM.
static void main(String[] args)
          Start the discovery process
 void run()
          Waits for control messages and takes appropriate action
 void shutdown()
          Initiates the shutdown of the thread's run method in accordance with the base class' specification.
 void start()
          Start all the threads
 
Methods inherited from class org.opennms.bb.dp.common.components.PollerThread
getCtrlStatus, getOpStatus, pauseOperation, pauseThread, resumeOperation, resumeThread, setCtrlStatus, setOpStatus, setUserStatus, 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, 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

m_lPktsPerSec

private long m_lPktsPerSec

The calculated number of packets per second that discovery can send when querying the network. Discovery should never send more than this number of packets in one second. This does not restrict the size of the packets, but for discovery all the packets should roughly be the same size.


m_lNumThreads

private long m_lNumThreads

The calcualted number of threads that maximize the use of the packets per second limitiation. This is the number of threads that are sending ICMP request.


m_ipGenerator

private IPGenerator m_ipGenerator

The IP Generator object is used to create IP addresses and add those addresses to the passed queue. The generator is a cyclic object that uses its own thread to generate the addresses.


m_monitorRequestReceiver

private MonitorRequestReceiver m_monitorRequestReceiver

The MonitorRequestReceiver object listens for ICMP poll requests from the ICMP service monitor and adds those requests to the passed queue.


m_pingManager

private DiscPingManager m_pingManager

The discovery thread manager. The manager is responsible for controlling numerous threads that constantly send ICMP request to remote addresses.

See Also:
DiscPinger

m_pingRequestQ

private PCQueue m_pingRequestQ

The producer/cosumer queue that is the sink for the IPGenerator and the source for the numerous discovery ping threads. This object is passed to the IPGenerator and the DiscPingManager objects.


m_monitorRequestQ

private PCQueue m_monitorRequestQ

The producer/cosumer queue that is the sink for the MonitorRequestReceiver and the source for the numerous monitor ping threads. This object is passed to the MonitorRequestReceiver and the DiscPingManager objects.


PROP_MAX_MONITOR_POLL_THREADS

private final String PROP_MAX_MONITOR_POLL_THREADS
The property name used to get max number of monitor pinger threads to use to service ICMP poll requests.

m_maxNumMonitorThreads

private int m_maxNumMonitorThreads

The maximum number of threads in the monitor thread pool which will be processing incoming ICMP poll requests from the ICMP service monitor. This value is configurable through the discovery properties. Default value is 10.


m_discCapsdReceiver

private DiscCapsdReceiver m_discCapsdReceiver

The thread that recieves the confirmation from capsd that a node has been added to the database - once this confirmation is got, the node is acknowledged as 'known'.


m_properties

private static Properties m_properties

The properties that are specific to the discovery process. The properties are a combination of the JVM's system properties, plus the inclusion of the OpenNMS specific property files. There are two additional files that are loaded, if the system properties are correctly set.

In order to properly load the OpenNMS specific file(s) their location must be known in advance. Instead of hard coding the location of the files, the files are referenced by properties. The following list declares the properites that reference the specific files. The property files are loaded in the order they appear in the list.

Currently the string returned for the propertyFile(s) must be a file on the local filesystem. Later support for remote files via HTTP, JSDT, etc al may be supported.

Constructor Detail

Discovery

public Discovery()
          throws ClassNotFoundException,
                 IOException
Instantiates the discovery process
Throws:
ClassNotFoundException - Thrown if an error occurs loading the database driver for collecting the known nodes.
IOException - Thrown if an file I/O error occurs loading and parsing the configuration files.
RuntimeException - Thrown if an unexpected runtime error occurs creating the discovery instance.
java.lang.NullPointerException - Thrown if an expected property is null and the discovery initilization cannot recover.
Method Detail

static void ()

Copy the System properties and then load the bluebird and discovery specific files into the property object. For more information see the javadoc comment for the m_properties element.

Additionally, this static loading will also look at the debugging options and will setup the Logging Facility. This can only be done after the properties have been loaded.


loadDatabaseNodes

private Set loadDatabaseNodes()
                       throws ClassNotFoundException

This method is used by the class constructor to load the currently known IP Addresses from the database into the discovery VM. The addresses are stored in a synchronzied Set collection so multiple threads can use the set together without causing data corruption.

If a non-fatal database error occurs, then an empty set is returned for use by the discovery process.

Returns:
The Set of all known IP addresses.
Throws:
java.lang.NullPointerException - Thrown if one of the database parameters cannot be loaded.
ClassNotFoundException - Thrown if the database driver cannot be loaded by the JVM.

computeNetParameters

private void computeNetParameters(float fNetPercent,
                                  long lTimeout,
                                  int iRetries)

This method is used by the discovery constructor to determine what the maximum number of packets per second should be and the number of icmp sending threads. This is done in accordance with the method described in the OpenNMS polling documentation.

Currently there is no JAVA method for getting the interfaces and their transmission rates. So for now the transmission rate has be hard coded at 10Mbs until a correct method is introduced.

Parameters:
fNetPercent - The maximum amount of the network interface's bandwidth that may be used for discovery.
lTimeout - The (default) timeout that will be used by discovery.
iRetires - The (default) number of retries that will be used when sending icmp packets.

start

public void start()
Start all the threads
Overrides:
start in class Thread

shutdown

public void shutdown()

Initiates the shutdown of the thread's run method in accordance with the base class' specification. Once the class is notified to terminate, the method waits for the thread to exit. If the calling thread equals the thread for the instance, then the join method will not be called.

Overrides:
shutdown in class PollerThread
Following copied from class: org.opennms.bb.dp.common.components.PollerThread
See Also:
PollerThread.STATUS_TERMINATING, Object.notifyAll()

run

public void run()
Waits for control messages and takes appropriate action
Overrides:
run in class Thread

getProperties

public static Properties getProperties()
Returns the discovery specific properties.

getProperty

public static String getProperty(String key)
Returns the property identified by 'key' from the discovery specific properties.

main

public static void main(String[] args)
Start the discovery process