|
OpenNMS API 1.1.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.ping.ReplyReceiver
This class is designed to be a single point of reciept for
all ICMP messages received by an IcmpSocket
instance. The class implements the
PausableFiber
interface
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 Reply
class are added to the queue
for processing.
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 |
private static final java.lang.String NAME
private FifoQueue m_replyQ
private IcmpSocket m_portal
private short m_filterID
private volatile boolean m_paused
private java.lang.String m_name
private java.lang.Thread m_worker
private int m_status
Constructor Detail |
private ReplyReceiver() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- Always thrown.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's
length.
portal
- The ICMP socketreplyQ
- The reply queue for matching messages.filterID
- The ICMP Identity for matching.Method Detail |
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:
Packet.getNetworkSize()
pkt
- The datagram to process.
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
public final void start()
start
in interface Fiber
java.lang.IllegalStateException
- Thrown if the receiver has
already been started.public final void stop()
stop
in interface Fiber
java.lang.IllegalStateException
- Thrown if the receiver
was never started.public final void pause()
pause
in interface PausableFiber
public final void resume()
resume
in interface PausableFiber
public final java.lang.String getName()
getName
in interface Fiber
public final int getStatus()
getStatus
in interface Fiber
public final void run()
run
in interface java.lang.Runnable
|
OpenNMS API 1.1.4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |