|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.management.snmp.agent.SnmpMibAgent
com.sun.management.snmp.agent.SnmpProxy
public class SnmpProxy
The SnmpProxy class provides an implementation of an SNMP proxy. It is a MBean forwarding calls to a remote sub agent. Multiple instances of SnmpProxy can run within an agent. Each of them being a proxy for a remote agent.
SnmpProxy implements the whole set of SNMP operations :
SnmpProxy fully translates SNMP V1 to SNMP V2 and SNMP V2 to SNMP V1. It allows also V1 to V1 and V2 to V2 forwarding. SnmpProxy doesn't deal with traps.
Handled manager protocols :
The V1 or V2 or V3 ==> V1 or V2 security parameters follow the rules
coded in the method translateParameters
.
If you want to change them, just overloaded this method.
The policy details are:
public
is used as the read community string and
private
as the write one. Java DMK 5.0 introduces the notion of SNMP engine. An engine
is generally associated to an SNMP entity. When embedding a proxy
within a Java DMK agent, the SnmpV3AdaptorServer
engine must be passed.
Field Summary | |
---|---|
static long |
defaultTimeout
The default timeout is 10 seconds. |
Fields inherited from class com.sun.management.snmp.agent.SnmpMibAgent |
---|
server |
Constructor Summary | |
---|---|
SnmpProxy(SnmpEngine engine,
SnmpPeer peer,
String rootOid)
Initializes this SNMP proxy with a SnmpPeer to which calls are forwarded. |
|
SnmpProxy(SnmpEngine engine,
SnmpPeer peer,
String rootOid,
String name)
Initializes this SNMP proxy with a SnmpPeer to which calls are forwarded. |
Method Summary | |
---|---|
void |
check(SnmpMibRequest inRequest)
Implement the check method from the abstract SnmpMibAgent class. |
void |
forwardSetRequestOnCheck(boolean check)
By default, set requests are forwarded when set(SnmpMibRequest request) is called. |
void |
get(SnmpMibRequest inRequest)
Implement the get method from the abstract SnmpMibAgent class. |
protected void |
get(SnmpPeer peer,
SnmpSession session,
SnmpMibRequest inRequest)
The get implementation. |
void |
getBulk(SnmpMibRequest request,
int nonRepeat,
int maxRepeat)
Implement the getBulk method from the abstract SnmpMibAgent class. |
SnmpEngine |
getEngine()
Returns the SNMP engine the proxy is based on. |
String |
getMibName()
Gets the distant agent MIB name. |
void |
getNext(SnmpMibRequest inRequest)
Implement the getNext method from the abstract SnmpMibAgent class. |
protected void |
getNext(SnmpPeer peer,
SnmpSession session,
SnmpMibRequest inRequest)
The getNext implementation. |
SnmpPeer |
getPeer()
Returns the Peer associated with this proxy. |
long[] |
getRootOid()
Returns the root object identifier of the MIB. |
long |
getTimeout()
Gets the proxy / sub agent communication total timeout. |
protected boolean |
handleReport(SnmpRequest request)
Called when a report is received when forwarding a request. |
void |
hideInvalidResponseError(boolean hide)
Hides invalid response errors. |
void |
init()
Initialization of the SnmpProxy with no registration in Java DMK. |
boolean |
isInvalidResponseErrorHidden()
Checks if invalid response errors are hidden. |
boolean |
isSetRequestForwardedOnCheck()
Returns the way a set request is forwarded by this SnmpProxy . |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Initialization of the SnmpProxy with registration in Java DMK. |
void |
set(SnmpMibRequest inRequest)
Implement the set method from the abstract SnmpMibAgent class. |
protected void |
set(SnmpPeer peer,
SnmpSession session,
SnmpMibRequest inRequest)
The set implementation. |
void |
setTimeout(long t)
Sets the proxy / agent communication total timeout. |
boolean |
skipError()
True means that this proxy doesn't throw exception in the case of erroneous getnext. |
void |
skipError(boolean skip)
If the proxied agent is answering an error during a getnext or getbulk, this proxy will throw a SnmpStatusException . |
protected SnmpParams |
translateParameters(SnmpMibRequest request)
Return the parameters to use when sending the call. |
Methods inherited from class com.sun.management.snmp.agent.SnmpMibAgent |
---|
getBindingState, getMBeanServer, getSnmpAdaptor, getSnmpAdaptorName, newMibRequest, newMibRequest, postDeregister, postRegister, preDeregister, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptor, setSnmpAdaptorName, setSnmpAdaptorName, setSnmpAdaptorName, setSnmpAdaptorName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long defaultTimeout
Constructor Detail |
---|
public SnmpProxy(SnmpEngine engine, SnmpPeer peer, String rootOid) throws SnmpStatusException, IllegalArgumentException
engine
- The SNMP adaptor engine.peer
- The peer representing the proxied agent.rootOid
- The proxy root OID.
IllegalArgumentException
- if the passed engine is null.
SnmpStatusException
- An error occurred while accessing
a MIB node.public SnmpProxy(SnmpEngine engine, SnmpPeer peer, String rootOid, String name) throws SnmpStatusException, IllegalArgumentException
SnmpAdaptorServer
engine
- The SNMP adaptor engine.peer
- The peer representing the proxied agent.rootOid
- The proxy root OID.name
- The proxy name.
IllegalArgumentException
- if the passed engine is null.
SnmpStatusException
- An error occurred while accessing
a MIB node.Method Detail |
---|
public void skipError(boolean skip)
SnmpStatusException
.
In some cases (multiple proxy registered in the same adaptor), it
can be useful to skip the error answer. To do so, you must call
this method passing it true.
By default a proxy will not skip the error.
skip
- True will skip, false will not.public boolean skipError()
public SnmpEngine getEngine()
public long getTimeout()
public void setTimeout(long t)
t
- The timeout in milliseconds.public void init() throws IllegalAccessException
init
in class SnmpMibAgent
IllegalAccessException
- The used session cannot be
initialized.public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
preRegister
in class SnmpMibAgent
server
- The reference to the MBean server.name
- The object name of this SnmpProxy.
Exception
public String getMibName()
getMibName
in interface SnmpMibAgentMBean
getMibName
in class SnmpMibAgent
public void get(SnmpMibRequest inRequest) throws SnmpStatusException
get
in interface SnmpMibAgentMBean
get
in class SnmpMibAgent
inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.SnmpMibAgent.get(SnmpMibRequest)
public void set(SnmpMibRequest inRequest) throws SnmpStatusException
set
in interface SnmpMibAgentMBean
set
in class SnmpMibAgent
inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.SnmpMibAgent.set(SnmpMibRequest)
public void forwardSetRequestOnCheck(boolean check)
set(SnmpMibRequest request)
is called. Doing so makes the
sub agent returned errors to be systematically mapped to undoFailed.
If you want more details on the sub agent error status, call this
method with true value. The set request will be then forwarded when
check(SnmpMibRequest request)
is called. No error
translation will be done.
check
- True, the set request is forwarded on check, false the
set request is forwarded on set.public boolean isSetRequestForwardedOnCheck()
SnmpProxy
.
public void hideInvalidResponseError(boolean hide)
Sub agent invalid response requests (e.g. invalid BER encoding) can lead to a request timeout.
This behavior can be changed by calling this method and passing it false. Providing false
will make this SnmpProxy
to throw a GenError if an internal error occurs.
hide
- True, hide the internal errors, requests will fail in timeout. False throw a GenError.public boolean isInvalidResponseErrorHidden()
Invalid response requests (e.g. invalid BER encoding) are dropped
by the manager API. This makes the requests to timeout. This behavior
can be changed by calling the method
hideInvalidResponseError
. By default the errors are hidden.
public void check(SnmpMibRequest inRequest) throws SnmpStatusException
forwardSetRequestOnCheck
has been set to true,
the set request is forwarded on the check.
Doing the set on check allows you to debug easily your master agent. The sub agent returned errors are forwarded to the manager without any translation (undoFailed is the error status returned when the set is done on the set). Handles V1 to V2 and V2 to V1 SNMP protocol translations.
check
in interface SnmpMibAgentMBean
check
in class SnmpMibAgent
inRequest
- The SnmpMibRequest object holding the list of variable
to be retrieved. This list is composed of SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.SnmpMibAgent.check(SnmpMibRequest)
public void getNext(SnmpMibRequest inRequest) throws SnmpStatusException
getNext
in interface SnmpMibAgentMBean
getNext
in class SnmpMibAgent
inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.SnmpMibAgent.getNext(SnmpMibRequest)
public void getBulk(SnmpMibRequest request, int nonRepeat, int maxRepeat) throws SnmpStatusException
getNext(com.sun.management.snmp.agent.SnmpMibRequest)
as repetition is needed.
getBulk
in interface SnmpMibAgentMBean
getBulk
in class SnmpMibAgent
request
- The SnmpMibRequest object holding the list of variable to
be retrieved. This list is composed of
SnmpVarBind
objects.nonRepeat
- The number of variables, starting with the first
variable in the variable-bindings, for which a single
lexicographic successor is requested.maxRepeat
- The number of lexicographic successors requested
for each of the last R variables. R is the number of variables
following the first nonRepeat
variables for which
multiple lexicographic successors are requested.
SnmpStatusException
- An error occurred during the operation.SnmpMibAgent.getBulk(SnmpMibRequest,int,int)
public long[] getRootOid()
getRootOid
in class SnmpMibAgent
public final SnmpPeer getPeer()
protected boolean handleReport(SnmpRequest request)
request
- The request containing the received report.
The default implementation does nothing and returns false.
protected SnmpParams translateParameters(SnmpMibRequest request) throws SnmpStatusException
request
- The received request.
SnmpStatusException
protected void get(SnmpPeer peer, SnmpSession session, SnmpMibRequest inRequest) throws SnmpStatusException
Be aware that session and peer parameters are SnmpProxy attributes. Modifying them leads to unpredictable behavior. This method should not be overridden.
peer
- The SnmpPeer on which the call is forwardedsession
- The session used to forward the call. If the proxy
translates from SNMP V2 to SNMP V1, you must provide a fixed session.inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.protected void getNext(SnmpPeer peer, SnmpSession session, SnmpMibRequest inRequest) throws SnmpStatusException
Be aware that session and peer parameters are SnmpProxy attributes. Modifying them leads to unpredictable behavior. This method should not be overridden.
peer
- The SnmpPeer on which the call is forwardedsession
- The session used to forward the call. If the proxy
translates from SNMP V2 to SNMP V1, you must provide a fixed session.inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.protected void set(SnmpPeer peer, SnmpSession session, SnmpMibRequest inRequest) throws SnmpStatusException
Be aware that session and peer parameters are SnmpProxy attributes. Modifying them leads to unpredictable behavior. This method should not be overridden.
peer
- The SnmpPeer on which the call is forwardedsession
- The session used to forward the call. If the proxy
translates from SNMP V2 to SNMP V1, you must provide a fixed session.inRequest
- The SnmpMibRequest object holding the list of
variable to be retrieved. This list is composed of
SnmpVarBind
objects.
SnmpStatusException
- An error occurred during the operation.
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |