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

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

public final class DiscPinger
extends PollerThread

DiscPinger is the type of thread that is maintained in the ping manager's thread pool. This is responsible for actually creating, sending and retrying the PING packets.

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.12 $
Author:
Sowmya, OpenNMS

Field Summary
private  IPPollAddress m_addr
          The IP Address object to poll.
private  short m_filterID
          This is the filterID to include in the icmp echo request message.
private  QuantumSemaphore m_limiter
          The limiter is used to ensure that only a specific number of packets are sent within a specific time quantium.
private  DaemonConnection m_portal
          This is the connection to the icmp daemon that sends and receives request for the discovery process.
private  PCQueue m_requestQ
           
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
DiscPinger(long lThreadID, PCQueue requestQ, DaemonConnection portal, short pingFilterID, QuantumSemaphore pktLimiter)
          Creates a new discovery ping thread that will attempt to poll addresses as they are set by the manager.
 
Method Summary
 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 discovery poller thread.
 
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_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_requestQ

private PCQueue m_requestQ

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_limiter

private QuantumSemaphore m_limiter

The limiter is used to ensure that only a specific number of packets are sent within a specific time quantium. The number is reset to the maximum each time quantum.


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_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

DiscPinger

public DiscPinger(long lThreadID,
                  PCQueue requestQ,
                  DaemonConnection portal,
                  short pingFilterID,
                  QuantumSemaphore pktLimiter)

Creates a new discovery ping thread that will attempt to poll addresses as they are set by the manager.

Parameters:
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.
pktLimiter - Limits the packets per quantum.
Method Detail

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 discovery poller thread. It waits for new addresses to be served out by the manager 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