OpenNMS API 1.2.3

org.opennms.netmgt.ping
Class ReplyReceiver

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

public final class ReplyReceiver
extends java.lang.Object
implements PausableFiber, java.lang.Runnable

This class is designed to be a single point of reciept for all ICMP messages received by an org.opennms.protocols.icmp.IcmpSocketIcmpSocket instance. The class implements the PausableFiberinterface as a means to control the operation of the receiver.

Once the receiver is started it will process all recieved datagrams and filter them based upon their ICMP code and the filter identifier used to construct the reciever. All ICMP messages, except for Echo Replies, are discared by the reciever. In addition, only those echo replies that have their identifier set to the passed filter identifier are also discarded.

Received datagrams that pass the requirement of the receiver are added to the reply queue for processing by the application. Only instances of the Replyclass are added to the queue for processing.

Author:
Sowmya , Brian Weaver , OpenNMS

Field Summary
private  short m_filterID
          The filter to look for
private  java.lang.String m_name
          The name of this instance.
private  boolean m_paused
          The paused flag
private  IcmpSocket m_portal
          The connection to the icmp daemon.
private  FifoQueue m_replyQ
          The queue to write the received replies
private  int m_status
          The thread's status
private  java.lang.Thread m_worker
          The underlying thread doing the work.
private static java.lang.String NAME
          The name of this instance, always starts the same and the filterID is appended to the name.
 
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
private ReplyReceiver()
          The default constructor is marked private to prevent it's used.
  ReplyReceiver(IcmpSocket portal, FifoQueue replyQ, short filterID)
           Constructs a ping reciever thread that reads datagrams from the connection and adds them to the queue.
 
Method Summary
 java.lang.String getName()
          Returns the name of this fiber.
 int getStatus()
          Returns the status of the fiber.
 void pause()
          Pauses the reciever.
protected  void process(java.net.DatagramPacket pkt)
           Processes the received datagram and adds a new Reply instance to the reply queue.
 void resume()
          Resumes the recipt and processing of ICMP messages.
 void run()
          The run() method does the actual work of reading messages from the daemon and placing those messages in the appropoiate queue for use by other threads.
 void start()
          Starts the ICMP receiver.
 void stop()
          Stops the current receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
The name of this instance, always starts the same and the filterID is appended to the name.

See Also:
Constant Field Values

m_replyQ

private FifoQueue m_replyQ
The queue to write the received replies


m_portal

private IcmpSocket m_portal
The connection to the icmp daemon.


m_filterID

private short m_filterID
The filter to look for


m_paused

private volatile boolean m_paused
The paused flag


m_name

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


m_worker

private java.lang.Thread m_worker
The underlying thread doing the work.


m_status

private int m_status
The thread's status

Constructor Detail

ReplyReceiver

private ReplyReceiver()
               throws java.lang.UnsupportedOperationException
The default constructor is marked private to prevent it's used. The constructor always throws an UnsupportedOperationException.

Throws:
java.lang.UnsupportedOperationException - Always thrown.

ReplyReceiver

public ReplyReceiver(IcmpSocket portal,
                     FifoQueue replyQ,
                     short filterID)

Constructs a ping reciever thread that reads datagrams from the connection and adds them to the queue. As each datagram is received and processed by the receiver, replies matching the criteria are added to the queue. Each reply must be of type ICMP Echo Reply, its identity must match the filterID, and its length must be equal to the ping packet'slength.

Parameters:
portal - The ICMP socket
replyQ - The reply queue for matching messages.
filterID - The ICMP Identity for matching.
Method Detail

process

protected void process(java.net.DatagramPacket pkt)
                throws java.lang.InterruptedException,
                       FifoQueueException

Processes the received datagram and adds a new Reply instance to the reply queue. The recieved packet must pass the following criteria:

Parameters:
pkt - The datagram to process.
Throws:
java.lang.InterruptedException - Thrown if the thread is interrupted.
org.opennms.core.fiber.FifoQueueException - Thrown if a queue exception occurs adding a new reply.
FifoQueueException

start

public final void start()
Starts the ICMP receiver. Once started the receiver reads new messages from the ICMP socket and processes them. Packets that match the proper criteria are added to the queue. If the receiver is already started then an exception is thrown.

Specified by:
start in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the receiver has already been started.

stop

public final void stop()
Stops the current receiver. If the receiver was never started then an exception is thrown.

Specified by:
stop in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the receiver was never started.

pause

public final void pause()
Pauses the reciever. While the receiver is pauses the it still reads and processes new ICMP datagrams. However, all datagrams are discarded while in a paused state regardless of matching criteria. Messages are still read since the operating system will continue to deliver them.

Specified by:
pause in interface PausableFiber

resume

public final void resume()
Resumes the recipt and processing of ICMP messages.

Specified by:
resume in interface PausableFiber

getName

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

Specified by:
getName in interface Fiber
Returns:
The fiber's name.

getStatus

public final int getStatus()
Returns the status of the fiber.

Specified by:
getStatus in interface Fiber
Returns:
The fiber's status.

run

public final void run()
The run() method does the actual work of reading messages from the daemon and placing those messages in the appropoiate queue for use by other threads.

Specified by:
run in interface java.lang.Runnable

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.