org.opennms.bb.dp.discovery.components
Class MonitorPinger

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

public final class MonitorPinger
extends PollerThread

MonitorPinger is another type of thread that is maintained in the ping manager's thread pool(the other being DiscPinger). This type of thread is responsible for creating, sending and retrying the PING packets as well as notifying the ICMP Service Monitor via JSDT of the result of the PING attempt(s).

Note however that object does not directly receive echo replies. The manager receives the replies and notifies this thread that a response to the request sent out has been received

Version:
$Revision: 1.2 $
Author:
Mike, Sowmya, OpenNMS

Inner Class Summary
private static class MonitorPinger.ReplyToSoapDocument
          This static class is used to build a compliant SOAP document that is sent to the ICMP service monitor.
 
Field Summary
private static String JSDT_CLIENT_RECEIVER_NAME_PREFIX
          This the prefix for the JSDT client to which ICMP poll result messages will be sent.
private  IPPollAddress m_addr
          The IP Address object to poll.
private static com.sun.media.jsdt.Channel m_channel
          JSDT channel through which replies are sent to the ICMP service monitor.
private static PollerClient m_client
          JSDT client identifier
private  short m_filterID
          This is the filterID to include in the icmp echo request message.
private  PCQueue m_monitorRequestQ
          The monitor request queue is the link between the discovery system and the ICMP service monitor.
private  DiscPingManager m_pingMgr
          The discover ping manager.
private  DaemonConnection m_portal
          This is the connection to the icmp daemon that sends and receives request for the discovery process.
private  boolean m_responded
          When the manager calls the receive method this variable will be updated with the value of true if the responding address matches the value of m_addr.
private  Object m_sync
          This object is used to synchronize access to the m_addr and m_responded.
private  long m_tid
          The thread key for this particular thread.
 
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
MonitorPinger(DiscPingManager pingMgr, long lThreadID, PCQueue requestQ, DaemonConnection portal, short pingFilterID)
          Creates a new monitor ping thread that will attempt to poll addresses as they are added to the request queue.
 
Method Summary
static com.sun.media.jsdt.Channel getChannel()
           Static method for retrieving the JSDT channel through which the MonitorPinger threads forwards ICMP poll results to the ICMP service monitor.
static PollerClient getClient()
           Static method for retrieving the JSDT client through which the MonitorPinger threads forwards ICMP poll results to the ICMP service monitor.
 IPPollAddress getIPAddress()
          Return the current IP Address being polled by this thread.
 long getThreadID()
          Returns the thread id as specified by the manager.
 boolean received(String ipAddress)
          The ping manager calls this function to indicate that the request sent by this thread has been received.
 void run()
          The run() method does the hard work of the monitor poller thread.
static void setChannel(com.sun.media.jsdt.Channel replyChannel)
           Static method for setting the JSDT channel through which the MonitorPinger threads will forward ICMP poll results to the ICMP service monitor.
static void setClient(PollerClient replyClient)
           Static method for setting the JSDT client through which the MonitorPinger threads will forward ICMP poll results to the ICMP service monitor.
 
Methods inherited from class org.opennms.bb.dp.common.components.PollerThread
getCtrlStatus, getOpStatus, pauseOperation, pauseThread, resumeOperation, resumeThread, setCtrlStatus, setOpStatus, setUserStatus, shutdown, 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, start, 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_channel

private static com.sun.media.jsdt.Channel m_channel
JSDT channel through which replies are sent to the ICMP service monitor.

m_client

private static PollerClient m_client
JSDT client identifier

JSDT_CLIENT_RECEIVER_NAME_PREFIX

private static final String JSDT_CLIENT_RECEIVER_NAME_PREFIX
This the prefix for the JSDT client to which ICMP poll result messages will be sent. The unique id which identifies the instance of the ICMP service monitor which sent the request will be appended to this prefix in order to ensure that only the monitor instance that sent the request gets the reply. WARNING: This value must match the prefix defined in the ServiceMonitorICMP class.

m_tid

private long m_tid

The thread key for this particular thread. This key is placed into all the icmp echo requests that are sent by this thread. The manager can the use this id to find the sending thread.


m_monitorRequestQ

private PCQueue m_monitorRequestQ

The monitor request queue is the link between the discovery system and the ICMP service monitor. The queue is used to hold IPPollAddress objects used by Monitor Pinger objects to generate ICMP requests directed at remote nodes. The data contained by an IPPollAddress object (IP address, timeout, retries) is received via a JSDT connection with the ICMP service monitor.


m_portal

private DaemonConnection m_portal

This is the connection to the icmp daemon that sends and receives request for the discovery process. Since most process must have superuser privilage to send and receive icmp messages, the icmpd is used to isolate the java code from the operating system.


m_filterID

private short m_filterID

This is the filterID to include in the icmp echo request message. Unless this id is included in the sending packet the echo reply will be discarded by the icmpd.


m_sync

private Object m_sync

This object is used to synchronize access to the m_addr and m_responded. Those member variables should not be modified unless the lock for m_sync is held. Also, while waiting on those modification the m_sync.wait() will be called instead of the thread's wait() method.


m_pingMgr

private DiscPingManager m_pingMgr

The discover ping manager.


m_addr

private IPPollAddress m_addr

The IP Address object to poll.


m_responded

private boolean m_responded

When the manager calls the receive method this variable will be updated with the value of true if the responding address matches the value of m_addr.

Constructor Detail

MonitorPinger

public MonitorPinger(DiscPingManager pingMgr,
                     long lThreadID,
                     PCQueue requestQ,
                     DaemonConnection portal,
                     short pingFilterID)

Creates a new monitor ping thread that will attempt to poll addresses as they are added to the request queue.

Parameters:
pingMgr - The thread manager
lThreadId - The thread identifer used by the manager.
Q - The Q from which to read off the address to ping
portal - The connection to the icmp daemon.
pingFilterID - The filter id used by the icmp daemon.
Method Detail

setChannel

public static void setChannel(com.sun.media.jsdt.Channel replyChannel)

Static method for setting the JSDT channel through which the MonitorPinger threads will forward ICMP poll results to the ICMP service monitor.

Parameters:
replyChannel - The JSDT channel for sending replies

getChannel

public static com.sun.media.jsdt.Channel getChannel()

Static method for retrieving the JSDT channel through which the MonitorPinger threads forwards ICMP poll results to the ICMP service monitor.

Returns:
The JSDT channel for replies or null if not set

setClient

public static void setClient(PollerClient replyClient)

Static method for setting the JSDT client through which the MonitorPinger threads will forward ICMP poll results to the ICMP service monitor.

Parameters:
replyChannel - The JSDT client for sending replies

getClient

public static PollerClient getClient()

Static method for retrieving the JSDT client through which the MonitorPinger threads forwards ICMP poll results to the ICMP service monitor.

Returns:
The JSDT client for replies or null if not set

getIPAddress

public IPPollAddress getIPAddress()

Return the current IP Address being polled by this thread. If no address is being polled then a null pointer will be returned.


getThreadID

public long getThreadID()

Returns the thread id as specified by the manager.


received

public boolean received(String ipAddress)

The ping manager calls this function to indicate that the request sent by this thread has been received. If the thread is currently attempting to query the remote host then a value of true will be returned.

Parameters:
ipAddress - The remote echo reply address.
Returns:
True if the ipAddress matches the queried node.

run

public void run()

The run() method does the hard work of the monitor poller thread. It waits for new addresses to be served out by the Monitor Request Receiver and then polls each address. When either the retries are exhausted or the manager informs the object that the remote has responded, the thread will go back to an idle state and wait for a new address.

Overrides:
run in class Thread