Module org.snmp4j.agent
Package org.snmp4j.agent.request
Interface Request<S,R,U extends SubRequest<U>>
- Type Parameters:
S- source object that trigger theRequestcreation.R- the response object returned by thisRequest.U- theSubRequestsub-type used to process this request.
- All Known Implementing Classes:
AbstractRequest,SnmpRequest
public interface Request<S,R,U extends SubRequest<U>>
The
Request interface defines common elements of SNMP related
operation requests.- Version:
- 1.2
- Author:
- Frank Fock
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionfind(org.snmp4j.smi.OID prefix) Finds the first sub-request whose OID starts with the supplied one.get(int index) Gets the sub-request at the specified index.org.snmp4j.smi.OctetStringGets the context of the request.intintintintgetPhase()Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.Gets the processing user object for the specified key.intReturns the value of the reprocessing counter associated with this request.Returns the response object for this request.intintorg.snmp4j.smi.OctetStringReturns the initiating event object for the request.intorg.snmp4j.smi.OctetStringintvoidIncrements the reprocess counter by one.booleanChecks whether the response for this request is complete.booleanChecks whether the current phase is complete.iterator()Returns anIteratorover the sub-requests of this request.intInitializes next phase and returns its identifier.voidSet the processed status of each (incomplete) sub-request tofalse.voidsetErrorStatus(int errorStatus) voidsetPhase(int phase) Sets the request phase.setProcessingUserObject(Object key, Object value) Sets an user object association.voidsetViewName(org.snmp4j.smi.OctetString viewName) intsize()Gets the number of sub-requests in this request.
-
Field Details
-
PHASE_INIT
static final int PHASE_INIT- See Also:
-
PHASE_1PC
static final int PHASE_1PC- See Also:
-
PHASE_2PC_PREPARE
static final int PHASE_2PC_PREPARE- See Also:
-
PHASE_2PC_COMMIT
static final int PHASE_2PC_COMMIT- See Also:
-
PHASE_2PC_UNDO
static final int PHASE_2PC_UNDO- See Also:
-
PHASE_2PC_CLEANUP
static final int PHASE_2PC_CLEANUP- See Also:
-
-
Method Details
-
find
Finds the first sub-request whose OID starts with the supplied one.- Parameters:
prefix- the OID prefix of the sub-request OID.- Returns:
- the first
SubRequestinstance of this request whose OID starts withprefix. If no such sub-request exitsnullis returned.
-
getResponse
R getResponse()Returns the response object for this request.- Returns:
- an object containing the response for this request.
-
isComplete
boolean isComplete()Checks whether the response for this request is complete.- Returns:
trueif all required data has been collected to create a response for this request,falseotherwise.
-
isPhaseComplete
boolean isPhaseComplete()Checks whether the current phase is complete.- Returns:
trueif all required processing has been finished for the current request phase. For single phase request types this method returns the same result asisComplete().
-
getSource
S getSource()Returns the initiating event object for the request.- Returns:
- an
Objectinstance on whose behalf this request has been initiated.
-
getContext
org.snmp4j.smi.OctetString getContext()Gets the context of the request.- Returns:
- an
OctetStringinstance.
-
get
Gets the sub-request at the specified index.- Parameters:
index- an index>= 0 and < size()- Returns:
- a
SnmpSubRequestinstance.
-
size
int size()Gets the number of sub-requests in this request. For GETBULK requests this number may increase over time.- Returns:
- a positive integer (greater or equal to zero).
-
getPhase
int getPhase()Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.- Returns:
- a 2PC identifier
-
nextPhase
Initializes next phase and returns its identifier.- Returns:
- a phase identifier.
- Throws:
NoSuchElementException- if there is no next phase for this type of request.
-
setPhase
Sets the request phase.- Parameters:
phase- a phase identifier.- Throws:
NoSuchElementException- if there is no such phase for this type of request.
-
iterator
Returns anIteratorover the sub-requests of this request.- Returns:
- an
Iterator
-
setViewName
void setViewName(org.snmp4j.smi.OctetString viewName) -
getViewName
org.snmp4j.smi.OctetString getViewName() -
getSecurityName
org.snmp4j.smi.OctetString getSecurityName() -
getMessageProcessingModel
int getMessageProcessingModel() -
getSecurityModel
int getSecurityModel() -
getSecurityLevel
int getSecurityLevel() -
getViewType
int getViewType() -
setErrorStatus
void setErrorStatus(int errorStatus) -
getErrorStatus
int getErrorStatus() -
getErrorIndex
int getErrorIndex() -
getTransactionID
int getTransactionID() -
resetProcessedStatus
void resetProcessedStatus()Set the processed status of each (incomplete) sub-request tofalse. -
getReprocessCounter
int getReprocessCounter()Returns the value of the reprocessing counter associated with this request. The reprocessing counter can be used to detect and handle endless-loop errors caused by instrumentation code not setting the completion status of a sub-request correctly.- Returns:
- 0 after the initial (and normally last) processing iteration and
nafter then-th reprocessing iteration. - See Also:
-
incReprocessCounter
void incReprocessCounter()Increments the reprocess counter by one.- See Also:
-
getProcessingUserObject
Gets the processing user object for the specified key. By default there is no such object associated with a request, butManagedObjects may put their own objects into the request (for example to avoid unnecessary updates on behalf of the same request).- Parameters:
key- an Object.- Returns:
- the associated Object or
nullif their exists no such association. - Since:
- 1.2
-
setProcessingUserObject
Sets an user object association.- Parameters:
key- a key Object.value- a value Object associated withkey.- Returns:
- the previous value associated with
keyornullif no such association existed. - Since:
- 1.2
-