|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.jmx.adaptor.snmp.agent.RequestHandlerSupport
org.jboss.jmx.adaptor.snmp.agent.RequestHandlerImpl
public class RequestHandlerImpl
Implement RequestHandler with mapping of snmp get/set requests to JMX mbean attribute gets/sets. Currently only v1 / v2 PDUs are supported by the agent service.
| Field Summary | |
|---|---|
protected java.util.SortedMap<org.snmp4j.smi.OID,BindEntry> |
bindings
Bindings from oid to mbean |
static java.lang.String |
NO_ENTRY_FOUND_FOR_OID
|
static java.lang.String |
SKIP_ENTRY
|
| Fields inherited from class org.jboss.jmx.adaptor.snmp.agent.RequestHandlerSupport |
|---|
clock, log, resourceName, server |
| Constructor Summary | |
|---|---|
RequestHandlerImpl()
Default CTOR |
|
| Method Summary | |
|---|---|
void |
addAttributeMappings(java.util.List<ManagedBean> mappings)
|
org.snmp4j.smi.Variable |
getValueFor(org.snmp4j.smi.OID oid)
Return the current value for the given oid |
void |
initialize(java.lang.String resourceName,
javax.management.MBeanServer server,
org.jboss.logging.Logger log,
Clock uptime)
Initialize |
static org.snmp4j.smi.Variable |
prepForPdu(java.lang.Object val,
org.snmp4j.smi.OID tableIndexOID)
This method takes an Object that is typically going to be put into a VariableBinding for use in a PDU, and thus must be converted into an SNMP type based on it's type. |
void |
reconfigure(java.lang.String resName)
Reconfigures the RequestHandler |
void |
removeAttributeMappings(java.util.List<ManagedBean> mappings)
|
void |
SnmpAgentSessionError(org.snmp4j.Snmp session,
int error,
java.lang.Object ref)
This method is invoked if an error occurs in the session. |
org.snmp4j.PDU |
snmpReceivedGet(org.snmp4j.PDU pdu)
This method is defined to handle SNMP GET and GETNEXT requests that are received by the session. |
org.snmp4j.PDU |
snmpReceivedGetBulk(org.snmp4j.PDU pdu)
This method handles SNMP GetBulk requests received in this session. |
void |
snmpReceivedPdu(org.snmp4j.Snmp session,
java.net.InetAddress manager,
int port,
org.snmp4j.smi.OctetString community,
org.snmp4j.PDU pdu)
This method is defined to handle SNMP requests that are received by the session. |
org.snmp4j.PDU |
snmpReceivedSet(org.snmp4j.PDU pdu)
This method is defined to handle SNMP Set requests that are received by the session. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String NO_ENTRY_FOUND_FOR_OID
public static final java.lang.String SKIP_ENTRY
protected java.util.SortedMap<org.snmp4j.smi.OID,BindEntry> bindings
| Constructor Detail |
|---|
public RequestHandlerImpl()
| Method Detail |
|---|
public void initialize(java.lang.String resourceName,
javax.management.MBeanServer server,
org.jboss.logging.Logger log,
Clock uptime)
throws java.lang.Exception
initialize in interface RequestHandlerinitialize in class RequestHandlerSupportresourceName - A file containing get/set mappingsserver - Our MBean-Serverlog - The logger we useuptime - The uptime of the snmp-agent subsystem.
java.lang.Exception - in case of initialization problem
public void reconfigure(java.lang.String resName)
throws java.lang.Exception
reconfigure in interface ReconfigurableresName - the file to configure from,
usually the same used at initialization time.
java.lang.Exception - in case of failurepublic org.snmp4j.PDU snmpReceivedGetBulk(org.snmp4j.PDU pdu)
This method handles SNMP GetBulk requests received in this session. Request is already validated. Builds a response and passes it back. A GetBulk request has two additional fields: nonRepeaters: the amount of scalar objects in the PDU maxRepetitions: the number of getNext requests to be done on the scalar objects. The parameter PDU is interpreted as follows: The first nonRepeaters elements in the VariableBinding list are retrieved with a simple GET snmp call. The remaining (size - nonRepeaters) elements in the VariableBinding list have maxRepetitions GETNEXT calls upon them. All of these VariableBindings are added into the response. The resultant response will have N + (M*R) VariableBindings This method functions according to the protocol definition in RFC-3416
snmpReceivedGetBulk in interface SnmpAgentRequestHandlersnmpReceivedGetBulk in class RequestHandlerSupportpdu - contains the following:
a list of OIDs
an Integer > 0 indicating the number of non-repeaters (set with PDU.setNonRepeaters())
an Integer >= 0 indicating the number of repetitions (set with PDU.setMaxRepetitions())
public org.snmp4j.PDU snmpReceivedGet(org.snmp4j.PDU pdu)
This method is defined to handle SNMP GET and GETNEXT requests that are received by the session. The request has already been validated by the system. This routine will build a response and pass it back to the caller. The behaviour is defined in RFC-3416 for v2 protocols.
snmpReceivedGet in interface SnmpAgentRequestHandlersnmpReceivedGet in class RequestHandlerSupportpdu - The SNMP pdu.
public org.snmp4j.PDU snmpReceivedSet(org.snmp4j.PDU pdu)
This method is defined to handle SNMP Set requests that are received by the session. The request has already been validated by the system. This routine will build a response and pass it back to the caller. Upon any error, this method will rollback all sets that were made before the failure occured. The behaviour is defined in RFC-3416
snmpReceivedSet in interface SnmpAgentRequestHandlersnmpReceivedSet in class RequestHandlerSupportpdu - The SNMP pdu
public void snmpReceivedPdu(org.snmp4j.Snmp session,
java.net.InetAddress manager,
int port,
org.snmp4j.smi.OctetString community,
org.snmp4j.PDU pdu)
This method is defined to handle SNMP requests that are received by the session. The parameters allow the handler to determine the host, port, and community string of the received PDU
snmpReceivedPdu in interface SnmpAgentRequestHandlersnmpReceivedPdu in class RequestHandlerSupportsession - The SNMP sessionmanager - The remote senderport - The remote senders portcommunity - The community stringpdu - The SNMP pdu
public void SnmpAgentSessionError(org.snmp4j.Snmp session,
int error,
java.lang.Object ref)
This method is invoked if an error occurs in the session. The error code that represents the failure will be passed in the second parameter, 'error'. The error codes can be found in the class SnmpAgentSession class.
If a particular PDU is part of the error condition it will be passed in the third parameter, 'pdu'. The pdu will be of the type SnmpPduRequest or SnmpPduTrap object. The handler should use the "instanceof" operator to determine which type the object is. Also, the object may be null if the error condition is not associated with a particular PDU.
SnmpAgentSessionError in class RequestHandlerSupportsession - The SNMP Sessionerror - The error condition value.ref - The PDU reference, or potentially null. It may also be an
exception.public void addAttributeMappings(java.util.List<ManagedBean> mappings)
addAttributeMappings in interface RequestHandlermappings - public void removeAttributeMappings(java.util.List<ManagedBean> mappings)
removeAttributeMappings in interface RequestHandlermappings -
public org.snmp4j.smi.Variable getValueFor(org.snmp4j.smi.OID oid)
throws NoSuchInstanceException,
VariableTypeException
getValueFor in interface RequestHandleroid - The oid we want a value for
NoSuchInstanceException
VariableTypeException
public static org.snmp4j.smi.Variable prepForPdu(java.lang.Object val,
org.snmp4j.smi.OID tableIndexOID)
throws VariableTypeException
val - The value needing conversion.
VariableTypeException - if the method was unable to convert val's type into an
equivalent SMI type.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||