All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.sun.jaw.snmp.manager.SnmpSession
SnmpSession object essentially creates, controls, and manages
one or more request. A session can be bound to a peer so that all
requests created (without specifying a peer) will use this as the default.
Alternately, there can be a mixture of peers, that is two requests can talk to
two different peers.
Each SnmpSession has a dispatcher that is a thread used to service
all the requests it creates. It also uses a socket which defaults
to a default SnmpSocket. If desired, the session can be configured to
exclusively use a seperate socket. By default, all sessions use the
same default socket unless explicitly configured.
See SnmpSocket for additional information.
This class implements SNMP commands interface which provides a variety of convenience methods that are used to create requests. Each of the requests perform specific SNMP operation. These methods are simple to use and automatically start the request. The session maintains the list of all active request and responses.
Users can explicitly create and start the requests. This is usually not required for most applications.
Each such method provides specific SNMP operation 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 retry limit. Certain options
of sessions can be configured using the SnmpOptions object.
This allow enabling and disabling features like fixing protocol data units (PDU)
on error, handling SnmpTooBig errors and multiplexing requests.
Once a session is created the user can perform one or more SNMP operation
in a one-at-a-time sequence. Usually such a sequence is a set of logical
operations which together form a complete operation.
For example, a SnmpSet operation, which involves a 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 cancelled.
SnmpRequests created
in this session.
SnmpSession
object to null.
SnmpSocket which will be used by requests
created in this session.
get request on the varbind list.
get request on the varbind list.
getbulk request on the varbind list.
getbulk request on the varbind list.
getnext request on the varbind list.
getnext request on the varbind list.
varbind list.
varbind list.
varbind list.
varbind list.
set request on the peer for the
specified varbind list.
set request on the peer for the
specified varbind list.
public String sessionName
public SnmpOptions snmpOptions
SnmpRequests created
in this session. The user can directly manipulate the options.
Note that this variable is public.
public SnmpSession(String name,
SnmpPeer apeer,
SnmpAuthHandlerIf auth)
public SnmpSession(String name,
SnmpAuthHandlerIf auth)
public SnmpSession(String name)
public final String getName()
public final void setName(String name)
public final void setDefaultPeer(SnmpPeer apeer)
public final SnmpPeer getDefaultPeer()
public final String toString()
public final SnmpSocket getSocket()
SnmpSocket which will be used by requests
created in this session.
public final synchronized void useExclusiveSocket(SnmpSocket sock)
public final synchronized void useExclusiveSocket() throws SocketException
public final synchronized boolean isEquivalent(SnmpSession arg)
this with.
public final synchronized boolean isSessionActive()
public synchronized boolean syncInProgress()
public final synchronized void destroySession()
public synchronized Vector getAllRequestsForPeer(SnmpPeer apeer)
SnmpPeer.
public final synchronized void cancelAllRequests()
public boolean checkResponseFor(Request req)
public boolean thisSessionContext()
public final SnmpRequest snmpGet(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
get request on the varbind list.
When the command completes, the appropriate callback method is invoked.
varbinds.
public final SnmpRequest snmpGet(SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
get request on the varbind list.
Uses the default peer.
varbinds.
public final SnmpRequest snmpGetNext(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
getnext request on the varbind list.
When the command completes, the appropriate callback method is invoked.
varbinds.
public final SnmpRequest snmpGetNext(SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
getnext request on the varbind list.
Uses the default peer.
varbinds.
public final SnmpRequest snmpGetBulk(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst,
int nonRepeat,
int maxRepeat) throws SnmpStatusException
getbulk request on the varbind list.
When the command completes, the appropriate callback method is invoked.
varbinds.
varbind to get one time.
varbind to get multiple time.
public final SnmpRequest snmpGetBulk(SnmpHandlerIf cb,
SnmpVarbindList vblst,
int nonRepeat,
int maxRepeat) throws SnmpStatusException
getbulk request on the varbind list.
Uses the default peer.
varbinds.
varbind to get one time.
varbind to get multiple time.
public final SnmpRequest snmpSet(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
set request on the peer for the
specified varbind list. Because retries on set
operations are not performed, the user needs to specify the timeout value
within which a response is requested.
varbinds.
public final SnmpRequest snmpSet(SnmpHandlerIf cb,
SnmpVarbindList vblst) throws SnmpStatusException
set request on the peer for the
specified varbind list.
Uses the default peer.
varbinds.
public final SnmpRequest snmpGetPoll(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst,
int intrvl) throws SnmpStatusException
varbind list.
It does a SNMP get request on the varbind list.
After each poll, the appropriate callback method is invoked.
varbinds.
public final SnmpRequest snmpGetPoll(SnmpHandlerIf cb,
SnmpVarbindList vblst,
int intrvl) throws SnmpStatusException
varbind list.
Uses the default peer.
varbinds.
public final SnmpRequest snmpGetNextPoll(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst,
int intrvl) throws SnmpStatusException
varbind list.
It saves the original varbind list that is used during each poll.
It performs an SNMP getnext request on the saved original
varbind 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 varbind list instead of
get.
varbinds.
public final SnmpRequest snmpGetNextPoll(SnmpHandlerIf cb,
SnmpVarbindList vblst,
int intrvl) throws SnmpStatusException
varbind list.
Uses the default peer.
varbinds.
public final SnmpRequest snmpWalkUntil(SnmpPeer peer,
SnmpHandlerIf cb,
SnmpVarbindList vblst,
SnmpOid key) throws SnmpStatusException
varbind list and continues until the OID key
specified as a parameter is "smaller" than the first variable in the
response varbind list or an error occurred.
Typically, this feature is used to walk 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.addVariable(var) ;
SnmpRequest request = session.snmpWalkUntil(null, vblst, new SnmpOid("sysServices")) ;
This example walks through the system group and get 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.addVariable(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 varbind list,
the request will start at the first variable of the list.
SnmpVarbindList.
SnmpVarbindList. Walk terminates if this condition is false.
public final SnmpRequest snmpWalkUntil(SnmpHandlerIf cb,
SnmpVarbindList vblst,
SnmpOid key) throws SnmpStatusException
SnmpVarbindList.
SnmpVarbindList. Walk terminates if this condition is false.
public boolean anyPendingResponses()
public void run()
public void finalize()
SnmpSession
object to null.
All Packages Class Hierarchy This Package Previous Next Index