org.opennms.bb.dp.capsd.components
Class CapsdDiscReceiver

java.lang.Object
  |
  +--org.opennms.bb.dp.capsd.components.CapsdDiscReceiver

public final class CapsdDiscReceiver
extends Object

This class is designed to handle the setup, communications, and shutdown between capsd and discovery using JSDT. Each instance of the class is passed a queue where address recoreds from the discovery system are written.

Version:
$Revision: 1.17 $
Author:
Sowmya, OpenNMS

Inner Class Summary
private  class CapsdDiscReceiver.CapsdDiscConsumer
          The CapsdDiscConsumer class is used by the capabilities daemon to receive actual IP address information from discovery.
 
Field Summary
private static String JSDT_CLIENT_NAME
          The JSDT client name used by this class.
private  com.sun.media.jsdt.Channel m_channel
          JSDT channel from which discoveyr data is received.
private  CapsdDiscReceiver.CapsdDiscConsumer m_consumer
          The consumer object is the final endpoint of data sent from discovery to capsd.
private  PCQueue m_discRecvQ
          The discovery queue is the link between the capabilites daemon and the discovery system.
private  Set m_dupNodes
          Duplicate node set.
private  boolean m_paused
          The current receiver status of the JSDT class.
private  com.sun.media.jsdt.Session m_session
          JSDT session for communication with discovery.
 
Constructor Summary
private CapsdDiscReceiver()
          The default constructor.
  CapsdDiscReceiver(PCQueue Q, Set dupNodes)
          The class' constructor is used to create an instance of the capsd/discovery address exchange channel.
 
Method Summary
 void close()
          Closes the connection to the JSDT session and channel.
private  void jsdtConnect()
          Creates a connection using JSDT between the capabilities daemon and the discovery system.
 void open()
          The start method is used to connect the object to the JSDT channel between the capsd and discovery systems.
 void pause()
          Pauses the recipt of messages from the JSDT channel.
 void resume()
          Resumes the recipt 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_discRecvQ

private PCQueue m_discRecvQ

The discovery queue is the link between the capabilites daemon and the discovery system. The queue is used to hold String object that are IPv4 address in dotted decimal format. The address strings are received using the JSDT connection to discovery.


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 discovery. This session is used to exchange messages about discovered IP addresses.


m_channel

private com.sun.media.jsdt.Channel m_channel

JSDT channel from which discoveyr data is received. The channel is part of the JSDT session between capsd and discovery.


m_consumer

private CapsdDiscReceiver.CapsdDiscConsumer m_consumer

The consumer object is the final endpoint of data sent from discovery to capsd. The consumer receives messages from the session, through the channel, and then is responsible for placing those messages in the objects queue.


m_dupNodes

private Set m_dupNodes
Duplicate node set. If an address is received from discovery process and it is a member of this set it is not added to the discovery queue.

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 ip address object from the discovery system and then forward them on to the rest of the capsd system.

Constructor Detail

CapsdDiscReceiver

private CapsdDiscReceiver()
                   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.

CapsdDiscReceiver

public CapsdDiscReceiver(PCQueue Q,
                         Set dupNodes)

The class' constructor is used to create an instance of the capsd/discovery address exchange channel. The object will consume address data from the discovery system and place the messages into the passed queue. By default when the object it will be in a ready state and will accept & queue messages from discovery. The queue should be prepared to handle messages prior to calling the start method.

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

Parameters:
Q - The queue where address records are written from discovery.
dupNodes - The set of addresses which are already known by Capsd.
Method Detail

jsdtConnect

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

Creates a connection using JSDT between the capabilities daemon and the discovery system. The capsd client name is passed in and used to join the address exchange channel.

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 recipt 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 recipt 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 start method is used to connect the object to the JSDT channel between the capsd and discovery systems. 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 discovery system. 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.