com.sun.management.comm
Class SnmpInformRequest

java.lang.Object
  extended by com.sun.management.comm.SnmpInformRequest
All Implemented Interfaces:
SnmpDefinitions
Direct Known Subclasses:
SnmpV3InformRequest

public class SnmpInformRequest
extends Object
implements SnmpDefinitions

This class is used by the SNMP adaptor server to send inform requests to an SNMP manager and receive inform responses.

This class provides basic functions that enable you to fire inform requests, handle retries, timeouts, and process responses from the manager.
The SNMP adaptor server specifies the destination of the inform request and controls the size of a single inform request/response to fit into its bufferSize. It specifies the maximum number of tries and the timeout to be used for the inform requests. It also provides resources such as the authentication mechanism (using its PDU factory), controlling all inform requests created by it, and finally the inform response to the user.

Each inform request, when ready to be sent, is assigned a unique identifier which helps in identifying the inform request with matching inform responses to the protocol engine lying transparently underneath. The engine does the job of retrying the inform requests when the timer expires and calls the SNMP adaptor server when a timeout occurs after exhausting the maximum number of tries.

The inform request object provides the method, waitForCompletion(long time), which enables a user to operate in a synchronous mode with an inform 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 an inform callback is provided when sending the inform request, the user operates in an asynchronous mode with the inform request. The user thread is not blocked and the specific inform callback implementation provided by the user is invoked when the inform response is received.

Note:
From RFC 1905, the SNMP inform request is defined as a request generated and transmitted by an SNMPv2 entity acting in a manager role to another SNMPv2 entity also acting in a manager role. The mechanisms to implement this behavior are defined in the SNMP manager API.
Nevertheless, this feature has derived and in some documentations, the inform request appears like an SNMPv2 trap that gets responded.
The SnmpInformRequest class is used to fulfill this latter case.

Since:
Java DMK 5.1

Field Summary
static int stAborted
          Status of an inform request: request aborted.
static int stInProgress
          Status of an inform request: in progress.
static int stInternalError
          Status of an inform request: internal error occurred.
static int stNeverUsed
          Status of an inform request: request never used.
static int stReceivedReply
          Status of an inform request: reply received.
static int stResultsAvailable
          Status of an inform request: result available for the request.
static int stTimeout
          Status of an inform request: timeout.
static int stWaitingForReply
          Status of an inform request: waiting for reply.
static int stWaitingToSend
          Status of an inform request: waiting to be sent.
 
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
 
Method Summary
 void cancelRequest()
          Cancels the active inform request and removes itself from the polling list.
 void finalize()
          Finalizer of the SnmpInformRequest objects.
 long getAbsMaxTimeToWait()
          Gets absolute time in milliseconds (based on epoch time) before which an inform response is expected from a manager.
 long getAbsNextPollTime()
          Gets absolute time in milliseconds (based on epoch time) when the next polling activity will begin.
 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 manager is not responding.
 int getNumTries()
          Gets the number of tries performed for the current inform request.
 int getRequestId()
          Gets the request id (invoke identifier) of the current inform request.
 int getRequestStatus()
          Gets the current status of the inform request.
 SnmpVarBindList getResponseVarBindList()
          Gets the SnmpVarBindList of the inform response.
 boolean inProgress()
          Indicates whether or not the inform request is in progress.
 boolean isAborted()
          Indicates whether or not the inform request was aborted.
 boolean isResultAvailable()
          Indicates whether or not the inform request result is available.
 void notifyClient()
          Notifies the registered client about the completion of an operation.
static String snmpErrorToString(int errcode)
          Returns the String representation of an error code.
 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, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stInProgress

public static final int stInProgress
Status of an inform request: in progress.

See Also:
Constant Field Values

stWaitingToSend

public static final int stWaitingToSend
Status of an inform request: waiting to be sent.

See Also:
Constant Field Values

stWaitingForReply

public static final int stWaitingForReply
Status of an inform request: waiting for reply.

See Also:
Constant Field Values

stReceivedReply

public static final int stReceivedReply
Status of an inform request: reply received.

See Also:
Constant Field Values

stAborted

public static final int stAborted
Status of an inform request: request aborted.

See Also:
Constant Field Values

stTimeout

public static final int stTimeout
Status of an inform request: timeout.

See Also:
Constant Field Values

stInternalError

public static final int stInternalError
Status of an inform request: internal error occurred.

See Also:
Constant Field Values

stResultsAvailable

public static final int stResultsAvailable
Status of an inform request: result available for the request.

See Also:
Constant Field Values

stNeverUsed

public static final int stNeverUsed
Status of an inform request: request never used.

See Also:
Constant Field Values
Method Detail

getRequestId

public final int getRequestId()
Gets the request id (invoke identifier) of the current inform request.

Returns:
The request id.

getRequestStatus

public final int getRequestStatus()
Gets the current status of the inform request.

Returns:
The current status of the inform request.

isAborted

public final boolean isAborted()
Indicates whether or not the inform request was aborted.

Returns:
true if the inform request was aborted, false otherwise.

inProgress

public final boolean inProgress()
Indicates whether or not the inform request is in progress.

Returns:
true if the inform request is in progress, false otherwise.

isResultAvailable

public final boolean isResultAvailable()
Indicates whether or not the inform request result is available.

Returns:
true if the inform request result is available, false otherwise.

getErrorStatus

public final int getErrorStatus()
Gets the status associated with the SnmpVarBindList.

Returns:
The error status.

getErrorIndex

public final int getErrorIndex()
Gets the index.

NOTE: this value is equal to the errorIndex field minus 1.

Returns:
The error index.

getMaxTries

public final int getMaxTries()
Gets the maximum number of tries before declaring that the manager is not responding.

Returns:
The maximum number of times an inform request should be tried.

getNumTries

public final int getNumTries()
Gets the number of tries performed for the current inform request.

Returns:
The number of tries performed.

getAbsNextPollTime

public final long getAbsNextPollTime()
Gets absolute time in milliseconds (based on epoch time) when the next polling activity will begin.

Returns:
The absolute time when polling will begin.

getAbsMaxTimeToWait

public final long getAbsMaxTimeToWait()
Gets absolute time in milliseconds (based on epoch time) before which an inform response is expected from a manager.

Returns:
The absolute time within which an inform response is expected.

getResponseVarBindList

public final SnmpVarBindList getResponseVarBindList()
Gets the SnmpVarBindList of the inform response. It returns a null value if the inform 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 inform request.

Returns:
The list of SnmpVarBind objects returned by the manager or the null value if the request is in progress.

waitForCompletion

public final boolean waitForCompletion(long time)
Used in synchronous mode only. Provides a hook that enables a synchronous operation on a previously sent inform request. Only one inform request can be in synchronous mode on a given thread. The blocked thread is notified when the inform request state reaches completion. If the inform request is not active, the method returns immediately. The user must get the error status of the inform request to determine the exact status of the request.

Parameters:
time - The amount of time to wait. Zero means block until complete.
Returns:
true if the inform request has completed, false if it is still active.

cancelRequest

public final void cancelRequest()
Cancels the active inform request and removes itself from the polling list.


notifyClient

public final void notifyClient()
Notifies the registered client about the completion of an operation.


finalize

public void finalize()
Finalizer of the SnmpInformRequest 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.

Sets all the references to this SNMP inform request object to null.

Overrides:
finalize in class Object

snmpErrorToString

public static String snmpErrorToString(int errcode)
Returns the String representation of an error code.

Parameters:
errcode - The error code as an integer.
Returns:
The error code as a String.

toString

public String toString()
Gives a status report of the request.

Overrides:
toString in class Object
Returns:
The status report of the request.

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.