com.sun.management.snmp.manager
Class SnmpSession

java.lang.Object
  extended by com.sun.management.snmp.manager.SnmpSession
All Implemented Interfaces:
SnmpDefinitions, Serializable, Runnable

public class SnmpSession
extends Object
implements SnmpDefinitions, Runnable, Serializable

Creates, controls, and manages one or more requests. A session is associated with one SnmpEngine (see RFC 2571). It can construct the engine or make use of an already created one. A session can be bound to a peer so that all requests created (without specifying a peer) will use this as the default. Alternatively, there can be a mixture of peers, that is, two requests can talk to two different peers.

In a typical manager application, a single engine is needed. So you should share a session within your process.

WARNING: Be aware that if you instantiate another session, you will instantiate another engine.

Each SnmpSession has a dispatcher, which is a thread used to service all the requests it creates. Each SnmpSession uses a separate socket for sending requests and receiving responses. The socket imposes an upper limit on the size of response packets. Any packet which exceeds this limit is truncated. By default, this limit is SnmpPeer.defaultSnmpResponsePktSize. It can be changed using setResponsePktSize(int).

This class implements an SNMP command interface which provides a variety of convenience methods that are used to create requests. Each of the requests performs a specific SNMP operation. These methods are simple to use and automatically start the request. The session maintains the list of all active requests and responses.

Users can explicitly create and start requests. This is usually not required for most applications.

Each method provides specific SNMP operations like SnmpGet, SnmpGetNext and SnmpSet. The SnmpGet and SnmpGetNext operations can be either poll or non-poll. In addition, there is a convenience method which automatically walks through a set of instances starting at any arbitrary place in the MIB hierarchy and terminates when a specified condition becomes true.

The requests are retried when the peer does not respond within a specified time. There is a maximum try limit. Certain options of sessions can be configured using the SnmpOptions object. This allows enabling and disabling of features like fixing protocol data units (PDU) on error, handling SnmpTooBig errors and multiplexing requests. If not specified, the default value sets the following options:

Once a session is created the user can perform one or more SNMP operations in a one-at-a-time sequence. Usually this sequence is a set of logical operations which together form a complete operation. For example, a SnmpSet operation, which involves an initial query to the agent for obtaining a valid index. This is followed by one or more SnmpSet commands to complete the set operation.

At any time, one or more requests active in a session can be canceled.

Since:
Java DMK 5.1
See Also:
SnmpRequest, Serialized Form

Field Summary
 String sessionName
          The name identifying this session.
 SnmpOptions snmpOptions
          Set of options used to configure all SnmpRequests created in this session.
 
Fields inherited from interface com.sun.management.snmp.SnmpDefinitions
authMask, authNoPriv, authPriv, authPrivMask, CtxtConsFlag, noAuthNoPriv, noGroupName, noSuchContext, noSuchView, notInView, pduGetBulkRequestPdu, pduGetNextRequestPdu, pduGetRequestPdu, pduGetResponsePdu, pduInformRequestPdu, pduReportPdu, pduSetRequestPdu, pduV1TrapPdu, pduV2TrapPdu, pduWalkRequest, privMask, reportableFlag, snmpAuthNotSupported, snmpBadSecurityLevel, snmpPrivNotSupported, snmpReqAborted, snmpReqEncodingError, snmpReqHandleTooBig, snmpReqInternalError, snmpReqPacketOverflow, snmpReqRefireAfterVbFix, snmpReqSocketIOError, snmpReqTimeout, snmpReqTooBigImpossible, snmpReqUnknownError, snmpRspAuthorizationError, snmpRspBadValue, snmpRspCommitFailed, snmpRspDecodingError, snmpRspEndOfTable, snmpRspGenErr, snmpRspInconsistentName, snmpRspInconsistentValue, snmpRspNoAccess, snmpRspNoCreation, snmpRspNoError, snmpRspNoSuchName, snmpRspNotWritable, snmpRspReadOnly, snmpRspResourceUnavailable, snmpRspTooBig, snmpRspUndoFailed, snmpRspWrongEncoding, snmpRspWrongLength, snmpRspWrongType, snmpRspWrongValue, snmpUnknownPrincipal, snmpUsmBadEngineId, snmpUsmInvalidTimeliness, snmpUsmSecurityModel, snmpV1AccessControlModel, snmpV1MsgProcessingModel, snmpV1SecurityModel, snmpV2AccessControlModel, snmpV2MsgProcessingModel, snmpV2SecurityModel, snmpV3AccessControlModel, snmpV3MsgProcessingModel, snmpVersionOne, snmpVersionThree, snmpVersionTwo, snmpWrongSnmpVersion, trapAuthenticationFailure, trapColdStart, trapEgpNeighborLoss, trapEnterpriseSpecific, trapLinkDown, trapLinkUp, trapWarmStart
 
Constructor Summary
SnmpSession(SnmpEngineParameters parameters, SnmpEngineFactory factory, String name, SnmpPeer apeer)
          Constructor for creating a new session.
SnmpSession(SnmpEngineParameters parameters, SnmpEngineFactory factory, String name, SnmpPeer apeer, InetAddress localaddress, int port)
          Constructor for creating a new session.
SnmpSession(SnmpEngineParameters parameters, SnmpEngineFactory factory, String name, SnmpPeer apeer, InetSocketAddress localaddress)
          Constructor for creating a new session.
SnmpSession(SnmpEngine engine, String name, SnmpPeer apeer)
          Constructor for creating a new session.
SnmpSession(String name)
          Constructor for creating a new session.
SnmpSession(String name, SnmpPeer apeer)
          Constructor for creating a new session.
 
Method Summary
 boolean anyPendingResponses()
          Indicates whether there are any responses available for processing.
 void cancelAllRequests()
          Cancels all pending requests in this session.
 boolean checkResponseFor(SnmpRequest req)
          Indicates whether a response was received for this request.
 void destroySession()
          Destroys any pending requests and then stops the session.
 void finalize()
          Finalizer of the SnmpSession objects.
 Vector getAllRequestsForPeer(SnmpPeer apeer)
          Gets a list of requests which have the specified destination.
 SnmpPeer getDefaultPeer()
          Gets a default peer (if any) bound to this session.
 SnmpEngine getEngine()
          Engine the SnmpSession is linked with.
 SnmpEngineId getEngineId()
          Get the local engine Id.
 int getInPkts()
          Gets the number of packets received.
 String getName()
          Gets the session name (often used in identification).
 int getOutPkts()
          Gets the number of packets sent.
 SnmpPduFactory getPduFactory()
          Gets the PDU factory.
 int getPktsErrors()
          Gets the number of errors that occurred.
 int getResponsePktSize()
          Gets the maximum size allowed for response packet.
 void hideInvalidResponseError(boolean hide)
          Hides invalid response errors.
 boolean isInvalidResponseErrorHidden()
          Checks if invalid response errors are hidden.
 boolean isSessionActive()
          Indicates whether the thread for this session is active.
 void performResetPktStatistics()
          Reset all the counters.
 void run()
          Dispatcher method for this session thread.
 void setDefaultPeer(SnmpPeer apeer)
          Sets peer as default.
 void setName(String name)
          Sets the session name (often used in identification).
 void setPduFactory(SnmpPduFactory factory)
          Sets the PDU factory.
 void setResponsePktSize(int size)
          Sets the maximum size allowed for response packet.
 SnmpRequest snmpGetBulkRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst, int nonRepeat, int maxRepeat)
          Performs a single SNMP getbulk request on the variable binding list.
 SnmpRequest snmpGetBulkRequest(SnmpRequestHandler cb, SnmpVarBindList vblst, int nonRepeat, int maxRepeat)
          Performs a single SNMP getbulk request on the variable binding list.
 SnmpRequest snmpGetNextPollRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst, int intrvl)
          Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list.
 SnmpRequest snmpGetNextPollRequest(SnmpRequestHandler cb, SnmpVarBindList vblst, int intrvl)
          Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list.
 SnmpRequest snmpGetNextRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP getnext request on the variable binding list.
 SnmpRequest snmpGetNextRequest(SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP getnext request on the variable binding list.
 SnmpRequest snmpGetPollRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst, int intrvl)
          Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list.
 SnmpRequest snmpGetPollRequest(SnmpRequestHandler cb, SnmpVarBindList vblst, int intrvl)
          Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list.
 SnmpRequest snmpGetRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP get request on the variable binding list.
 SnmpRequest snmpGetRequest(SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP get request on the variable binding list.
 SnmpRequest snmpInformRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpOid trapOid, SnmpVarBindList vblst)
          Performs a single SNMP inform request on the variable binding list.
 SnmpRequest snmpInformRequest(SnmpRequestHandler cb, SnmpOid trapOid, SnmpVarBindList vblst)
          Performs a single SNMP inform request on the variable binding list.
 SnmpRequest snmpSetRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP set request on the peer for the specified variable binding list.
 SnmpRequest snmpSetRequest(SnmpRequestHandler cb, SnmpVarBindList vblst)
          Performs a single SNMP set request on the peer for the specified variable binding list.
 SnmpRequest snmpWalkUntilRequest(SnmpPeer peer, SnmpRequestHandler cb, SnmpVarBindList vblst, SnmpOid key)
          Walks through the lexicographic ordering of the agent MIB.
 SnmpRequest snmpWalkUntilRequest(SnmpRequestHandler cb, SnmpVarBindList vblst, SnmpOid key)
          Walks through the lexicographic ordering of the agent MIB.
 boolean syncInProgress()
          Indicates whether this session is performing synchronous operation for a request.
 boolean thisSessionContext()
          Returns true if the current executing thread is this session's dispatcher.
 String toString()
          Gets a String representation of the session.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionName

public String sessionName
The name identifying this session. Useful in debugging a session.


snmpOptions

public SnmpOptions snmpOptions
Set of options used to configure all SnmpRequests created in this session. The user can manipulate the options directly. Note that this variable is public.

Constructor Detail

SnmpSession

public SnmpSession(SnmpEngine engine,
                   String name,
                   SnmpPeer apeer)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. The given SnmpEngine is used.

Parameters:
engine - The engine to use.
name - The session name.
apeer - The default peer to which to send requests.
Throws:
SnmpStatusException - Unable to initialize the SNMP Datagram Socket.
IllegalArgumentException - if the passed engine is null.

SnmpSession

public SnmpSession(String name,
                   SnmpPeer apeer)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. An SnmpEngine is instantiated.

The SnmpEngineId is computed as follows:

Parameters:
name - The session name.
apeer - The default peer to which to send requests.
Throws:
IllegalArgumentException - If one of the specified configuration files doesn't exist.
SnmpStatusException - Unable to initialize the Snmp Datagram Socket.

SnmpSession

public SnmpSession(String name)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. An SnmpEngine is instantiated.

The SnmpEngineId is computed as follows:

Parameters:
name - The session name.
Throws:
IllegalArgumentException - If one of the specified configuration files doesn't exist.
SnmpStatusException - Unable to initialize the SNMP Datagram Socket.

SnmpSession

public SnmpSession(SnmpEngineParameters parameters,
                   SnmpEngineFactory factory,
                   String name,
                   SnmpPeer apeer)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. An SnmpEngine is instantiated.

The SnmpEngineId is computed as follows:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
name - The session name.
apeer - The default peer to which to send requests.
Throws:
IllegalArgumentException - If one of the specified configuration files doesn't exist.
SnmpStatusException - Unable to initialize the Snmp Datagram Socket.

SnmpSession

public SnmpSession(SnmpEngineParameters parameters,
                   SnmpEngineFactory factory,
                   String name,
                   SnmpPeer apeer,
                   InetSocketAddress localaddress)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. An SnmpEngine is instantiated.

The SnmpEngineId is computed as follows:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
name - The session name.
apeer - The default peer to which to send requests.
localaddress - A sockect addess to bind the session to.
Throws:
IllegalArgumentException - If one of the specified configuration files doesn't exist.
SnmpStatusException - Unable to initialize the Snmp Datagram Socket.

SnmpSession

public SnmpSession(SnmpEngineParameters parameters,
                   SnmpEngineFactory factory,
                   String name,
                   SnmpPeer apeer,
                   InetAddress localaddress,
                   int port)
            throws SnmpStatusException,
                   IllegalArgumentException
Constructor for creating a new session. An SnmpEngine is instantiated.

The SnmpEngineId is computed as follows:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
name - The session name.
apeer - The default peer to which to send requests.
localaddress - An InetAddress to bind the session to.
port - A port to listen to.
Throws:
IllegalArgumentException - If one of the specified configuration files doesn't exist.
SnmpStatusException - Unable to initialize the Snmp Datagram Socket.
Method Detail

getEngine

public SnmpEngine getEngine()
Engine the SnmpSession is linked with.


getName

public final String getName()
Gets the session name (often used in identification).

Returns:
The session name.

getPduFactory

public final SnmpPduFactory getPduFactory()
Gets the PDU factory.

Returns:
The PDU factory

setPduFactory

public final void setPduFactory(SnmpPduFactory factory)
Sets the PDU factory.

Parameters:
factory - The new factory. If null is passed, the default factory will be set.

hideInvalidResponseError

public void hideInvalidResponseError(boolean hide)
Hides invalid response errors.

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 this method and passing it false. By default the errors are hidden.

Parameters:
hide - True, hide the internal errors, false throw a GenError.

isInvalidResponseErrorHidden

public boolean isInvalidResponseErrorHidden()
Checks if invalid response errors are hidden.

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.

Returns:
hide True, hide the internal errors, false throw a GenError.

setName

public final void setName(String name)
Sets the session name (often used in identification).

Parameters:
name - The session name.

getDefaultPeer

public final SnmpPeer getDefaultPeer()
Gets a default peer (if any) bound to this session.

Returns:
The default peer object.

setDefaultPeer

public final void setDefaultPeer(SnmpPeer apeer)
Sets peer as default. This peer is used when an SNMP command is issued without specifying the destination.

Parameters:
apeer - The default destination.

getEngineId

public final SnmpEngineId getEngineId()
Get the local engine Id.

Returns:
The local engine Id.

getResponsePktSize

public final int getResponsePktSize()
Gets the maximum size allowed for response packet. Any packet which exceeds this limit will be truncated. The default value is SnmpPeer.defaultSnmpResponsePktSize.

Returns:
The maximum size allowed for response packet.

setResponsePktSize

public final void setResponsePktSize(int size)
Sets the maximum size allowed for response packet.

Parameters:
size - The maximum size allowed for response packet.

getPktsErrors

public final int getPktsErrors()
Gets the number of errors that occurred.

Returns:
The number of errors that occurred.

getInPkts

public final int getInPkts()
Gets the number of packets received.

Returns:
The number of packets received.

getOutPkts

public final int getOutPkts()
Gets the number of packets sent.

Returns:
The number of packets sent.

performResetPktStatistics

public final void performResetPktStatistics()
Reset all the counters.


toString

public final String toString()
Gets a String representation of the session.

Overrides:
toString in class Object
Returns:
A String representation of the session.

isSessionActive

public final boolean isSessionActive()
Indicates whether the thread for this session is active.

Returns:
true if active, false otherwise.

syncInProgress

public boolean syncInProgress()
Indicates whether this session is performing synchronous operation for a request.

Returns:
true if the session is performing synchronous operation, false otherwise.

destroySession

public final void destroySession()
Destroys any pending requests and then stops the session. The session will not be usable after this method returns.


getAllRequestsForPeer

public Vector getAllRequestsForPeer(SnmpPeer apeer)
Gets a list of requests which have the specified destination.

Parameters:
apeer - The SnmpPeer.
Returns:
Vector of requests to the specified peer.

cancelAllRequests

public final void cancelAllRequests()
Cancels all pending requests in this session.


checkResponseFor

public boolean checkResponseFor(SnmpRequest req)
Indicates whether a response was received for this request. The status of the response is maintained in the request object.

Parameters:
req - The request.
Returns:
true if the request has a pending response, false otherwise.

thisSessionContext

public boolean thisSessionContext()
Returns true if the current executing thread is this session's dispatcher. Typically used to detect whether the user is doing a sync operation from this dispatcher context. For instance, a user gives a sync command from within a request callback using its associated session.

Returns:
true if current thread is this session's dispatcher, false otherwise.

snmpGetRequest

public final SnmpRequest snmpGetRequest(SnmpPeer peer,
                                        SnmpRequestHandler cb,
                                        SnmpVarBindList vblst)
                                 throws SnmpStatusException
Performs a single SNMP get request on the variable binding list. When the command completes, the appropriate callback method is invoked.

Parameters:
peer - The SNMP peer object.
cb - The callback that gets invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpGetRequest

public final SnmpRequest snmpGetRequest(SnmpRequestHandler cb,
                                        SnmpVarBindList vblst)
                                 throws SnmpStatusException
Performs a single SNMP get request on the variable binding list. Uses the default peer.

Parameters:
cb - The callback that gets invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpGetNextRequest

public final SnmpRequest snmpGetNextRequest(SnmpPeer peer,
                                            SnmpRequestHandler cb,
                                            SnmpVarBindList vblst)
                                     throws SnmpStatusException
Performs a single SNMP getnext request on the variable binding list. When the command completes, the appropriate callback method is invoked.

Parameters:
peer - The SNMP peer object.
cb - The callback that is invoked when a request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpGetNextRequest

public final SnmpRequest snmpGetNextRequest(SnmpRequestHandler cb,
                                            SnmpVarBindList vblst)
                                     throws SnmpStatusException
Performs a single SNMP getnext request on the variable binding list. Uses the default peer.

Parameters:
cb - The callback that is invoked when a request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpGetBulkRequest

public final SnmpRequest snmpGetBulkRequest(SnmpPeer peer,
                                            SnmpRequestHandler cb,
                                            SnmpVarBindList vblst,
                                            int nonRepeat,
                                            int maxRepeat)
                                     throws SnmpStatusException
Performs a single SNMP getbulk request on the variable binding list. When the command completes, the appropriate callback method is invoked.

Parameters:
peer - The SNMP peer object.
cb - The callback that is invoked when a request is complete.
vblst - A list of SnmpVarBind objects.
nonRepeat - Number of variable bindings to get one time.
maxRepeat - Number of repetitions for the variable bindings to get multiple times.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpGetBulkRequest

public final SnmpRequest snmpGetBulkRequest(SnmpRequestHandler cb,
                                            SnmpVarBindList vblst,
                                            int nonRepeat,
                                            int maxRepeat)
                                     throws SnmpStatusException
Performs a single SNMP getbulk request on the variable binding list. Uses the default peer.

Parameters:
cb - The callback that is invoked when a request is complete.
vblst - A list of SnmpVarBind objects.
nonRepeat - Number of variable bindings to get one time.
maxRepeat - Number of repetitions for the variable bindings to get multiple times.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpSetRequest

public final SnmpRequest snmpSetRequest(SnmpPeer peer,
                                        SnmpRequestHandler cb,
                                        SnmpVarBindList vblst)
                                 throws SnmpStatusException
Performs a single SNMP set request on the peer for the specified variable binding list. Because retries on set operations are not performed, the user needs to specify the timeout value within which a response is requested.

Parameters:
peer - The SNMP peer object.
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpSetRequest

public final SnmpRequest snmpSetRequest(SnmpRequestHandler cb,
                                        SnmpVarBindList vblst)
                                 throws SnmpStatusException
Performs a single SNMP set request on the peer for the specified variable binding list. Uses the default peer.

Parameters:
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpGetPollRequest

public final SnmpRequest snmpGetPollRequest(SnmpPeer peer,
                                            SnmpRequestHandler cb,
                                            SnmpVarBindList vblst,
                                            int intrvl)
                                     throws SnmpStatusException
Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list. Performs an SNMP get request on the variable binding list. After each poll, the appropriate callback method is invoked.

Parameters:
peer - The SNMP peer object.
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
intrvl - The frequency of polling (in seconds).
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpGetPollRequest

public final SnmpRequest snmpGetPollRequest(SnmpRequestHandler cb,
                                            SnmpVarBindList vblst,
                                            int intrvl)
                                     throws SnmpStatusException
Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list. Uses the default peer.

Parameters:
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
intrvl - The frequency of polling (in seconds).
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpGetNextPollRequest

public final SnmpRequest snmpGetNextPollRequest(SnmpPeer peer,
                                                SnmpRequestHandler cb,
                                                SnmpVarBindList vblst,
                                                int intrvl)
                                         throws SnmpStatusException
Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list. It saves the original variable binding list that is used during each poll. It performs an SNMP getnext request on the saved original variable binding list and provides the response to the user via the callback mechanism. This method is similar to snmpGetPoll except that it uses getnext on the original variable binding list instead of get.

Parameters:
peer - The SNMP peer object.
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
intrvl - The frequency of polling (in seconds).
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpGetNextPollRequest

public final SnmpRequest snmpGetNextPollRequest(SnmpRequestHandler cb,
                                                SnmpVarBindList vblst,
                                                int intrvl)
                                         throws SnmpStatusException
Starts polling the peer at the specified intervals, for the MIB variables in the variable binding list. Uses the default peer.

Parameters:
cb - The callback that is invoked when the request is complete.
vblst - A list of SnmpVarBind objects.
intrvl - The frequency of polling (in seconds).
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpInformRequest

public final SnmpRequest snmpInformRequest(SnmpPeer peer,
                                           SnmpRequestHandler cb,
                                           SnmpOid trapOid,
                                           SnmpVarBindList vblst)
                                    throws SnmpStatusException
Performs a single SNMP inform request on the variable binding list. When the command completes, the appropriate callback method is invoked. The variable list included in the outgoing inform request is composed of the following items:

Parameters:
peer - The SNMP peer object.
cb - The callback that gets invoked when request is complete.
trapOid - The OID identifying the inform request.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.
See Also:
How to get response data.

snmpInformRequest

public final SnmpRequest snmpInformRequest(SnmpRequestHandler cb,
                                           SnmpOid trapOid,
                                           SnmpVarBindList vblst)
                                    throws SnmpStatusException
Performs a single SNMP inform request on the variable binding list. Uses the default peer.

Note:
Take care when using the default SNMP peer in your requests.
Indeed, the default port for sending inform requests (162) is not the same used for the get, getnext, set etc... operations (161). So the peer to be used should not be the same.
To avoid any confusion, you can:

Parameters:
cb - The callback that gets invoked when request is complete.
trapOid - The OID identifying the inform request.
vblst - A list of SnmpVarBind objects.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.
See Also:
How to get response data.

snmpWalkUntilRequest

public final SnmpRequest snmpWalkUntilRequest(SnmpPeer peer,
                                              SnmpRequestHandler cb,
                                              SnmpVarBindList vblst,
                                              SnmpOid key)
                                       throws SnmpStatusException
Walks through the lexicographic ordering of the agent MIB. It starts at the specified variable binding list and continues until the OID key specified as a parameter is "smaller" than the first variable in the response variable binding list or an error occurs. Typically, this feature is used to walk through an arbitrary table and obtain all rows satisfying a specific condition. The condition may be a specific instance combination for a MIB variable or a MIB variable OID entry object.
 String var[] = {"sysDescr"} ;
 SnmpVarBindList vblst = new SnmpVarBindList() ;
 vblst.addVarBind(var) ;
 SnmpRequest request = session.snmpWalkUntil(null, vblst, new SnmpOid("sysServices")) ;
 
This example walks through the system group and gets all the variables in this group.
 SnmpRequest request = session.snmpWalkUntil(null, vblst, new SnmpOid("1.4")) ;
 
This example walks through the entire agent MIB starting at sysDescr.
 String var[] = {"sysDescr.0"} ;
 SnmpVarBindList vblst = new SnmpVarBindList() ;
 vblst.addVarBind(var) ;
 SnmpRequest request = session.snmpWalkUntil(null, vblst, new SnmpOid("sysServices.0")) ;
 
This example walks through the system group beginning after the sysDescr variable (not included) and ending with the sysServices variable (included).

If there is more than one variable in the specified variable binding list, the request will start at the first variable of the list.

The snmpWalkUntil request can be called in asynchronous mode only.

Parameters:
peer - The peer object to talk to.
cb - The callback that is invoked when the request completes.
vblst - A list of SnmpVarBind objects.
key - Condition key that must be a subset of the first variable in the response variable binding list. Walk terminates if this condition is false.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If peer parameter is null and no default peer has been set.

snmpWalkUntilRequest

public final SnmpRequest snmpWalkUntilRequest(SnmpRequestHandler cb,
                                              SnmpVarBindList vblst,
                                              SnmpOid key)
                                       throws SnmpStatusException
Walks through the lexicographic ordering of the agent MIB. Uses the default peer.

The snmpWalkUntil request can be called in asynchronous mode only.

Parameters:
cb - The callback that is invoked when the request completes.
vblst - A list of SnmpVarBind objects.
key - Condition key that must be a subset of the first variable in the response variable binding list. Walk terminates if this condition is false.
Throws:
SnmpStatusException - An error occurred during the operation.
IllegalArgumentException - If no default peer has been set.

anyPendingResponses

public boolean anyPendingResponses()
Indicates whether there are any responses available for processing. These responses belong to the requests made using this session.

Returns:
true if a response is available, false otherwise.

run

public void run()
Dispatcher method for this session thread. This is the dispatcher method which goes in an endless-loop and waits for servicing requests which received a reply from the agent.

Specified by:
run in interface Runnable

finalize

public void finalize()
Finalizer of the SnmpSession objects. This method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Removes all the requests for this SNMP session, closes the socket and sets all the references to the SnmpSession object to null.

Overrides:
finalize in class Object

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.