public class AgentXSubagent extends Object implements AgentXCommandListener, org.snmp4j.agent.NotificationOriginator
AgentXSubagent class implements the AgentX communication
for an AgentX subagent implementation.| Modifier and Type | Field and Description |
|---|---|
protected int |
nextTransactionID |
protected Map<org.snmp4j.smi.Address,AgentXPeer> |
peers |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerCleanupSet |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerCommitSet |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerGet |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerGetBulk |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerGetNext |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerTestSet |
protected org.snmp4j.agent.RequestHandler<AgentXRequest> |
requestHandlerUndoSet |
protected Map<org.snmp4j.agent.agentx.subagent.AgentXSubagent.RequestID,AgentXRequest> |
requestList |
protected Map<Integer,AgentXSession> |
sessions |
protected Map<String,AgentXSharedMOTableSupport> |
sharedMOTableSupport |
| Constructor and Description |
|---|
AgentXSubagent(AgentX agentX,
org.snmp4j.smi.OID subagentID,
org.snmp4j.smi.OctetString subagentDescr) |
| Modifier and Type | Method and Description |
|---|---|
int |
addAgentCaps(AgentXSession session,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID id,
org.snmp4j.smi.OctetString descr) |
protected <A extends org.snmp4j.smi.Address> |
addMaster(A localAddress,
List<org.snmp4j.transport.TransportStateListener> stateListeners) |
void |
addMOServer(org.snmp4j.agent.MOServer server) |
void |
addPingListener(PingListener l) |
int |
close(AgentXSession session,
byte reason) |
Map<AgentXSession,Integer> |
closeAllSessions(byte reason)
Close all sessions hold by this sub-agent and return the AgentX status of the close operation together with the
AgentXSession object. |
protected int |
closeSession(int sessionID,
byte reason)
Close the AgentX session with the given session ID and reason.
|
<A extends org.snmp4j.smi.Address> |
connect(A masterAddress,
A localAddress,
AgentXSession session,
List<org.snmp4j.transport.TransportStateListener> stateListeners)
Connect to the given AgentX master using the specified local address.
|
int |
connect(org.snmp4j.smi.Address masterAddress,
org.snmp4j.smi.Address localAddress,
AgentXSession session)
Connect to the given AgentX master using the specified local address.
|
protected AgentXSharedMOTableSupport |
createSharedTableSupport(AgentXSession session,
org.snmp4j.smi.OctetString context)
Create a new
AgentXSharedMOTableSupport instance for the given AgentX session and context. |
void |
disconnect(org.snmp4j.smi.Address masterAddress)
Disconnect from master but leave transport mapping ready.
|
void |
dispatchCommand(AgentXCommandEvent cmd) |
protected void |
firePinged(PingEvent event) |
AgentXSession |
firstSession()
Returns the first session that have been opened by this subagent and is
still open.
|
Collection<org.snmp4j.smi.OctetString> |
getContexts() |
byte |
getDefaultPriority() |
protected int |
getNextTransactionID()
Get the next AgentX transaction ID.
|
protected byte |
getPriority(org.snmp4j.agent.ManagedObject mo,
AgentXRegion region)
Gets the priority with which the supplied managed object and
region should be registered at the master agent.
|
org.snmp4j.agent.MOServer |
getServer(org.snmp4j.smi.OctetString context) |
org.snmp4j.util.WorkerPool |
getWorkerPool() |
AgentXResponseEvent |
notify(AgentXSession session,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID notificationID,
org.snmp4j.smi.TimeTicks sysUpTime,
org.snmp4j.smi.VariableBinding[] vbs) |
Object |
notify(org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID notificationID,
org.snmp4j.smi.TimeTicks sysUpTime,
org.snmp4j.smi.VariableBinding[] vbs) |
Object |
notify(org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID notificationID,
org.snmp4j.smi.VariableBinding[] vbs)
Sends notifications (traps) to all appropriate notification targets
through the master agent.
|
protected int |
openSession(org.snmp4j.TransportMapping transport,
org.snmp4j.smi.Address masterAddress,
AgentXSession session) |
void |
processCommand(AgentXCommandEvent event) |
protected void |
processNextSubRequest(org.snmp4j.agent.request.Request request,
org.snmp4j.agent.MOServer server,
org.snmp4j.smi.OctetString context,
org.snmp4j.agent.request.SubRequest sreq) |
protected void |
processResponse(AgentXCommandEvent cmd) |
protected int |
registerRegion(AgentXSession session,
org.snmp4j.smi.OctetString context,
AgentXRegion region,
byte priority,
org.snmp4j.smi.TimeTicks sysUpTime) |
void |
registerRegions(AgentXSession session,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.TimeTicks sysUpTime,
RegistrationCallback registrationCallback)
Registers the subagent regions at the master agent.
|
void |
registerSharedTableRows(AgentXSession session,
org.snmp4j.smi.OctetString context,
AgentXSharedMOTable mo,
RegistrationCallback registrationCallback)
Deprecated.
Use
registerSharedTableRows(org.snmp4j.agent.agentx.AgentXSession, org.snmp4j.smi.OctetString,
AgentXSharedMOTable, RegistrationCallback, AgentXSharedMOTableSupport) instead. This version creates
a new table support object for each call (shared table) which is not recommended. |
void |
registerSharedTableRows(AgentXSession session,
org.snmp4j.smi.OctetString context,
AgentXSharedMOTable mo,
RegistrationCallback registrationCallback,
AgentXSharedMOTableSupport sharedTableSupport)
Registers the indexes and (row) regions of a shared table.
|
protected void |
release(org.snmp4j.agent.MOServer server,
AgentXRequest req) |
int |
removeAgentCaps(AgentXSession session,
org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID id) |
protected void |
removeMaster(org.snmp4j.TransportMapping transport) |
void |
removeMOServer(org.snmp4j.agent.MOServer server) |
void |
removePingListener(PingListener l) |
<A extends org.snmp4j.smi.Address> |
resetConnection(A masterAddress,
boolean sendClosePdu)
Reset a connection that is not working anymore either with trying to close all open session with a AgentXClosePdu
(when sendClosePdu is true) or silently without sending any messages.
|
protected void |
sendResponse(AgentXCommandEvent cmd,
AgentXRequest request) |
void |
setDefaultPriority(byte priority) |
void |
setPingDelay(int seconds)
Sets the ping delay in seconds.
|
void |
setThreadPool(org.snmp4j.util.ThreadPool threadPool) |
protected int |
unregisterRegion(AgentXSession session,
org.snmp4j.smi.OctetString context,
AgentXRegion region,
byte timeout) |
protected Map<org.snmp4j.agent.agentx.subagent.AgentXSubagent.RequestID,AgentXRequest> requestList
protected Map<org.snmp4j.smi.Address,AgentXPeer> peers
protected Map<Integer,AgentXSession> sessions
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerGet
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerGetNext
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerGetBulk
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerTestSet
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerCommitSet
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerUndoSet
protected org.snmp4j.agent.RequestHandler<AgentXRequest> requestHandlerCleanupSet
protected int nextTransactionID
protected Map<String,AgentXSharedMOTableSupport> sharedMOTableSupport
public AgentXSubagent(AgentX agentX, org.snmp4j.smi.OID subagentID, org.snmp4j.smi.OctetString subagentDescr)
public void setPingDelay(int seconds)
PingListener with addPingListener(org.snmp4j.agent.agentx.event.PingListener).seconds - the delay. If zero or a negative value is supplied, no pings are sentpublic void processCommand(AgentXCommandEvent event)
processCommand in interface AgentXCommandListenerprotected int getNextTransactionID()
protected int closeSession(int sessionID,
byte reason)
throws IOException
sessionID - an AgentX session ID. If such a session does not exist, AgentXProtocol.AGENTX_NOT_OPEN is returned.reason - the AgentX reason (AgentXProtocol.REASON_SHUTDOWN, AgentXProtocol.REASON_TIMEOUTS,
AgentXProtocol.REASON_BY_MANAGER, AgentXProtocol.REASON_PROTOCOL_ERROR,
AgentXProtocol.REASON_PARSE_ERROR, AgentXProtocol.REASON_OTHER) for closing the session.AgentXProtocol.AGENTX_TIMEOUT if the master did not
respond in time.IOException - if the IO operation failed.protected int openSession(org.snmp4j.TransportMapping transport,
org.snmp4j.smi.Address masterAddress,
AgentXSession session)
throws IOException
IOExceptionpublic void disconnect(org.snmp4j.smi.Address masterAddress)
throws IOException
masterAddress - the master's address to disconnect.IOException - if the closing of the connection fails.public <A extends org.snmp4j.smi.Address> boolean resetConnection(A masterAddress,
boolean sendClosePdu)
masterAddress - the address of the peer to reset connection.sendClosePdu - true if this subagent should try to send AgentXClosePdus for each open session before resetting the
connection of false if the connection should be closed silently. Close PDU will be sent only if the
transport is still listening.public int connect(org.snmp4j.smi.Address masterAddress,
org.snmp4j.smi.Address localAddress,
AgentXSession session)
throws IOException
masterAddress - the (TCP) address of the master agent.localAddress - the local address. Use port 0 to let AgentXSubagent choose an available port.session - returns the AgentXSession information of the new AgentX session, i.e. the session ID returned by the
master agent.AgentXProtocol.AGENTX_SUCCESS if the session has been established or an AgentX error status, if not.IOException - if an IO operation failed.public <A extends org.snmp4j.smi.Address> int connect(A masterAddress,
A localAddress,
AgentXSession session,
List<org.snmp4j.transport.TransportStateListener> stateListeners)
throws IOException
A - address type to connect to.masterAddress - the (TCP) address of the master agent.localAddress - the local address. Use port 0 to let AgentXSubagent choose an available port.session - returns the AgentXSession information of the new AgentX session, i.e. the session ID returned by the
master agent.stateListeners - an optional list of TransportStateListener to register for TransportStateEvents before the
connection is being established using a new ConnectionOrientedTransportMapping.AgentXProtocol.AGENTX_SUCCESS if the session has been established or an AgentX error status, if not.IOException - if an IO operation failed.public int close(AgentXSession session, byte reason) throws IOException
IOExceptionpublic Map<AgentXSession,Integer> closeAllSessions(byte reason)
AgentXSession object.reason - the AgentX reason (AgentXProtocol.REASON_SHUTDOWN, AgentXProtocol.REASON_TIMEOUTS,
AgentXProtocol.REASON_BY_MANAGER, AgentXProtocol.REASON_PROTOCOL_ERROR,
AgentXProtocol.REASON_PARSE_ERROR, AgentXProtocol.REASON_OTHER) for closing the session.AgentXProtocol.AGENTX_SUCCESS indicates that this session was successfully closed.public void setDefaultPriority(byte priority)
public byte getDefaultPriority()
protected byte getPriority(org.snmp4j.agent.ManagedObject mo,
AgentXRegion region)
getDefaultPriority().mo - ManagedObject
a managed object instance that manages region.region - the region to be registered.public void registerRegions(AgentXSession session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.TimeTicks sysUpTime, RegistrationCallback registrationCallback)
AgentXSharedMOTableSupport instances of AgentXSharedMutableMOTable
instances. For any other instances a support object instance will
be created for each session and context.session - the session on whose behalf regions are registered.context - the context to use for registration.sysUpTime - if not null, the master agent's notion of the sysUpTime
for the registered context is returned. The input value is always
ignored!registrationCallback - a possibly null reference to a
RegistrationCallback instance to handle registration
events.protected AgentXSharedMOTableSupport createSharedTableSupport(AgentXSession session, org.snmp4j.smi.OctetString context)
AgentXSharedMOTableSupport instance for the given AgentX session and context.session - an AgentXSession instance.context - a AgentX context.public void registerSharedTableRows(AgentXSession session, org.snmp4j.smi.OctetString context, AgentXSharedMOTable mo, RegistrationCallback registrationCallback)
registerSharedTableRows(org.snmp4j.agent.agentx.AgentXSession, org.snmp4j.smi.OctetString,
AgentXSharedMOTable, RegistrationCallback, AgentXSharedMOTableSupport) instead. This version creates
a new table support object for each call (shared table) which is not recommended.registerRegions(org.snmp4j.agent.agentx.AgentXSession,
org.snmp4j.smi.OctetString, org.snmp4j.smi.TimeTicks, RegistrationCallback).session - the session on whose behalf regions are registered.context - the context to use for registration.mo - the AgentXSharedMOTable instance to register.registrationCallback - if not null the callback is informed when registration
of a row succeeded or failed.public void registerSharedTableRows(AgentXSession session, org.snmp4j.smi.OctetString context, AgentXSharedMOTable mo, RegistrationCallback registrationCallback, AgentXSharedMOTableSupport sharedTableSupport)
registerRegions(org.snmp4j.agent.agentx.AgentXSession,
org.snmp4j.smi.OctetString, org.snmp4j.smi.TimeTicks, RegistrationCallback).session - the session on whose behalf regions are registered.context - the context to use for registration.mo - the AgentXSharedMOTable instance to register.registrationCallback - if not null the callback is informed when registration
of a row succeeded or failed.sharedTableSupport - the shared table support to be used for row registration. If mo has
no table support instance and is a AgentXSharedMutableMOTable then its
sharedTableSupport will be set to sharedTableSupport.protected int registerRegion(AgentXSession session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte priority, org.snmp4j.smi.TimeTicks sysUpTime) throws IOException
IOExceptionprotected int unregisterRegion(AgentXSession session, org.snmp4j.smi.OctetString context, AgentXRegion region, byte timeout) throws IOException
IOExceptionprotected <A extends org.snmp4j.smi.Address> org.snmp4j.TransportMapping<A> addMaster(A localAddress,
List<org.snmp4j.transport.TransportStateListener> stateListeners)
throws IOException
IOExceptionprotected void removeMaster(org.snmp4j.TransportMapping transport)
public void addMOServer(org.snmp4j.agent.MOServer server)
public void removeMOServer(org.snmp4j.agent.MOServer server)
public org.snmp4j.agent.MOServer getServer(org.snmp4j.smi.OctetString context)
public Collection<org.snmp4j.smi.OctetString> getContexts()
public org.snmp4j.util.WorkerPool getWorkerPool()
public void setThreadPool(org.snmp4j.util.ThreadPool threadPool)
public void dispatchCommand(AgentXCommandEvent cmd)
protected void sendResponse(AgentXCommandEvent cmd, AgentXRequest request)
protected void release(org.snmp4j.agent.MOServer server,
AgentXRequest req)
protected void processResponse(AgentXCommandEvent cmd)
protected void processNextSubRequest(org.snmp4j.agent.request.Request request,
org.snmp4j.agent.MOServer server,
org.snmp4j.smi.OctetString context,
org.snmp4j.agent.request.SubRequest sreq)
throws NoSuchElementException
NoSuchElementExceptionpublic Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.VariableBinding[] vbs)
notify in interface org.snmp4j.agent.NotificationOriginatorcontext - the context name of the context on whose behalf this
notification has been generated.notificationID - the object ID that uniquely identifies this
notification. For SNMPv1 traps, the notification ID has to be build
using the rules provided by RFC 2576.vbs - an array of VariableBinding instances
representing the payload of the notification.AgentXResponseEvent instance or null if the
notification request timed out.public Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs)
notify in interface org.snmp4j.agent.NotificationOriginatorpublic final AgentXSession firstSession()
null is returned.AgentXSession.public AgentXResponseEvent notify(AgentXSession session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs) throws IOException
IOExceptionpublic int addAgentCaps(AgentXSession session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id, org.snmp4j.smi.OctetString descr)
public int removeAgentCaps(AgentXSession session, org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID id)
public void addPingListener(PingListener l)
public void removePingListener(PingListener l)
protected void firePinged(PingEvent event)
Copyright © 2020 SNMP4J.org. All rights reserved.