org.snmp4j.agent.request
Interface Request<S,R>

All Known Implementing Classes:
AbstractRequest, SnmpRequest

public interface Request<S,R>

The Request interface defines common elements of SNMP related operation requests.

Version:
1.2
Author:
Frank Fock

Field Summary
static int PHASE_1PC
           
static int PHASE_2PC_CLEANUP
           
static int PHASE_2PC_COMMIT
           
static int PHASE_2PC_PREPARE
           
static int PHASE_2PC_UNDO
           
static int PHASE_INIT
           
 
Method Summary
 SubRequest find(org.snmp4j.smi.OID prefix)
          Finds the first sub-request whose OID starts with the supplied one.
 SubRequest<S,R> get(int index)
          Gets the sub-request at the specified index.
 org.snmp4j.smi.OctetString getContext()
          Gets the context of the request.
 int getErrorIndex()
           
 int getErrorStatus()
           
 int getMessageProcessingModel()
           
 int getPhase()
          Gets the phase identifier of the current Two-Phase-Commit (2PC) phase of this request.
 java.lang.Object getProcessingUserObject(java.lang.Object key)
          Gets the processing user object for the specified key.
 int getReprocessCounter()
          Returns the value of the reprocessing counter associated with this request.
 R getResponse()
          Returns the response object for this request.
 int getSecurityLevel()
           
 int getSecurityModel()
           
 org.snmp4j.smi.OctetString getSecurityName()
           
 S getSource()
          Returns the initiating event object for the request.
 int getTransactionID()
           
 org.snmp4j.smi.OctetString getViewName()
           
 int getViewType()
           
 void incReprocessCounter()
          Increments the reprocess counter by one.
 boolean isComplete()
          Checks whether the response for this request is complete.
 boolean isPhaseComplete()
          Checks whether the current phase is complete.
 java.util.Iterator<SubRequest> iterator()
          Returns an Iterator over the sub-requests of this request.
 int nextPhase()
          Initializes next phase and returns its identifier.
 void resetProcessedStatus()
          Set the processed status of each (incomplete) sub-request to false.
 void setErrorStatus(int errorStatus)
           
 void setPhase(int phase)
          Sets the request phase.
 java.lang.Object setProcessingUserObject(java.lang.Object key, java.lang.Object value)
          Sets an user object association.
 void setViewName(org.snmp4j.smi.OctetString viewName)
           
 int size()
          Gets the number of sub-requests in this request.
 

Field Detail

PHASE_INIT

static final int PHASE_INIT
See Also:
Constant Field Values

PHASE_1PC

static final int PHASE_1PC
See Also:
Constant Field Values

PHASE_2PC_PREPARE

static final int PHASE_2PC_PREPARE
See Also:
Constant Field Values

PHASE_2PC_COMMIT

static final int PHASE_2PC_COMMIT
See Also:
Constant Field Values

PHASE_2PC_UNDO

static final int PHASE_2PC_UNDO
See Also:
Constant Field Values

PHASE_2PC_CLEANUP

static final int PHASE_2PC_CLEANUP
See Also:
Constant Field Values
Method Detail

find

SubRequest find(org.snmp4j.smi.OID prefix)
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 SubRequest instance of this request whose OID starts with prefix. If no such sub-request exits null is 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:
true if all required data has been collected to create a response for this request, false otherwise.

isPhaseComplete

boolean isPhaseComplete()
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 as isComplete().

getSource

S getSource()
Returns the initiating event object for the request.

Returns:
an Object instance on whose behalf this request has been initiated.

getContext

org.snmp4j.smi.OctetString getContext()
Gets the context of the request.

Returns:
an OctetString instance.

get

SubRequest<S,R> get(int index)
Gets the sub-request at the specified index.

Parameters:
index - an index >= 0 and < size()
Returns:
a SnmpSubRequest instance.

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

int nextPhase()
              throws java.util.NoSuchElementException
Initializes next phase and returns its identifier.

Returns:
a phase identifier.
Throws:
java.util.NoSuchElementException - if there is no next phase for this type of request.

setPhase

void setPhase(int phase)
              throws java.util.NoSuchElementException
Sets the request phase.

Parameters:
phase - a phase identifier.
Throws:
java.util.NoSuchElementException - if there is no such phase for this type of request.

iterator

java.util.Iterator<SubRequest> iterator()
Returns an Iterator over 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 to false.


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 n after the n-th reprocessing iteration.
See Also:
incReprocessCounter()

incReprocessCounter

void incReprocessCounter()
Increments the reprocess counter by one.

See Also:
getReprocessCounter()

getProcessingUserObject

java.lang.Object getProcessingUserObject(java.lang.Object key)
Gets the processing user object for the specified key. By default there is no such object associated with a request, but ManagedObjects 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.
Since:
1.2

setProcessingUserObject

java.lang.Object setProcessingUserObject(java.lang.Object key,
                                         java.lang.Object value)
Sets an user object association.

Parameters:
key - a key Object.
value - a value Object associated with key.
Returns:
the previous value associated with key or null if no such association existed.
Since:
1.2

Copyright 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.