|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jaw.snmp.manager.Request | +--com.sun.jaw.snmp.manager.SnmpRequest
This class creates a request that is used to perform one or more
SNMP operations such as Get
, GetNext
,
Set
, and GetBulk
on a specified
SnmpVarbindList
.
This class provides basic functions that enable you to fire requests, handle retrys, timeouts, and process responses from the agent. It then notifies the user upon completion of requests by invoking the callback interface implementation provided by the user.
The periodic polling functionality is implemented by SnmpPollRequest
which inherits the functionalities of this class and fires the
requests periodically.
An SnmpRequest
can be created by the session object using
one of the many convenience methods as stated in the
SnmpManagerSrvIf
interface class.
The peer object determines the destination of the request and controls
what and how many SnmpVarbindList
s to pack into a single request.
For example, the protocol data units (PDU) packet size, the number of
SnmpVarbindList
s allowed in a packet, the peer address and port,
the SnmpParameters
and probably some flow control mechanism.
The session object provides resources such as which socket to use, the authentication mechanism, controlling all requests created by it, and finally the response to the user.
Each request can be configured with various options that influence
how a request handles a correctable error situation.
For example, SnmpTooBig
error and snmpRspNoSuchName
exception in SNMPv1 context.
Each request when ready to be sent, is assigned a unique identifier which help in identifying the request with matching responses to the protocol engine lying transparently underneath. The engine does the job of retrying the requests when the timer expires and calls the session when a timeout occurs after exhausting the retry counts.
When a user submits a request, it joins the pool of waiting requests
waiting to be sent. When the request becomes ready to be sent,
the underlying engine constructs a PDU packet and sends it out after
starting the wait timer. The SnmpVarbindList
, with a request can get
multiplexed with a SnmpVarbindList
of other requests (passing multiplexing
rules). The responses will be de-multiplexed.
The multiplex operation remains transparent to the user. A user
can choose to disallow such multiplexing of certain specific requests
by providing the options when the request is created. This may
become necessary to optimize performance of certain requests.
An application can cancel one or more request at any time.
The request that are sent are automatically retried if a response does not arrive within a specified interval. If the agent responds with an error, the request object uses the options to determine what should be done.
The request object provides the method, waitForCompletion(long time)
,
which enables a user to operate in a synchronous mode with a request.
This is done by blocking the user thread for the desired time interval.
The user thread gets notified whenever a request reaches completion
independent of the status of response. If the user blocks on the
session thread context an exception is thrown (you should not
block the session thread).
A request becomes active when a user submits the request successfully. When any event happens that moves the request to the done state, the request becomes inactive. At any time, one or more requests active in a session can be cancelled.
SnmpSession
,
SnmpVar
,
SnmpVarbindList
,
SnmpParameters
,
SnmpPeer
, Serialized FormField Summary | |
protected SnmpHandlerIf |
callback
The user implementation of the callback interface for this session. |
protected int |
errorIndex
The index in SnmpVarbindList that caused the exception. |
protected int |
errorStatus
The error status associated with the response packet. |
protected int |
maxRepetitions
The maxRepetitions field for the bulk operation. |
protected int |
nonRepeaters
The nonRepeaters field for the bulk operation. |
protected SnmpSession |
session
The session object associated with this request. |
protected SnmpPeer |
thePeer
The peer object associated with this request. |
protected SnmpVarbindList |
varbindList
This contains a list of SnmpVar objects for making
the SNMP requests. |
Fields inherited from class com.sun.jaw.snmp.manager.Request |
retry,
stAborted,
stBase,
stInProgress,
stInternalError,
stNeverUsed,
stReceivedReply,
stResultsAvailable,
stTimeout,
stWaitingForReply,
stWaitingToSend,
timeout |
Method Summary | |
boolean |
allowMultiplex()
Checks to see if this request can be multiplexed with other requests. |
void |
cancelRequest()
Cancels the active request and removes itself from polling list. |
void |
finalize()
Sets all the references to the SnmpRequest
object to null . |
boolean |
fixPduOnError()
Returns true if the PDU should be fixed for recoverable error. |
boolean |
fixTooBigError()
Returns true if request should be retried for SnmpTooBig error. |
int |
getCommand()
Gets the SNMP command for this request. |
int |
getErrorIndex()
Gets the index. |
int |
getErrorStatus()
Gets the status associated with the SnmpVarbindList . |
int |
getMaxRetry()
Gets the maximum number of retries before declaring that the peer is not responding. |
int |
getOptions()
Gets the options set for this request. |
SnmpParameters |
getParam()
Gets the session parameter object for this request. |
SnmpPeer |
getPeer()
Gets the peer object for this request. |
SnmpVarbindList |
getRequestVbList()
Gets the active SnmpVarbindList . |
SnmpVarbindList |
getResponseVbList()
Gets the SnmpVarbindList that is the response obtained when
an agent is queried. |
SnmpSession |
getSnmpSession()
Gets the session object for this request. |
boolean |
isInternalRequest()
Indicates if this request was created internally by the package to handle error conditions. |
void |
notifyClient()
Notifies the registered client about the completion of an operation. |
void |
setOptions(int opt)
Allows the user to configure the behavior of the request when certain errors occur, such as SnmpTooBig and
optFixPduOnError . |
static java.lang.String |
snmpErrorToString(int errcode)
Returns the string representation of an error code. |
java.lang.String |
toString()
Gives a status report of the request. |
boolean |
waitForCompletion(long time)
Used in synchronous mode only. |
Methods inherited from class com.sun.jaw.snmp.manager.Request |
getAbsMaxTimeToWait,
getAbsNextPollTime,
getPollTimestamp,
getRequestId,
getRequestStatus,
getRetryCount,
initNewRequest,
inProgress,
isAborted,
isResultAvailable |
Methods inherited from class java.lang.Object |
clone,
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected SnmpVarbindList varbindList
SnmpVar
objects for making
the SNMP requests. A private copy of the user specified
SnmpVarbindList
is made by cloning the
SnmpVarbindList
to ensure that the user does not modify the
SnmpVarbindList
or the contents while the polling is in progress.SnmpVarbindList
protected int errorStatus
protected int errorIndex
SnmpVarbindList
that caused the exception.protected SnmpPeer thePeer
protected SnmpSession session
protected SnmpHandlerIf callback
SnmpHandlerIf
protected int nonRepeaters
nonRepeaters
field for the bulk
operation.
This variable is used only for pduGetBulkRequestPdu
.protected int maxRepetitions
maxRepetitions
field for the bulk
operation.
This variable is used only for pduGetBulkRequestPdu
.Method Detail |
public final SnmpSession getSnmpSession()
public final SnmpPeer getPeer()
public final SnmpParameters getParam()
public final int getCommand()
public final boolean waitForCompletion(long time) throws SnmpStatusException
time
- The amount of time to wait. Zero means block until complete.public final boolean allowMultiplex()
SnmpSet
requests cannot be multiplexed.
An already multiplexed request cannot be further multiplexed.public java.lang.String toString()
public final int getErrorStatus()
SnmpVarbindList
.public final int getErrorIndex()
NOTE: this value is equals to the errorIndex field minus 1.
public final int getMaxRetry()
SnmpSet
operations are never retried.public final void setOptions(int opt)
SnmpTooBig
and
optFixPduOnError
. When carefully chosen, these can
improve or degrade performance.
This method can be set only when a request is inactive.opt
- The option as an integer.public final int getOptions()
public boolean fixTooBigError()
SnmpTooBig
error.SnmpTooBig
error;
false otherwise.public boolean fixPduOnError()
public final SnmpVarbindList getResponseVbList()
SnmpVarbindList
that is the response obtained when
an agent is queried. It returns null value if the request is
in progress. This ensures accidental manipulation does not occur when
a request is progress. In case of any error, SnmpVarbindList
is the copy
of the original SnmpVarbindList
at the time of making request.SnmpVarbindList
returned by the agent or the null value if request
is in progress.public final SnmpVarbindList getRequestVbList()
SnmpVarbindList
. The contents of it
are not guaranteed to be constant when request is active. It is
dangerous to modify when request is active.SnmpVarbindList
when the request was fired.public final void cancelRequest()
public boolean isInternalRequest()
public final void notifyClient()
public void finalize()
SnmpRequest
object to null
.public static java.lang.String snmpErrorToString(int errcode)
errcode
- The error code as an integer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |