OpenNMS API 1.2.3

org.opennms.netmgt.capsd.snmp
Class IfXTable

java.lang.Object
  extended byorg.opennms.netmgt.capsd.snmp.IfXTable
All Implemented Interfaces:
SnmpHandler

public final class IfXTable
extends java.lang.Object
implements SnmpHandler

The IfXTable uses a SnmpSession to collect the entries in the remote agent's interface extensions table. It implements the SnmpHandler to receive notifications and handle errors associated with the data collection. Data is collected using a series of GETNEXT PDU request to walk multiple parts of the interface table at once. The number of SNMP packets should not exceed the number of interface + 1, assuming no lost packets or error conditions occur.

Version:
1.1.1.1
Author:
Mike , Weave , OpenNMS
See Also:
RFC2233

Field Summary
private  java.util.List m_entries
           The list of interfaces from the remote's interface extensions table.
private  boolean m_error
           Flag indicating if query was successful or if the collection failed.
private static char[] m_hexDigit
           
private  int m_ifNumber
           Used for storing the ifNumber variable from the MIB, the number of interfaces a device possesses.
private  int m_ifNumberRequestId
           The request id associated with the GetNext PDU generated to retrieve the number of interfaces associated with the remote host.
private  int m_responses
           For SNMPv1 used to keep track of the number of SNMP response packets received.
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  SnmpObjectId m_stopAt
           This will be the OID where the information should cut off from the return packet from the GETBULK command.
private  int m_version
           Used to generate the proper command for fetching the SNMP data from the agent (via GETBULK for version 2 or GETNEXT for version 1.
private  SnmpVarBind[] tempStorage
           Used as a temporary storage space for all the data collected from the SNMP response packets for SNMP v2.
 
Constructor Summary
private IfXTable()
           The default constructor is marked as private and will always throw an exception.
  IfXTable(SnmpSession session, Signaler signaler)
           Constructs an IfXTable object that is used to collect the interface elements from the remote agent.
  IfXTable(SnmpSession session, Signaler signaler, int version)
           Constructs an IfXTable object that is used to collect the interface elements from the remote agent.
 
Method Summary
 boolean failed()
           Returns the success or failure code for collection of the data.
 java.util.List getEntries()
           Returns the list of entry maps that can be used to access all the information about the interface extensions table.
 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.
static java.lang.String toHexString(byte[] physAddr)
           This method converts the physical address, normally six bytes, into a hexidecimal string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_hexDigit

private static final char[] m_hexDigit

m_entries

private java.util.List m_entries

The list of interfaces from the remote's interface extensions table. The list contains a set of IfXTableEntry objects that were collected from the remote host.

See Also:
IfXTableEntry

m_error

private boolean m_error

Flag indicating if query was successful or if the collection failed.


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.


m_version

private int m_version

Used to generate the proper command for fetching the SNMP data from the agent (via GETBULK for version 2 or GETNEXT for version 1.


m_ifNumberRequestId

private int m_ifNumberRequestId

The request id associated with the GetNext PDU generated to retrieve the number of interfaces associated with the remote host.


m_stopAt

private SnmpObjectId m_stopAt

This will be the OID where the information should cut off from the return packet from the GETBULK command.


m_ifNumber

private int m_ifNumber

Used for storing the ifNumber variable from the MIB, the number of interfaces a device possesses.


tempStorage

private SnmpVarBind[] tempStorage

Used as a temporary storage space for all the data collected from the SNMP response packets for SNMP v2. After receiving all the data, the information will be sorted so that it mimics the SNMP v1 data storage; one map per interface containing all the necessary MIB values.


m_responses

private int m_responses

For SNMPv1 used to keep track of the number of SNMP response packets received. For SNMPv2 used to keep track of the total number of varbinds received in SNMP response packets. For both SNMPv1 and SNMPv2 this value is used to determine when all the necessary SNMP data has been retrieved.

Constructor Detail

IfXTable

private IfXTable()
          throws java.lang.UnsupportedOperationException

The default constructor is marked as private and will always throw an exception. This is done to disallow the constructor to be called. Since any instance of this class must have an SnmpSession and Signaler to properly work, the correct constructor must be used.

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

IfXTable

public IfXTable(SnmpSession session,
                Signaler signaler)

Constructs an IfXTable object that is used to collect the interface elements from the remote agent. Once all the interfaces are collected, or there is an error in the collection the signaler object is notified to inform other threads.

Parameters:
session - The session with the remote agent.
signaler - The object to notify waiters.
See Also:
IfXTableEntry

IfXTable

public IfXTable(SnmpSession session,
                Signaler signaler,
                int version)

Constructs an IfXTable object that is used to collect the interface elements from the remote agent. Once all the interfaces are collected, or there is an error in the collection the signaler object is notified to inform other threads.

Parameters:
session - The session with the remote agent.
signaler - The object to notify waiters.
version - SNMP version to use
See Also:
IfXTableEntry
Method Detail

failed

public boolean failed()

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


getEntries

public java.util.List getEntries()

Returns the list of entry maps that can be used to access all the information about the interface extensions table.

Returns:
The list of ifXTableEntry maps.

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.

For SNMP version 2 devices, all the received data enters a temporary array. After the collecting process, the method sorts the data so that each interface has its own map.

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

toHexString

public static java.lang.String toHexString(byte[] physAddr)

This method converts the physical address, normally six bytes, into a hexidecimal string. The string is not prefixed with the traditional "0x", but is the raw hexidecimal string in upper case.

NOTICE: The string is converted based on the starndard US-ASCII table. Each NIBBLE is converted to an integer and added to the character '0' (Zero).

Parameters:
physAddr - The physical address to convert to a string.
Returns:
The converted physical address as a hexidecimal string.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.