|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.management.snmp.manager.SnmpRequest
public class SnmpRequest
Creates a request that is used to perform one or more SNMP operations such as
Get
, GetNext
, Set
, Inform
and
GetBulk
on a specified SnmpVarBindList
.
This class provides basic functions that enable you to fire requests, handle retries, 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.
An SnmpRequest
can be created by the session object.
The peer object determines the destination of the request and controls
what and how many SnmpVarBind
s to pack into a single request.
For example, the protocol data units (PDU) packet size, the number of
SnmpVarBind
s allowed in a packet, the peer address and port,
the SnmpParameters
and probably some flow control mechanisms.
The session object provides resources such as 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 the SNMPv1 context.
Each request, when ready to be sent, is assigned a unique identifier which helps 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 maximum number of tries.
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 be multiplexed with an 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 this 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 requests at any time.
The requests 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, independently of the status of the 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 an event happens that moves the request into the done state, the request becomes inactive. At any time, one or more requests active in a session can be canceled.
SnmpSession
,
SnmpPeer
,
Serialized FormField Summary | |
---|---|
static int |
stAborted
Status of a request: request aborted. |
static int |
stInProgress
Status of a request: in progress. |
static int |
stInternalError
Status of a request: internal error occurred. |
static int |
stNeverUsed
Status of a request: request never used. |
static int |
stReceivedReply
Status of a request: reply received. |
static int |
stResultsAvailable
Status of a request: result available for the request. |
static int |
stTimeout
Status of a request: timeout. |
static int |
stWaitingForReply
Status of a request: waiting for reply. |
static int |
stWaitingToSend
Status of a request: waiting to be sent. |
Method Summary | |
---|---|
boolean |
allowMultiplex()
Checks to see whether this request can be multiplexed with other requests. |
void |
cancelRequest()
Cancels the active request and removes itself from the polling list. |
boolean |
fixPduOnError()
Returns true if the PDU should be fixed for recoverable error. |
boolean |
fixTooBigError()
Returns true if the request should be retried for SnmpTooBig error. |
long |
getAbsMaxTimeToWait()
Gets absolute time in milliseconds (based on epoch time) before which a response is expected from an agent. |
long |
getAbsNextPollTime()
Gets absolute time in milliseconds (based on epoch time) when the next polling activity will begin. |
int |
getCommand()
Gets the SNMP command for this request. |
int |
getErrorIndex()
Gets the index. |
int |
getErrorStatus()
Gets the status associated with the SnmpVarBindList . |
int |
getMaxTries()
Gets the maximum number of tries before declaring that the peer is not responding. |
int |
getNumTries()
Gets the number of tries performed for the current request. |
int |
getOptions()
Gets the options set for this request. |
SnmpParams |
getParams()
Gets the session parameter object for this request. |
SnmpPeer |
getPeer()
Gets the peer object for this request. |
long |
getPollTimestamp()
Gets the absolute time (based on epoch time) when the poll started. |
SnmpVarBindList |
getReportVarBindList()
Gets the report SnmpVarBindList . |
int |
getRequestId()
Gets the request id (invoke identifier) of the current request. |
int |
getRequestStatus()
Gets the current status of the request. |
SnmpVarBindList |
getRequestVarBindList()
Gets the active SnmpVarBindList . |
SnmpSecurityParameters |
getResponseSecurityParameters()
Gets the response security parameters info (e.g. |
SnmpVarBindList |
getResponseVarBindList()
Gets the SnmpVarBindList that is the response obtained when an agent is queried. |
SnmpSession |
getSnmpSession()
Gets the session object for this request. |
boolean |
inProgress()
Indicates whether or not the request is in progress. |
boolean |
isAborted()
Indicates whether or not the request was aborted. |
boolean |
isInternalRequest()
Indicates whether this request was created internally by the package to handle error conditions. |
boolean |
isReport()
Test if the received reply is an SNMP report. |
boolean |
isResponse()
Test if the received reply is an SNMP response. |
boolean |
isResultAvailable()
Indicates whether or not the request result is available. |
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 String |
snmpErrorToString(int errcode)
Returns the String representation of an error code. |
static String |
statusDescription(int state)
Returns the string state corresponding to the specified integer state. |
String |
toString()
Gives a status report of the request. |
boolean |
waitForCompletion(long time)
Used in synchronous mode only. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int stInProgress
public static final int stWaitingToSend
public static final int stWaitingForReply
public static final int stReceivedReply
public static final int stAborted
public static final int stTimeout
public static final int stInternalError
public static final int stResultsAvailable
public static final int stNeverUsed
Method Detail |
---|
public final int getNumTries()
public final int getRequestId()
public final int getRequestStatus()
public final boolean isAborted()
true
if the request was aborted, false
otherwise.public final boolean inProgress()
true
if the request is in progress, false
otherwise.public final boolean isResultAvailable()
true
if the request result is available, false
otherwise.public final long getAbsNextPollTime()
public final long getAbsMaxTimeToWait()
public final long getPollTimestamp()
public final SnmpSession getSnmpSession()
public final SnmpPeer getPeer()
public final SnmpParams getParams()
public final int getCommand()
public final int getErrorStatus()
SnmpVarBindList
.
public final int getErrorIndex()
NOTE: this value is equal to the errorIndex
field minus 1.
public final int getMaxTries()
SnmpSet
operations are never retried.
public final int getOptions()
public final void setOptions(int opt)
SnmpTooBig
and optFixPduOnError
.
These should be carefully chosen, as they can improve or degrade performance.
This method can only be set when a request is inactive.
opt
- The option as an integer.public final SnmpVarBindList getRequestVarBindList()
SnmpVarBindList
. The contents of it are not guaranteed
to be consistent when the request is active. It is dangerous to modify when the request is active.
SnmpVarBindList
when the request was fired.public final SnmpVarBindList getReportVarBindList()
SnmpVarBindList
. The contents of it are not guaranteed
to be consistent when the request is active. It should be called if isReport()
is true.
SnmpVarBindList
received in the report.public final SnmpVarBindList getResponseVarBindList()
SnmpVarBindList
that is the response obtained when an agent is queried.
It returns a null value if the request is in progress.
This ensures accidental manipulation does not occur when a request is in progress.
In case of an error, SnmpVarBindList
is the copy of the original SnmpVarBindList
at the time of making the request.
SnmpVarBindList
returned by the agent or the null value if the request
is in progress.public boolean fixTooBigError()
true
if the request should be retried for SnmpTooBig
error.
true
if the request should be retried for SnmpTooBig
error,
false
otherwise.public boolean fixPduOnError()
true
if the PDU should be fixed for recoverable error.
true
if PDU should be fixed for recoverable error,
false
otherwise.public final boolean allowMultiplex()
SnmpSet
requests cannot be multiplexed.
A request already multiplexed cannot be further multiplexed.
true
if the request is allowed to be multiplexed, false
otherwise.public boolean isInternalRequest()
true
if this request was created internally, false
otherwise.public final boolean waitForCompletion(long time) throws SnmpStatusException
time
- The amount of time to wait. Zero means block until complete.
true
if the request has completed, false
if it is still active.
SnmpStatusException
- An error occurred while accessing a MIB node.public final void cancelRequest()
public final void notifyClient()
public String toString()
toString
in class Object
public static String snmpErrorToString(int errcode)
String
representation of an error code.
errcode
- The error code as an integer.
String
.public boolean isReport()
true
if a report is received, false
otherwise.public boolean isResponse()
true
if a response is received, false
otherwise.public final SnmpSecurityParameters getResponseSecurityParameters()
SnmpUsmPeer
at discovery time).
public static final String statusDescription(int state)
state
- The integer state.
|
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 |