org.snmp4j.agent.agentx.master
Class AgentXCommandProcessor

java.lang.Object
  extended by org.snmp4j.agent.CommandProcessor
      extended by org.snmp4j.agent.agentx.master.AgentXCommandProcessor
All Implemented Interfaces:
java.util.EventListener, AgentXCommandListener, AgentXResponseListener, org.snmp4j.agent.NotificationOriginator, org.snmp4j.CommandResponder, org.snmp4j.transport.TransportStateListener

public class AgentXCommandProcessor
extends org.snmp4j.agent.CommandProcessor
implements AgentXCommandListener, org.snmp4j.transport.TransportStateListener, AgentXResponseListener

The AgentXCommandProcessor implements the CommandProcessor interface for AgentX command processing of an AgentX master agent. It holds the AgentX sessions and region registrations internally. The context engine ID of the master agent, the AgentXQueue, the AgentX protocol adapter, and the MOServers have to be provided for instance creation.

Author:
Frank Fock

Nested Class Summary
protected static class AgentXCommandProcessor.AgentXRegEntryComparator
           
 
Field Summary
protected  AgentXIndexRegistry indexRegistry
           
static int MAX_REPROCESSING_DEFAULT
           
 
Fields inherited from class org.snmp4j.agent.CommandProcessor
coexistenceProvider, moServers, notificationOriginator, ownContextEngineIDs, pduHandler, proxyForwarder, requestFactory, requestList, threadPool, vacm
 
Constructor Summary
AgentXCommandProcessor(org.snmp4j.smi.OctetString contextEngineID, AgentXQueue queue, AgentX agentX, org.snmp4j.agent.MOServer[] server)
           
 
Method Summary
protected  int acceptSession(AgentXMasterSession session)
           
 AgentXResponsePDU addAgentCaps(AgentXAddAgentCapsPDU pdu, AgentXMasterSession session)
           
 void addAgentXMasterListener(AgentXMasterListener l)
           
protected  void addPeer(AgentXPeer peer)
           
protected  void addRegion(AgentXRegEntry registration, AgentXRegion region)
           
protected  void addRegistration(AgentXRegEntry registration)
           
protected  void addSession(AgentXMasterSession session)
           
protected  AgentXPeer closePeer(org.snmp4j.smi.Address peerAddress, byte reason)
           
 AgentXResponsePDU closeSession(AgentXClosePDU pdu, AgentXMasterSession session)
           
 void closeSession(AgentXMasterSession session, byte reason)
           
 void connectionStateChanged(org.snmp4j.transport.TransportStateEvent change)
           
protected  AgentXResponsePDU createResponse(AgentXPDU request, AgentXSession session)
           
protected  void finalizeRequest(org.snmp4j.CommandResponderEvent command, org.snmp4j.agent.request.Request req, org.snmp4j.agent.MOServer server)
           
protected  void fireMasterChanged(AgentXMasterEvent event)
           
protected  org.snmp4j.agent.mo.snmp.AgentCapabilityList getAgentCaps(org.snmp4j.smi.OctetString contextName)
           
 byte getAgentXVersion()
           
protected  org.snmp4j.smi.TimeTicks getContextSysUpTime(org.snmp4j.smi.OctetString context)
           
 byte getDefaultTimeout()
           
 int getMaxConsecutiveTimeouts()
          Gets the maximum number of consecutive timeouts allowed per session.
 int getMaxParseErrors()
          Gets the upper limit for parse errors for an AgentX peer.
 int getMaxReprocessing()
           
protected  int getNextSessionID()
           
protected  AgentXPeer getPeer(org.snmp4j.smi.Address address)
           
 org.snmp4j.agent.MOServer getServer()
          Deprecated. Use CommandProcessor.getServer(OctetString context) instead.
protected  AgentXMasterSession getSession(AgentXPDU pdu)
           
protected  AgentXMasterSession getSession(int sessionID)
           
 AgentXResponsePDU indexAllocate(AgentXIndexAllocatePDU pdu, AgentXMasterSession session)
           
 AgentXResponsePDU indexDeallocate(AgentXIndexDeallocatePDU pdu, AgentXMasterSession session)
           
 boolean isAcceptNewContexts()
          Indicates whether subagents can register contexts that are not yet supported by this master agent.
protected  boolean isDuplicate(AgentXRegEntry registration)
           
protected  AgentXResponsePDU notify(AgentXNotifyPDU pdu, AgentXMasterSession session)
           
 void onResponse(AgentXResponseEvent event)
          Process an AgentX response.
 AgentXResponsePDU openSession(AgentXOpenPDU pdu, AgentXCommandEvent event)
           
protected  AgentXResponsePDU ping(AgentXPingPDU pdu, AgentXMasterSession session)
           
protected  void processAgentXBulkResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
protected  void processAgentXGetNextResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
protected  void processAgentXGetResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
protected  void processAgentXSearchResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
protected  void processAgentXSetResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
 void processCommand(AgentXCommandEvent event)
           
protected static void processsErrorResponse(AgentXPending pending, AgentXResponsePDU pdu)
           
protected  AgentXResponsePDU register(AgentXRegisterPDU pdu, AgentXCommandEvent command, AgentXMasterSession session)
           
 AgentXResponsePDU removeAgentCaps(AgentXRemoveAgentCapsPDU pdu, AgentXMasterSession session)
           
 void removeAgentXMasterListener(AgentXMasterListener l)
           
protected  void removeAllRegistrations(AgentXMasterSession session)
           
protected  AgentXPeer removePeer(org.snmp4j.smi.Address peerAddress)
           
protected  boolean removeRegistration(AgentXRegEntry registration, java.util.Iterator<AgentXRegEntry> regIterator)
           
protected  AgentXMasterSession removeSession(int sessionID)
           
protected  void sendResponse(AgentXPDU response, AgentXSession session)
           
 void setAcceptNewContexts(boolean acceptNewContexts)
          Enables or disables accepting new contexts from subagents.
 void setDefaultTimeout(byte defaultTimeout)
           
 void setMaxConsecutiveTimeouts(int maxConsecutiveTimeouts)
          Sets the maximum number of timeouts allowed per session.
 void setMaxParseErrors(int maxParseErrors)
          Sets the maximum number of parse errors allowed per peer.
 void setMaxReprocessing(int maxReprocessing)
           
protected  AgentXResponsePDU unregister(AgentXUnregisterPDU pdu, AgentXCommandEvent event, AgentXMasterSession session)
           
 
Methods inherited from class org.snmp4j.agent.CommandProcessor
addCounterListener, addMOServer, addPduHandler, addProxyForwarder, dispatchCommand, fireIncrementCounter, getCoexistenceProvider, getContextEngineID, getHandler, getInternalRequestTimeout, getNotificationOriginator, getProxyForwarder, getRequestList, getServer, getVacm, getViewName, notify, notify, processNextSubRequest, processPdu, processRequest, processRequest, release, removeCounterListener, removeMOServer, removePduHandler, removeProxyForwarder, reprocessRequest, sendResponse, setAuthorizationError, setCoexistenceProvider, setContextEngineID, setInternalRequestTimeout, setNotificationOriginator, setThreadPool, setVacm, setWorkerPool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_REPROCESSING_DEFAULT

public static final int MAX_REPROCESSING_DEFAULT
See Also:
Constant Field Values

indexRegistry

protected AgentXIndexRegistry indexRegistry
Constructor Detail

AgentXCommandProcessor

public AgentXCommandProcessor(org.snmp4j.smi.OctetString contextEngineID,
                              AgentXQueue queue,
                              AgentX agentX,
                              org.snmp4j.agent.MOServer[] server)
Method Detail

setMaxReprocessing

public void setMaxReprocessing(int maxReprocessing)

getMaxReprocessing

public int getMaxReprocessing()

setMaxParseErrors

public void setMaxParseErrors(int maxParseErrors)
Sets the maximum number of parse errors allowed per peer. If this number is exceeded then the peer will be closed with reason AgentXProtocol.REASON_PARSE_ERROR.

Parameters:
maxParseErrors - a positive value (including zero) sets the upper limit of parse errors tolerated per peer. If the number of parse errors exceeds this limit, all sessions with that peer will be closed. A negative value deactivates any limit.
Since:
1.0.1

getMaxParseErrors

public int getMaxParseErrors()
Gets the upper limit for parse errors for an AgentX peer.

Returns:
a positive value (including zero) indicates the upper limit of parse errors tolerated per peer. A negative value indicates that there is no limit.
Since:
1.0.1

finalizeRequest

protected void finalizeRequest(org.snmp4j.CommandResponderEvent command,
                               org.snmp4j.agent.request.Request req,
                               org.snmp4j.agent.MOServer server)
Overrides:
finalizeRequest in class org.snmp4j.agent.CommandProcessor

getNextSessionID

protected int getNextSessionID()

getServer

public org.snmp4j.agent.MOServer getServer()
Deprecated. Use CommandProcessor.getServer(OctetString context) instead.

Gets the default server (for the null context).

Returns:
the default server instance.

getDefaultTimeout

public byte getDefaultTimeout()

getMaxConsecutiveTimeouts

public int getMaxConsecutiveTimeouts()
Gets the maximum number of consecutive timeouts allowed per session.

Returns:
the maximum number of consecutive timeouts allowed per session

isAcceptNewContexts

public boolean isAcceptNewContexts()
Indicates whether subagents can register contexts that are not yet supported by this master agent.

Returns:
true if subagents can register objects for new contexts.

setDefaultTimeout

public void setDefaultTimeout(byte defaultTimeout)

setMaxConsecutiveTimeouts

public void setMaxConsecutiveTimeouts(int maxConsecutiveTimeouts)
Sets the maximum number of timeouts allowed per session. If the number is exceeded then the session will be closed with reason AgentXProtocol.REASON_TIMEOUTS.

Parameters:
maxConsecutiveTimeouts - the maximum number of timeouts (should be greater than zero).

setAcceptNewContexts

public void setAcceptNewContexts(boolean acceptNewContexts)
Enables or disables accepting new contexts from subagents.

Parameters:
acceptNewContexts - true if subagents are allowed to register objects for new contexts, false otherwise. Default is false.

processCommand

public void processCommand(AgentXCommandEvent event)
Specified by:
processCommand in interface AgentXCommandListener

indexDeallocate

public AgentXResponsePDU indexDeallocate(AgentXIndexDeallocatePDU pdu,
                                         AgentXMasterSession session)

indexAllocate

public AgentXResponsePDU indexAllocate(AgentXIndexAllocatePDU pdu,
                                       AgentXMasterSession session)

processAgentXSearchResponse

protected void processAgentXSearchResponse(AgentXPending pending,
                                           AgentXResponsePDU pdu)

processAgentXBulkResponse

protected void processAgentXBulkResponse(AgentXPending pending,
                                         AgentXResponsePDU pdu)

processsErrorResponse

protected static void processsErrorResponse(AgentXPending pending,
                                            AgentXResponsePDU pdu)
                                     throws java.util.NoSuchElementException
Throws:
java.util.NoSuchElementException

ping

protected AgentXResponsePDU ping(AgentXPingPDU pdu,
                                 AgentXMasterSession session)

notify

protected AgentXResponsePDU notify(AgentXNotifyPDU pdu,
                                   AgentXMasterSession session)

getContextSysUpTime

protected org.snmp4j.smi.TimeTicks getContextSysUpTime(org.snmp4j.smi.OctetString context)

addAgentCaps

public AgentXResponsePDU addAgentCaps(AgentXAddAgentCapsPDU pdu,
                                      AgentXMasterSession session)

getAgentCaps

protected org.snmp4j.agent.mo.snmp.AgentCapabilityList getAgentCaps(org.snmp4j.smi.OctetString contextName)

removeAgentCaps

public AgentXResponsePDU removeAgentCaps(AgentXRemoveAgentCapsPDU pdu,
                                         AgentXMasterSession session)

closeSession

public AgentXResponsePDU closeSession(AgentXClosePDU pdu,
                                      AgentXMasterSession session)

closeSession

public void closeSession(AgentXMasterSession session,
                         byte reason)

removeAllRegistrations

protected void removeAllRegistrations(AgentXMasterSession session)

getSession

protected AgentXMasterSession getSession(int sessionID)

getSession

protected AgentXMasterSession getSession(AgentXPDU pdu)

register

protected AgentXResponsePDU register(AgentXRegisterPDU pdu,
                                     AgentXCommandEvent command,
                                     AgentXMasterSession session)

unregister

protected AgentXResponsePDU unregister(AgentXUnregisterPDU pdu,
                                       AgentXCommandEvent event,
                                       AgentXMasterSession session)

isDuplicate

protected boolean isDuplicate(AgentXRegEntry registration)

addRegistration

protected void addRegistration(AgentXRegEntry registration)
                        throws org.snmp4j.agent.DuplicateRegistrationException
Throws:
org.snmp4j.agent.DuplicateRegistrationException

addRegion

protected void addRegion(AgentXRegEntry registration,
                         AgentXRegion region)
                  throws org.snmp4j.agent.DuplicateRegistrationException
Throws:
org.snmp4j.agent.DuplicateRegistrationException

removeRegistration

protected boolean removeRegistration(AgentXRegEntry registration,
                                     java.util.Iterator<AgentXRegEntry> regIterator)

openSession

public AgentXResponsePDU openSession(AgentXOpenPDU pdu,
                                     AgentXCommandEvent event)

addPeer

protected void addPeer(AgentXPeer peer)

getPeer

protected AgentXPeer getPeer(org.snmp4j.smi.Address address)

acceptSession

protected int acceptSession(AgentXMasterSession session)

addSession

protected void addSession(AgentXMasterSession session)

removeSession

protected AgentXMasterSession removeSession(int sessionID)

createResponse

protected AgentXResponsePDU createResponse(AgentXPDU request,
                                           AgentXSession session)

sendResponse

protected void sendResponse(AgentXPDU response,
                            AgentXSession session)

connectionStateChanged

public void connectionStateChanged(org.snmp4j.transport.TransportStateEvent change)
Specified by:
connectionStateChanged in interface org.snmp4j.transport.TransportStateListener

removePeer

protected AgentXPeer removePeer(org.snmp4j.smi.Address peerAddress)

closePeer

protected AgentXPeer closePeer(org.snmp4j.smi.Address peerAddress,
                               byte reason)

getAgentXVersion

public byte getAgentXVersion()

addAgentXMasterListener

public void addAgentXMasterListener(AgentXMasterListener l)

removeAgentXMasterListener

public void removeAgentXMasterListener(AgentXMasterListener l)

fireMasterChanged

protected void fireMasterChanged(AgentXMasterEvent event)

onResponse

public void onResponse(AgentXResponseEvent event)
Description copied from interface: AgentXResponseListener
Process an AgentX response.

Specified by:
onResponse in interface AgentXResponseListener
Parameters:
event - a AgentXResponseEvent.

processAgentXGetResponse

protected void processAgentXGetResponse(AgentXPending pending,
                                        AgentXResponsePDU pdu)

processAgentXGetNextResponse

protected void processAgentXGetNextResponse(AgentXPending pending,
                                            AgentXResponsePDU pdu)

processAgentXSetResponse

protected void processAgentXSetResponse(AgentXPending pending,
                                        AgentXResponsePDU pdu)

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.