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

java.lang.Object
  |
  +--org.opennms.bb.dp.discovery.components.MonitorRequestReceiver

public final class MonitorRequestReceiver
extends Object

This class is designed to handle the setup, communications, and shutdown between discovery and ICMP service monitor using JSDT. Each instance of the class is passed a queue where ICMP poll records from the ICMP service monitor process are written.

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

Inner Class Summary
private  class MonitorRequestReceiver.MonitorRequestConsumer
          The MonitorRequestConsumer class is responsible for handling incoming ICMP poll request messages from the ICMP service monitor.
 
Field Summary
private  boolean bFirstRequestReceived
           True if first request already received and m_inforOnce object has been notified.
private static String JSDT_CLIENT_NAME
          The JSDT client name used by this class.
private  com.sun.media.jsdt.Channel m_channel
          JSDT channel over which ICMP service monitor request messages are received.
private  MonitorRequestReceiver.MonitorRequestConsumer m_consumer
          The consumer object is the final endpoint of data sent from the service monitor to discovery.
private  PCQueue m_monitorRequestQ
          The monitor request queue is the link between the discovery system and the ICMP service monitor.
private  boolean m_paused
          The current receiver status of the JSDT class.
private  Object m_pingManager
           Contains a reference to the ping manager which will be notified the first time a request is received.
private  com.sun.media.jsdt.Session m_session
          JSDT session for communication with the ICMP service monitor.
 
Constructor Summary
private MonitorRequestReceiver()
          The default constructor.
  MonitorRequestReceiver(PCQueue Q, Object pingMgr)
          The class' constructor is used to create an instance of the discovery/ICMP service monitor request exchange channel.
 
Method Summary
 void close()
          Closes the connection to the JSDT session and channel.
private  void jsdtConnect()
          Creates a connection using JSDT between discovery and the ICMP service monitor.
 void open()
          The open method is used to connect the object to the JSDT channel between discovery and ICMP service monitor.
 void pause()
          Pauses the receipt of messages from the JSDT channel.
 void resume()
          Resumes the receipt of messages from the JSDT channel.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

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_pingManager

private Object m_pingManager

Contains a reference to the ping manager which will be notified the first time a request is received. No further notifications will be generated. Ping manager uses this notifications as a trigger to start the monitor thread pool.


bFirstRequestReceived

private boolean bFirstRequestReceived

True if first request already received and m_inforOnce object has been notified. False otherewise.


m_paused

private volatile boolean m_paused

The current receiver status of the JSDT class. If the variable is set then JSDT messages are rejected by the inner class.

This member is marked as volitalie to ensure that changes are not cached and missed by the JSDT thread(s).


m_session

private com.sun.media.jsdt.Session m_session

JSDT session for communication with the ICMP service monitor. This session is used to exchange ICMP service monitor request/reply messages.


m_channel

private com.sun.media.jsdt.Channel m_channel

JSDT channel over which ICMP service monitor request messages are received. The channel is part of the JSDT session between discovery and the ICMP service monitor.


m_consumer

private MonitorRequestReceiver.MonitorRequestConsumer m_consumer

The consumer object is the final endpoint of data sent from the service monitor to discovery. The consumer receives messages from the session, through the channel, and then is responsible for creating an IPPollAddress object and adding it to the monitor request Q.


JSDT_CLIENT_NAME

private static final String JSDT_CLIENT_NAME

The JSDT client name used by this class. This is the client that will receive ICMP poll request objects from the service monitor and make them available to the rest of discovery for processing.

Constructor Detail

MonitorRequestReceiver

private MonitorRequestReceiver()
                        throws UnsupportedOperationException

The default constructor. The construct is implemented for completeness, but will always throw an exception. Since any instance must have a queue to write recieved addresses the default constructor is denied via the exception.

Throws:
UnsupportedOperationException - Always thrown to prevent default construction.

MonitorRequestReceiver

public MonitorRequestReceiver(PCQueue Q,
                              Object pingMgr)

The class' constructor is used to create an instance of the discovery/ICMP service monitor request exchange channel. The object will consume ICMP poll requests from the ICMP service monitor and place the resulting request objects into the passed queue. By default the object will be in a ready state and will accept & queue requests. The queue should be prepared to handle requests prior to calling the start method.

However, should the queue be closed the class will behave just as if the object's instance had been suspended via the pause method.

Parameters:
Q - The queue where ICMP poll requests received from ICMP service monitor are written.
pingMgr - The object to be notified the first time a request is received (& never again).
Method Detail

jsdtConnect

private void jsdtConnect()
                  throws com.sun.media.jsdt.JSDTException

Creates a connection using JSDT between discovery and the ICMP service monitor.

If an error occurs then an exception will be thrown from the code. Be aware that this method will wait until a connection or fatal error occurs before returning control to the caller. Callers should make provisions to ensure that any locks that are held prior to calling jsdtConnect will not cause negative deadlock issues.

Throws:
com.sun.media.jsdt.JSDTException - thrown if the JSDT communication channel cannot be established or other error conditions occur.

resume

public void resume()

Resumes the receipt of messages from the JSDT channel. If the channel was not paused then the resume is silently ignored. If the channel was paused, then messages will again be received by the consumer.


pause

public void pause()

Pauses the receipt of messages from the JSDT channel. All messages received while the channel is paused will be discarded by the consumer.


open

public void open()
          throws com.sun.media.jsdt.JSDTException

The open method is used to connect the object to the JSDT channel between discovery and ICMP service monitor. When called the method will block until the connection is established or an exception is thrown. The method will also reset the instance to receive messages from the ICMP service monitor. If the instance was previously paused, it will be resumed.

Throws:
com.sun.media.jsdt.JSDTException - Thrown if a the connection cannot be completed due to a JSDT error.
IllegalStateException - Thrown if the session has already been established.

close

public void close()

Closes the connection to the JSDT session and channel. This will permanently close the connection. If the connection is needed again, then a new object should be created.

If a JSDTException occurs it is caught, and then logged as a warning in the log. The exception is then silently discarded and not rethrown.