Module org.snmp4j.agent
Package org.snmp4j.agent.request
Class AbstractRequest<U extends SubRequest<U>,S,R>
- java.lang.Object
-
- org.snmp4j.agent.request.AbstractRequest<U,S,R>
-
- All Implemented Interfaces:
Request<S,R,U>
- Direct Known Subclasses:
SnmpRequest
public abstract class AbstractRequest<U extends SubRequest<U>,S,R> extends Object implements Request<S,R,U>
TheAbstractRequestimplements common elements of SNMP and AgentX requests and might be also used for other sub-agent request types.- Version:
- 3.1.0
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description protected interrorStatusprotected intphaseprotected intrepeaterRowSizeprotected intrepeaterStartIndexprotected intreprocessCounterprotected Rresponseprotected Ssourceprotected List<U>subrequestsprotected inttransactionID-
Fields inherited from interface org.snmp4j.agent.request.Request
PHASE_1PC, PHASE_2PC_CLEANUP, PHASE_2PC_COMMIT, PHASE_2PC_PREPARE, PHASE_2PC_UNDO, PHASE_INIT
-
-
Constructor Summary
Constructors Constructor Description AbstractRequest(S source)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Ufind(org.snmp4j.smi.OID prefix)Finds the first sub-request whose OID starts with the supplied one.Uget(int index)Gets the sub-request at the specified index.intgetErrorIndex()intgetErrorStatus()protected abstract intgetMaxPhase()intgetPhase()Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.intgetReprocessCounter()Returns the value of the reprocessing counter associated with this request.RgetResponse()Returns the response object for this request.SgetSource()Returns the initiating event object for the request.intgetTransactionID()inthashCode()voidincReprocessCounter()Increments the reprocess counter by one.protected voidinitSubRequests()abstract booleanisBulkRequest()booleanisComplete()Checks whether the response for this request is complete.intnextPhase()Initializes next phase and returns its identifier.protected voidresetCompletionStatus()voidresetProcessedStatus()Set the processed status of each (incomplete) sub-request tofalse.voidsetErrorStatus(int errorStatus)voidsetPhase(int phase)Sets the request phase.protected abstract voidsetupSubRequests()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.snmp4j.agent.request.Request
getContext, getMessageProcessingModel, getProcessingUserObject, getSecurityLevel, getSecurityModel, getSecurityName, getViewName, getViewType, isPhaseComplete, iterator, setProcessingUserObject, setViewName, size
-
-
-
-
Field Detail
-
subrequests
protected List<U extends SubRequest<U>> subrequests
-
source
protected S source
-
response
protected R response
-
phase
protected int phase
-
errorStatus
protected int errorStatus
-
repeaterStartIndex
protected int repeaterStartIndex
-
repeaterRowSize
protected int repeaterRowSize
-
reprocessCounter
protected int reprocessCounter
-
transactionID
protected int transactionID
-
-
Constructor Detail
-
AbstractRequest
public AbstractRequest(S source)
-
-
Method Detail
-
getSource
public S getSource()
Description copied from interface:RequestReturns the initiating event object for the request.
-
getResponse
public R getResponse()
Description copied from interface:RequestReturns the response object for this request.- Specified by:
getResponsein interfaceRequest<U extends SubRequest<U>,S,R>- Returns:
- an object containing the response for this request.
-
isBulkRequest
public abstract boolean isBulkRequest()
-
find
public U find(org.snmp4j.smi.OID prefix)
Description copied from interface:RequestFinds the first sub-request whose OID starts with the supplied one.
-
initSubRequests
protected void initSubRequests()
-
setupSubRequests
protected abstract void setupSubRequests()
-
getMaxPhase
protected abstract int getMaxPhase()
-
nextPhase
public int nextPhase()
Description copied from interface:RequestInitializes next phase and returns its identifier.
-
isComplete
public boolean isComplete()
Description copied from interface:RequestChecks whether the response for this request is complete.- Specified by:
isCompletein interfaceRequest<U extends SubRequest<U>,S,R>- Returns:
trueif all required data has been collected to create a response for this request,falseotherwise.
-
get
public U get(int index)
Description copied from interface:RequestGets the sub-request at the specified index.
-
getPhase
public int getPhase()
Description copied from interface:RequestGets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.
-
getErrorIndex
public int getErrorIndex()
- Specified by:
getErrorIndexin interfaceRequest<U extends SubRequest<U>,S,R>
-
getErrorStatus
public int getErrorStatus()
- Specified by:
getErrorStatusin interfaceRequest<U extends SubRequest<U>,S,R>
-
getTransactionID
public int getTransactionID()
- Specified by:
getTransactionIDin interfaceRequest<U extends SubRequest<U>,S,R>
-
setPhase
public void setPhase(int phase) throws NoSuchElementExceptionDescription copied from interface:RequestSets the request phase.- Specified by:
setPhasein interfaceRequest<U extends SubRequest<U>,S,R>- Parameters:
phase- a phase identifier.- Throws:
NoSuchElementException- if there is no such phase for this type of request.
-
resetCompletionStatus
protected void resetCompletionStatus()
-
resetProcessedStatus
public void resetProcessedStatus()
Description copied from interface:RequestSet the processed status of each (incomplete) sub-request tofalse.- Specified by:
resetProcessedStatusin interfaceRequest<U extends SubRequest<U>,S,R>
-
setErrorStatus
public void setErrorStatus(int errorStatus)
- Specified by:
setErrorStatusin interfaceRequest<U extends SubRequest<U>,S,R>
-
getReprocessCounter
public int getReprocessCounter()
Description copied from interface:RequestReturns 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.- Specified by:
getReprocessCounterin interfaceRequest<U extends SubRequest<U>,S,R>- Returns:
- 0 after the initial (and normally last) processing iteration and
nafter then-th reprocessing iteration. - See Also:
Request.incReprocessCounter()
-
incReprocessCounter
public void incReprocessCounter()
Description copied from interface:RequestIncrements the reprocess counter by one.- Specified by:
incReprocessCounterin interfaceRequest<U extends SubRequest<U>,S,R>- See Also:
Request.getReprocessCounter()
-
-