Package org.snmp4j.agent.request
Class AbstractRequest<U extends SubRequest,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,S,R>
extends Object
implements Request<S,R,U>
The
AbstractRequest
implements common elements of SNMP and
AgentX requests and might be also used for other sub-agent request types.- Version:
- 1.0
- Author:
- Frank Fock
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected int
protected int
protected int
protected int
protected R
protected S
protected int
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
find
(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.int
int
protected abstract int
int
getPhase()
Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.int
Returns the value of the reprocessing counter associated with this request.Returns the response object for this request.Returns the initiating event object for the request.int
int
hashCode()
void
Increments the reprocess counter by one.protected void
abstract boolean
boolean
Checks whether the response for this request is complete.int
Initializes next phase and returns its identifier.protected void
void
Set the processed status of each (incomplete) sub-request tofalse
.void
setErrorStatus
(int errorStatus) void
setPhase
(int phase) Sets the request phase.protected abstract void
toString()
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 Details
-
subrequests
-
source
-
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 Details
-
AbstractRequest
-
-
Method Details
-
getSource
Description copied from interface:Request
Returns the initiating event object for the request. -
getResponse
Description copied from interface:Request
Returns the response object for this request.- Specified by:
getResponse
in interfaceRequest<U extends SubRequest,
S, R> - Returns:
- an object containing the response for this request.
-
isBulkRequest
public abstract boolean isBulkRequest() -
find
Description copied from interface:Request
Finds 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:Request
Initializes next phase and returns its identifier. -
isComplete
public boolean isComplete()Description copied from interface:Request
Checks whether the response for this request is complete.- Specified by:
isComplete
in interfaceRequest<U extends SubRequest,
S, R> - Returns:
true
if all required data has been collected to create a response for this request,false
otherwise.
-
get
Description copied from interface:Request
Gets the sub-request at the specified index. -
getPhase
public int getPhase()Description copied from interface:Request
Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request. -
getErrorIndex
public int getErrorIndex()- Specified by:
getErrorIndex
in interfaceRequest<U extends SubRequest,
S, R>
-
getErrorStatus
public int getErrorStatus()- Specified by:
getErrorStatus
in interfaceRequest<U extends SubRequest,
S, R>
-
getTransactionID
public int getTransactionID()- Specified by:
getTransactionID
in interfaceRequest<U extends SubRequest,
S, R>
-
setPhase
Description copied from interface:Request
Sets the request phase.- Specified by:
setPhase
in interfaceRequest<U extends SubRequest,
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:Request
Set the processed status of each (incomplete) sub-request tofalse
.- Specified by:
resetProcessedStatus
in interfaceRequest<U extends SubRequest,
S, R>
-
setErrorStatus
public void setErrorStatus(int errorStatus) - Specified by:
setErrorStatus
in interfaceRequest<U extends SubRequest,
S, R>
-
equals
-
hashCode
public int hashCode() -
getReprocessCounter
public int getReprocessCounter()Description copied from interface:Request
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.- Specified by:
getReprocessCounter
in interfaceRequest<U extends SubRequest,
S, R> - Returns:
- 0 after the initial (and normally last) processing iteration and
n
after then
-th reprocessing iteration. - See Also:
-
incReprocessCounter
public void incReprocessCounter()Description copied from interface:Request
Increments the reprocess counter by one.- Specified by:
incReprocessCounter
in interfaceRequest<U extends SubRequest,
S, R> - See Also:
-
toString
-