org.opennms.bb.dp.capsd.snmp
Class SystemGroup

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.TreeMap
              |
              +--org.opennms.bb.dp.capsd.snmp.SystemGroup
All Implemented Interfaces:
Cloneable, Map, Serializable, SnmpHandler, SortedMap

public final class SystemGroup
extends TreeMap
implements SnmpHandler

SystemGroup holds the system group properties It implements the SnmpHandler to receive notifications when a reply is received/error occurs in the SnmpSession used to send requests /recieve replies.

Version:
$Revision: 1.13 $
Author:
Sowmya, Weave, OpenNMS
See Also:
RFC1213, Serialized Form

Inner classes inherited from class java.util.TreeMap
TreeMap.Entry
 
Inner classes inherited from class java.util.Map
Map.Entry
 
Field Summary
 boolean m_error
          Flag indicating the success or failure of the informational query.
private  Signaler m_signal
          Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.
private static NamedSnmpVar[] ms_elemList
          The keys that will be supported by default from the TreeMap base class.
static SnmpObjectId ROOT
          The SnmpObjectId that represents the root of the system tree.
static String SYSTEM_OID
          The SYSTEM_OID is the object identifier that represents the root of the system information in the MIB forest.
 
Fields inherited from class java.util.TreeMap
BLACK, comparator, ENTRIES, entrySet, KEYS, keySet, modCount, RED, root, serialVersionUID, size, values, VALUES
 
Constructor Summary
private SystemGroup()
          The default constructor is marked private and will always throw an exception.
  SystemGroup(SnmpSession session, Signaler signaler)
          The class constructor is used to initialize the collector and send out the initial SNMP packet requesting data.
 
Method Summary
(package private) static void ()
          Initialize the element list for the class.
 boolean failed()
          Returns the success or failure code for collection of the data.
static SnmpPduRequest getPdu()
          This method is used to build the initial SNMP PDU that is sent to the remote host.
 void snmpInternalError(SnmpSession session, int error, SnmpSyntax pdu)
          This method is part of the SnmpHandler interface and called when an internal error happens in a session.
 void snmpReceivedPdu(SnmpSession session, int command, SnmpPduPacket pdu)
          This method is used to process received SNMP PDU packets from the remote agent.
 void snmpTimeoutError(SnmpSession session, SnmpSyntax pdu)
          This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.
 void update(SnmpVarBind[] vars)
          This method is used to update the map with the current information from the agent.
 
Methods inherited from class java.util.TreeMap
addAllForTreeSet, buildFromSorted, buildFromSorted, clear, clone, colorOf, comparator, compare, computeRedLevel, containsKey, containsValue, decrementSize, deleteEntry, entrySet, firstEntry, firstKey, fixAfterDeletion, fixAfterInsertion, get, getCeilEntry, getEntry, getPrecedingEntry, headMap, incrementSize, key, keySet, lastEntry, lastKey, leftOf, parentOf, put, putAll, readObject, readTreeSet, remove, rightOf, rotateLeft, rotateRight, setColor, size, subMap, successor, swapPosition, tailMap, valEquals, values, valueSearchNonNull, valueSearchNull, writeObject
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, isEmpty
 

Field Detail

ms_elemList

private static NamedSnmpVar[] ms_elemList

The keys that will be supported by default from the TreeMap base class. Each of the elements in the list are an instance of the SNMP Interface table. Objects in this list should be used by multiple instances of this class.


m_error

public boolean m_error

Flag indicating the success or failure of the informational query. If the flag is set to false then either part of all of the information was unable to be retreived. If it is set to true then all of the data was received from the remote host.


SYSTEM_OID

public static final String SYSTEM_OID

The SYSTEM_OID is the object identifier that represents the root of the system information in the MIB forest. Each of the system elements can be retreived by adding their specific index to the string, and an additional Zero(0) to signify the single instance item.


ROOT

public static final SnmpObjectId ROOT

The SnmpObjectId that represents the root of the system tree. It is created at initilization time and is the converted value of SYSTEM_OID.

See Also:
SYSTEM_OID

m_signal

private Signaler m_signal

Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.

Constructor Detail

SystemGroup

private SystemGroup()
             throws UnsupportedOperationException

The default constructor is marked private and will always throw an exception. This is done to disallow the default constructor. The reason is that this object requires an SNMP session and a synchronization object to perform it's duties.

Throws:
UnsupportedOperationException - Always thrown from this method since it is not supported.
See Also:
SystemGroup(SnmpSession, Signaler)

SystemGroup

public SystemGroup(SnmpSession session,
                   Signaler signaler)

The class constructor is used to initialize the collector and send out the initial SNMP packet requesting data. The data is then received and store by the object. When all the data has been collected the passed signaler object is notified using the notifyAll() method.

Parameters:
session - The SNMP session with the remote agent.
signaler - The object signaled when data collection is done.
Method Detail

static void ()

Initialize the element list for the class. This is class wide data, but will be used by each instance.


update

public void update(SnmpVarBind[] vars)

This method is used to update the map with the current information from the agent.

This does not clear out any column in the actual row that does not have a definition.

Parameters:
vars - The variables in the interface row.

getPdu

public static SnmpPduRequest getPdu()

This method is used to build the initial SNMP PDU that is sent to the remote host. The PDU contains as many variable bindings as needed by the object. The varbinds are SnmpNull objects that have been initialized each with one instance of a required variable. The PDU type is marked as GET so that only a single Request/Response is required to get all the data.

Returns:
An SnmpPduRequest with the command GET and a predefined varbind list.
See Also:
SnmpNull, SnmpPduRequest

snmpReceivedPdu

public void snmpReceivedPdu(SnmpSession session,
                            int command,
                            SnmpPduPacket pdu)

This method is used to process received SNMP PDU packets from the remote agent. The method is part of the SnmpHandler interface and will be invoked when a PDU is successfully decoded. The method is passed the receiving session, the PDU command, and the actual PDU packet.

When all the data has been received from the session the signaler object, initialized in the constructor, is signaled. In addition, the receiving instance will call notifyAll() on itself at the same time.

Specified by:
snmpReceivedPdu in interface SnmpHandler
Parameters:
session - The SNMP Session that received the PDU
command - The command contained in the received pdu
pdu - The actual received PDU.

snmpInternalError

public void snmpInternalError(SnmpSession session,
                              int error,
                              SnmpSyntax pdu)

This method is part of the SnmpHandler interface and called when an internal error happens in a session. This is usually the result of an I/O error. This method will not be called if the session times out sending a packet, see snmpTimeoutError for timeout handling.

Specified by:
snmpInternalError in interface SnmpHandler
Parameters:
session - The session that had an unexpected error
error - The error condition
pdu - The PDU being sent when the error occured
See Also:
snmpTimeoutError(org.opennms.protocols.snmp.SnmpSession, org.opennms.protocols.snmp.SnmpSyntax), SnmpHandler

snmpTimeoutError

public void snmpTimeoutError(SnmpSession session,
                             SnmpSyntax pdu)

This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.

Specified by:
snmpTimeoutError in interface SnmpHandler
Parameters:
session - The session invoking the error handler
pdu - The PDU that the remote failed to respond to.
See Also:
SnmpHandler

failed

public boolean failed()

Returns the success or failure code for collection of the data.