- java.lang.Object
-
- org.snmp4j.agent.request.AbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
- org.snmp4j.agent.request.SnmpRequest
-
- All Implemented Interfaces:
Request<org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU,SnmpRequest.SnmpSubRequest>
public class SnmpRequest extends AbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
TheSnmpRequest
class implements requests from a SNMP source.- Version:
- 1.2
- Author:
- Frank Fock
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SnmpRequest.SnmpSubRequest
The SnmpSubRequest represents a single variable binding request of a SNMP PDU.class
SnmpRequest.SnmpSubRequestIterator
TheSnmpRequest.SnmpSubRequestIterator
implements an iterator over the GETBULK repetitions of a subrequest.
-
Field Summary
Fields Modifier and Type Field Description static org.snmp4j.smi.OctetString
DEFAULT_CONTEXT
protected Map<Object,Object>
processingUserObjects
-
Fields inherited from class org.snmp4j.agent.request.AbstractRequest
errorStatus, phase, repeaterRowSize, repeaterStartIndex, reprocessCounter, response, source, subrequests, transactionID
-
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 SnmpRequest(org.snmp4j.CommandResponderEvent<?> request, CoexistenceInfo cinfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addRepeaterSubRequest()
protected void
assignErrorStatus2Response()
CoexistenceInfo
getCoexistenceInfo()
int
getCompleteRepetitions()
Returns the number of repetitions that are complete.org.snmp4j.smi.OctetString
getContext()
Gets the context of the request.int
getErrorIndex()
protected int
getMaxPhase()
int
getMaxRepetitions()
int
getMessageProcessingModel()
int
getNonRepeaters()
Object
getProcessingUserObject(Object key)
Gets the processing user object for the specified key.int
getRepeaterCount()
org.snmp4j.PDU
getResponse()
Return the response PDU.int
getSecurityLevel()
int
getSecurityModel()
org.snmp4j.smi.OctetString
getSecurityName()
int
getTransactionID()
org.snmp4j.smi.OctetString
getViewName()
int
getViewType()
static int
getViewType(int pduType)
Returns the VACM view type for the supplied PDU type.protected boolean
is2PC()
boolean
isBulkRequest()
boolean
isPhaseComplete()
Checks whether the current phase is complete.Iterator<SnmpRequest.SnmpSubRequest>
iterator()
iteratorstatic int
nextTransactionID()
Object
setProcessingUserObject(Object key, Object value)
Sets an user object association.void
setRequestEvent(org.snmp4j.CommandResponderEvent<?> source)
protected void
setupSubRequests()
void
setViewName(org.snmp4j.smi.OctetString viewName)
int
size()
Gets the number of sub-requests in this request.-
Methods inherited from class org.snmp4j.agent.request.AbstractRequest
equals, find, get, getErrorStatus, getPhase, getReprocessCounter, getSource, hashCode, incReprocessCounter, initSubRequests, isComplete, nextPhase, resetCompletionStatus, resetProcessedStatus, setErrorStatus, setPhase, toString
-
-
-
-
Constructor Detail
-
SnmpRequest
public SnmpRequest(org.snmp4j.CommandResponderEvent<?> request, CoexistenceInfo cinfo)
-
-
Method Detail
-
nextTransactionID
public static int nextTransactionID()
-
setupSubRequests
protected void setupSubRequests()
- Specified by:
setupSubRequests
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
getCompleteRepetitions
public int getCompleteRepetitions()
Returns the number of repetitions that are complete.- Returns:
- the minimum
r
for which alli<r*(pduSize-nonRepeaters)
SubRequest
s returned byAbstractRequest.get(int i)
return true onSubRequest.isComplete()
.
-
getMaxRepetitions
public int getMaxRepetitions()
-
getNonRepeaters
public int getNonRepeaters()
-
getMaxPhase
protected int getMaxPhase()
- Specified by:
getMaxPhase
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
size
public int size()
Description copied from interface:Request
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).
-
setRequestEvent
public void setRequestEvent(org.snmp4j.CommandResponderEvent<?> source)
-
assignErrorStatus2Response
protected void assignErrorStatus2Response()
-
getResponse
public org.snmp4j.PDU getResponse()
Return the response PDU.- Specified by:
getResponse
in interfaceRequest<org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU,SnmpRequest.SnmpSubRequest>
- Overrides:
getResponse
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
- Returns:
- the PDU received as response.
-
iterator
public Iterator<SnmpRequest.SnmpSubRequest> iterator()
iterator- Returns:
- Iterator
-
is2PC
protected boolean is2PC()
-
getContext
public org.snmp4j.smi.OctetString getContext()
Description copied from interface:Request
Gets the context of the request.- Returns:
- an
OctetString
instance.
-
getViewName
public org.snmp4j.smi.OctetString getViewName()
-
setViewName
public void setViewName(org.snmp4j.smi.OctetString viewName)
-
getSecurityLevel
public int getSecurityLevel()
-
getSecurityModel
public int getSecurityModel()
-
getSecurityName
public org.snmp4j.smi.OctetString getSecurityName()
-
getViewType
public int getViewType()
-
getViewType
public static int getViewType(int pduType)
Returns the VACM view type for the supplied PDU type.- Parameters:
pduType
- a PDU type.- Returns:
- the corresponding VACM view type.
-
addRepeaterSubRequest
protected void addRepeaterSubRequest()
-
getErrorIndex
public int getErrorIndex()
- Specified by:
getErrorIndex
in interfaceRequest<org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU,SnmpRequest.SnmpSubRequest>
- Overrides:
getErrorIndex
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
getTransactionID
public int getTransactionID()
- Specified by:
getTransactionID
in interfaceRequest<org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU,SnmpRequest.SnmpSubRequest>
- Overrides:
getTransactionID
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
getCoexistenceInfo
public CoexistenceInfo getCoexistenceInfo()
-
getMessageProcessingModel
public int getMessageProcessingModel()
-
getRepeaterCount
public int getRepeaterCount()
-
isPhaseComplete
public boolean isPhaseComplete()
Description copied from interface:Request
Checks whether the current phase is complete.- Returns:
true
if all required processing has been finished for the current request phase. For single phase request types this method returns the same result asRequest.isComplete()
.
-
isBulkRequest
public boolean isBulkRequest()
- Specified by:
isBulkRequest
in classAbstractRequest<SnmpRequest.SnmpSubRequest,org.snmp4j.CommandResponderEvent<?>,org.snmp4j.PDU>
-
getProcessingUserObject
public Object getProcessingUserObject(Object key)
Description copied from interface:Request
Gets the processing user object for the specified key. By default there is no such object associated with a request, butManagedObject
s 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
null
if their exists no such association.
-
setProcessingUserObject
public Object setProcessingUserObject(Object key, Object value)
Description copied from interface:Request
Sets an user object association.- Parameters:
key
- a key Object.value
- a value Object associated withkey
.- Returns:
- the previous value associated with
key
ornull
if no such association existed.
-
-