Package org.snmp4j.agent.request
Class SnmpRequest.SnmpSubRequest
java.lang.Object
org.snmp4j.agent.request.SnmpRequest.SnmpSubRequest
- All Implemented Interfaces:
EventListener
,RequestStatusListener
,SnmpSubRequest
,SubRequest
- Enclosing class:
SnmpRequest
public class SnmpRequest.SnmpSubRequest
extends Object
implements SnmpSubRequest, RequestStatusListener
- Version:
- 1.0
- Author:
- Frank Fock
-
Constructor Summary
ModifierConstructorDescriptionprotected
SnmpSubRequest
(SnmpRequest.SnmpSubRequest predecessor, int index) protected
SnmpSubRequest
(org.snmp4j.smi.VariableBinding subrequest, int index) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Marks the sub-request as completed.final int
Gets the error status for this sub-request.int
getIndex()
Returns the index of this subrequest in the request.protected MOScope
getNextScope
(org.snmp4j.smi.OID previousOID) getQuery()
Gets the query previously associated with this sub-request.Gets the request this sub-request belongs to.getScope()
Gets the scope for this subrequest.Gets the status object associated with this sub-request.Gets theManagedObject
that is responsible for processing this sub-request.Gets the undo value object associated with this sub-request.Gets the user object that has previously associated with this sub-request.org.snmp4j.smi.VariableBinding
Returns the variable binding associated with the sub-request.boolean
hasError()
Indicates whether this (sub-)request has an error.boolean
Checks whether the sub-request has been completed and needs no further processing.SubRequestIterator<? extends SubRequest>
Returns an iterator on the repetitions of this sub-request.void
void
setErrorStatus
(int errorStatus) Sets the error status for this sub-request.void
Sets the query associated with this subrequest.void
setStatus
(RequestStatus status) void
setTargetMO
(ManagedObject managedObject) Sets theManagedObject
that is determined as the target object of this sub-request by the agent framework.void
setUndoValue
(Object undoInformation) Associates an undo value object with this sub-request.void
setUserObject
(Object userObject) Sets the user object.toString()
void
Updates the next repetition's scope and reset any previously set query tonull
.
-
Constructor Details
-
SnmpSubRequest
protected SnmpSubRequest(org.snmp4j.smi.VariableBinding subrequest, int index) -
SnmpSubRequest
-
-
Method Details
-
getNextScope
-
getRequest
Description copied from interface:SubRequest
Gets the request this sub-request belongs to.- Specified by:
getRequest
in interfaceSubRequest
- Returns:
- a Request instance.
-
getStatus
Description copied from interface:SubRequest
Gets the status object associated with this sub-request.- Specified by:
getStatus
in interfaceSnmpSubRequest
- Specified by:
getStatus
in interfaceSubRequest
- Returns:
- a RequestStatus instance.
-
getVariableBinding
public org.snmp4j.smi.VariableBinding getVariableBinding()Description copied from interface:SubRequest
Returns the variable binding associated with the sub-request. In order to process a sub-request this variable binding needs to be modified (if not an error condition prevents that).- Specified by:
getVariableBinding
in interfaceSnmpSubRequest
- Specified by:
getVariableBinding
in interfaceSubRequest
- Returns:
- the
VariableBinding
that holds the sub-request result or operation parameter (in case of a SET request).
-
setStatus
- Specified by:
setStatus
in interfaceSnmpSubRequest
-
getUndoValue
Description copied from interface:SubRequest
Gets the undo value object associated with this sub-request.- Specified by:
getUndoValue
in interfaceSubRequest
- Returns:
- an Object that has previously been associated with this request by
calling
SubRequest.setUndoValue(java.lang.Object)
.
-
setUndoValue
Description copied from interface:SubRequest
Associates an undo value object with this sub-request. The undo value is internally used by the SNMP4J-Agent API and should therefore not be altered externally. One exception to this rule is an implementation of theManagedObject
interface that does not extend any other API class.- Specified by:
setUndoValue
in interfaceSubRequest
- Parameters:
undoInformation
- an object that represents/contains all necessary information to undo this sub-request.
-
requestStatusChanged
- Specified by:
requestStatusChanged
in interfaceRequestStatusListener
-
getScope
Description copied from interface:SubRequest
Gets the scope for this subrequest. The scope is solely defined by this sub-request and possible request processing that has already excluded managed objects from the scope of this sub-request.- Specified by:
getScope
in interfaceSubRequest
- Returns:
- a
MOScope
instance.
-
completed
public void completed()Description copied from interface:SubRequest
Marks the sub-request as completed. This is a shortcut for callingSubRequest.getStatus()
and thenRequestStatus.setPhaseComplete(boolean)
totrue
.- Specified by:
completed
in interfaceSubRequest
-
hasError
public boolean hasError()Description copied from interface:SubRequest
Indicates whether this (sub-)request has an error.- Specified by:
hasError
in interfaceSubRequest
- Returns:
true
if this request (and thus also this sub-request) has an error status greater than zero.
-
isComplete
public boolean isComplete()Description copied from interface:SubRequest
Checks whether the sub-request has been completed and needs no further processing.- Specified by:
isComplete
in interfaceSubRequest
- Returns:
true
if the sub-request has been finished and should not be processed any more.
-
setTargetMO
Description copied from interface:SubRequest
Sets theManagedObject
that is determined as the target object of this sub-request by the agent framework. For SET requests the target managed object is locked and referenced here to make sure that all locks are released when a request is answered. In addition, SET requests are processed in multiple phases and referencing the target managed objects increases performance.- Specified by:
setTargetMO
in interfaceSubRequest
- Parameters:
managedObject
- theManagedObject
responsible for processing this sub- request.
-
getTargetMO
Description copied from interface:SubRequest
Gets theManagedObject
that is responsible for processing this sub-request.- Specified by:
getTargetMO
in interfaceSubRequest
- Returns:
ManagedObject
instance.
-
getSnmpRequest
- Specified by:
getSnmpRequest
in interfaceSnmpSubRequest
-
setErrorStatus
public void setErrorStatus(int errorStatus) Description copied from interface:SubRequest
Sets the error status for this sub-request. Calling this method is a shortcut for
.SubRequest.getStatus()
.setErrorStatus(int errorStatus)- Specified by:
setErrorStatus
in interfaceSnmpSubRequest
- Specified by:
setErrorStatus
in interfaceSubRequest
- Parameters:
errorStatus
- a SNMPv2/v3 error status.
-
getIndex
public int getIndex()Description copied from interface:SubRequest
Returns the index of this subrequest in the request.- Specified by:
getIndex
in interfaceSubRequest
- Returns:
- the zero based index.
-
setQuery
Description copied from interface:SubRequest
Sets the query associated with this subrequest. The query is not used by the request itself but may be stored here for further reference while processing this sub-requests.- Specified by:
setQuery
in interfaceSubRequest
- Parameters:
query
- aMOQuery
instance representing the query resulting from this sub-request.
-
getQuery
Description copied from interface:SubRequest
Gets the query previously associated with this sub-request. A sub-request is associated during requests processing with a instrumentation query.- Specified by:
getQuery
in interfaceSubRequest
- Returns:
- a
MOQuery
that describes which manage objects match this sub-request.
-
toString
-
repetitions
Description copied from interface:SubRequest
Returns an iterator on the repetitions of this sub-request. On requests other than GETBULK requests this method returns an empty iterator.- Specified by:
repetitions
in interfaceSubRequest
- Returns:
- a SubRequestIterator enumerating the repetitions on this sub-requests starting with this sub-request.
-
updateNextRepetition
public void updateNextRepetition()Description copied from interface:SubRequest
Updates the next repetition's scope and reset any previously set query tonull
. The scope of the next repetition is updated according to the value of this variable binding. If this sub-request has an error status or exception value, the following repetitions are set to the same value and exception. Otherwise, the scope of the following sub-request is the open interval from this sub-request's OID (not-including) to any OID value.- Specified by:
updateNextRepetition
in interfaceSubRequest
-
getErrorStatus
public final int getErrorStatus()Description copied from interface:SubRequest
Gets the error status for this sub-request. Calling this method is a shortcut for
.SubRequest.getStatus()
.getErrorStatus()- Specified by:
getErrorStatus
in interfaceSubRequest
- Returns:
- a SNMPv2/v3 error status.
-
getUserObject
Description copied from interface:SubRequest
Gets the user object that has previously associated with this sub-request.- Specified by:
getUserObject
in interfaceSubRequest
- Returns:
- an object.
-
setUserObject
Description copied from interface:SubRequest
Sets the user object. The user object can be used to associate resources or any other type of information necessary for a managed object instance to process a SNMP request. When the request is processed, this reference will be set tonull
.- Specified by:
setUserObject
in interfaceSubRequest
- Parameters:
userObject
- an object that is not processed or interpreted by the agent API.
-