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

java.lang.Object
  |
  +--org.opennms.bb.dp.capsd.snmp.IpNetToMediaTable
All Implemented Interfaces:
SnmpHandler

public class IpNetToMediaTable
extends Object
implements SnmpHandler

The IpNetToMediaTable uses a SnmpSession to collect the entries in the remote agent's ipNetToMedia 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 ipNetToMedia table at once. The number of SNMP packets should not exceed the number of media entries + 1, assuming no lost packets or error conditions occur.

Version:
$Revision: 1.12 $
Author:
Sowmya, Weave, OpenNMS
See Also:
RFC1213

Field Summary
private  List m_entries
          The list of media entries from the remote's interface table.
private  boolean m_error
          Flag indicating if query was successful or if the collection failed.
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 Summary
private IpNetToMediaTable()
          The default constructor is marked as private and will always throw an exception.
  IpNetToMediaTable(SnmpSession session, Signaler signaler)
          Constructs an IpNetToMediaTable object that is used to collect the NetToMedia elements from the remote agent.
 
Method Summary
 boolean failed()
          Returns the success or failure code for collection of the data.
 List getEntries()
          Returns the list of entry maps that can be used to access all the information about the interface 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.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_entries

private List m_entries

The list of media entries from the remote's interface table. The list contains a set of IpNetToMediaTableEntry objects that were collected from the remote host.

See Also:
IpNetToMediaTableEntry

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.

Constructor Detail

IpNetToMediaTable

private IpNetToMediaTable()
                   throws 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:
UnsupportedOperationException - Always thrown from this method since it is not supported.
See Also:
IpNetToMediaTable(SnmpSession, Signaler)

IpNetToMediaTable

public IpNetToMediaTable(SnmpSession session,
                         Signaler signaler)

Constructs an IpNetToMediaTable object that is used to collect the NetToMedia elements from the remote agent. Once all the elements 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:
IpNetToMediaTableEntry
Method Detail

failed

public boolean failed()

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


getEntries

public List getEntries()

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

Returns:
The list of ifTableEntry 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.

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