public class CommandProcessor extends Object implements org.snmp4j.CommandResponder, NotificationOriginator
CommandProcessor
is the central glue code that puts together
the various sub-systems of a SNMP agent.Modifier and Type | Field and Description |
---|---|
protected CoexistenceInfoProvider |
coexistenceProvider |
protected Vector<MOServer> |
moServers |
protected NotificationOriginator |
notificationOriginator |
protected List<org.snmp4j.smi.OctetString> |
ownContextEngineIDs |
protected Vector<RequestHandler<SnmpRequest>> |
pduHandler |
protected ProxyMap |
proxyForwarder |
protected RequestFactory<org.snmp4j.CommandResponderEvent,org.snmp4j.PDU,SnmpRequest> |
requestFactory |
protected TemporaryList<Request> |
requestList |
protected org.snmp4j.util.WorkerPool |
threadPool |
protected VACM |
vacm |
Constructor and Description |
---|
CommandProcessor(org.snmp4j.smi.OctetString contextEngineID)
Creates a
CommandProcessor and registers all PDU types
with the supplied contextEngineID as well as with
MPv3.LOCAL_ENGINE_ID as required by RFC 5343. |
Modifier and Type | Method and Description |
---|---|
void |
addCounterListener(org.snmp4j.event.CounterListener l) |
void |
addMOServer(MOServer server) |
void |
addPduHandler(RequestHandler<SnmpRequest> handler) |
ProxyForwarder |
addProxyForwarder(ProxyForwarder proxyForwarder,
org.snmp4j.smi.OctetString contextEngineID,
int proxyType) |
protected void |
dispatchCommand(org.snmp4j.CommandResponderEvent command,
CoexistenceInfo cinfo) |
protected void |
finalizeRequest(org.snmp4j.CommandResponderEvent command,
SnmpRequest req,
MOServer server) |
protected void |
fireIncrementCounter(org.snmp4j.event.CounterEvent event) |
CoexistenceInfoProvider |
getCoexistenceProvider() |
org.snmp4j.smi.OctetString |
getContextEngineID() |
protected RequestHandler<SnmpRequest> |
getHandler(int pduType) |
int |
getInternalRequestTimeout()
Gets the internal request timeout millis.
|
NotificationOriginator |
getNotificationOriginator() |
ProxyMap |
getProxyForwarder() |
TemporaryList<Request> |
getRequestList() |
MOServer |
getServer(org.snmp4j.smi.OctetString context) |
VACM |
getVacm() |
protected org.snmp4j.smi.OctetString |
getViewName(org.snmp4j.CommandResponderEvent req,
CoexistenceInfo cinfo,
int viewType) |
Object |
notify(org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID notificationID,
org.snmp4j.smi.TimeTicks sysUpTime,
org.snmp4j.smi.VariableBinding[] vbs)
Sends notifications (traps) to all appropriate notification targets.
|
Object |
notify(org.snmp4j.smi.OctetString context,
org.snmp4j.smi.OID notificationID,
org.snmp4j.smi.VariableBinding[] vbs)
Sends notification/inform messages to all registered targets.
|
protected void |
processNextSubRequest(SnmpRequest request,
MOServer server,
org.snmp4j.smi.OctetString context,
SubRequest sreq) |
void |
processPdu(org.snmp4j.CommandResponderEvent event) |
protected void |
processRequest(org.snmp4j.CommandResponderEvent command,
CoexistenceInfo cinfo,
RequestHandler<SnmpRequest> handler) |
protected <R extends Request<Source,Response,? extends SubRequest>,Source,Response> |
processRequest(MOServer server,
RequestHandler<R> handler,
R req)
Processes (or re-process) a request and try to complete the request (thus
to complete any incomplete subrequests).
|
protected void |
release(MOServer server,
SnmpRequest req) |
void |
removeCounterListener(org.snmp4j.event.CounterListener l) |
void |
removeMOServer(MOServer server) |
void |
removePduHandler(RequestHandler handler) |
ProxyForwarder |
removeProxyForwarder(org.snmp4j.smi.OctetString contextEngineID,
int proxyType) |
protected void |
reprocessRequest(MOServer server,
SnmpRequest req) |
protected void |
sendResponse(org.snmp4j.CommandResponderEvent requestEvent,
org.snmp4j.PDU response) |
protected void |
setAuthorizationError(Request req,
int vacmStatus) |
void |
setCoexistenceProvider(CoexistenceInfoProvider coexistenceProvider) |
void |
setContextEngineID(org.snmp4j.smi.OctetString contextEngineID) |
void |
setInternalRequestTimeout(int timeoutMillis)
Sets the internal request timeout.
|
void |
setNotificationOriginator(NotificationOriginator notificationOriginator) |
void |
setThreadPool(org.snmp4j.util.WorkerPool threadPool)
Deprecated.
Use
setWorkerPool(org.snmp4j.util.WorkerPool) instead |
void |
setVacm(VACM vacm) |
void |
setWorkerPool(org.snmp4j.util.WorkerPool threadPool)
Sets the internal thread pool for task execution.
|
protected void |
unlockManagedObjectIfLockedByLookup(MOServer server,
ManagedObject mo,
LockRequest lockRequest)
Unlock the provided
ManagedObject if the also provided LockRequest indicates
that the managed object was locked by a preceding MOServer.lookup(MOQuery, LockRequest) operation. |
protected org.snmp4j.util.WorkerPool threadPool
protected VACM vacm
protected List<org.snmp4j.smi.OctetString> ownContextEngineIDs
protected final Vector<RequestHandler<SnmpRequest>> pduHandler
protected TemporaryList<Request> requestList
protected RequestFactory<org.snmp4j.CommandResponderEvent,org.snmp4j.PDU,SnmpRequest> requestFactory
protected NotificationOriginator notificationOriginator
protected ProxyMap proxyForwarder
protected CoexistenceInfoProvider coexistenceProvider
public CommandProcessor(org.snmp4j.smi.OctetString contextEngineID)
CommandProcessor
and registers all PDU types
with the supplied contextEngineID as well as with
MPv3.LOCAL_ENGINE_ID
as required by RFC 5343.contextEngineID
- the custom engine ID to use (should equal the engineID
of the agent, i.e. USM).public void setInternalRequestTimeout(int timeoutMillis)
timeoutMillis
- the maximum number of milli-seconds a request can be processed.public int getInternalRequestTimeout()
public void processPdu(org.snmp4j.CommandResponderEvent event)
processPdu
in interface org.snmp4j.CommandResponder
public void setThreadPool(org.snmp4j.util.WorkerPool threadPool)
setWorkerPool(org.snmp4j.util.WorkerPool)
insteadthreadPool
- a pool of workers/threads which can execute tasks.public void setWorkerPool(org.snmp4j.util.WorkerPool threadPool)
threadPool
- a pool of workers/threads which can execute tasks.public VACM getVacm()
public void setVacm(VACM vacm)
public org.snmp4j.smi.OctetString getContextEngineID()
public void setContextEngineID(org.snmp4j.smi.OctetString contextEngineID)
public Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.VariableBinding[] vbs)
ThreadPool
to send the message(s) via the
NotificationOriginator
(see getNotificationOriginator()
) to the targets specified by the
SnmpTargetMIB and SnmpNotificationMIB instances supplied to the
notification originator.notify
in interface NotificationOriginator
context
- 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.NotificationOriginator
determines on behalf of the
SNMP-NOTIFICTON-MIB contents whether a notification is sent as
trap/notification or as inform request, the returned array will contain
an element for each addressed target, but only a response PDU for
inform targets.
null
will be returned when sending the notification failed
because there is no NotificationOriginator
set.
NOTE: If this command processor is using a ThreadPool then the returned
object will be NotificationTask
instance. If all response have
been received Object.notify()
will be called on the returned
NotificationTask
object by the sending thread.
public Object notify(org.snmp4j.smi.OctetString context, org.snmp4j.smi.OID notificationID, org.snmp4j.smi.TimeTicks sysUpTime, org.snmp4j.smi.VariableBinding[] vbs)
NotificationOriginator
notify
in interface NotificationOriginator
context
- 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.sysUpTime
- the value of the sysUpTime for the context context
. This
value will be included in the generated notification as
sysUpTime.0
.vbs
- an array of VariableBinding
instances representing the
payload of the notification.NotificationOriginator
determines on behalf of the
SNMP-NOTIFICTON-MIB contents whether a notification is sent as
trap/notification or as inform request, the returned array contains
an element for each addressed target, but only a response PDU for
inform targets.public void setNotificationOriginator(NotificationOriginator notificationOriginator)
public void setCoexistenceProvider(CoexistenceInfoProvider coexistenceProvider)
public ProxyForwarder addProxyForwarder(ProxyForwarder proxyForwarder, org.snmp4j.smi.OctetString contextEngineID, int proxyType)
public ProxyForwarder removeProxyForwarder(org.snmp4j.smi.OctetString contextEngineID, int proxyType)
protected RequestHandler<SnmpRequest> getHandler(int pduType)
protected void dispatchCommand(org.snmp4j.CommandResponderEvent command, CoexistenceInfo cinfo)
protected void processRequest(org.snmp4j.CommandResponderEvent command, CoexistenceInfo cinfo, RequestHandler<SnmpRequest> handler)
protected void reprocessRequest(MOServer server, SnmpRequest req)
protected <R extends Request<Source,Response,? extends SubRequest>,Source,Response> void processRequest(MOServer server, RequestHandler<R> handler, R req)
R
- the Request
type to process.Source
- the source object that created the request for processing.Response
- the response PDU type created by the request processing.server
- the MOServer
instance to use for accessing instrumentation.handler
- the RequestHandler
to use to process the request.req
- the Request
.protected void finalizeRequest(org.snmp4j.CommandResponderEvent command, SnmpRequest req, MOServer server)
protected void release(MOServer server, SnmpRequest req)
protected void sendResponse(org.snmp4j.CommandResponderEvent requestEvent, org.snmp4j.PDU response)
protected void setAuthorizationError(Request req, int vacmStatus)
public void addPduHandler(RequestHandler<SnmpRequest> handler)
public void removePduHandler(RequestHandler handler)
public void addMOServer(MOServer server)
public void removeMOServer(MOServer server)
public MOServer getServer(org.snmp4j.smi.OctetString context)
public TemporaryList<Request> getRequestList()
public NotificationOriginator getNotificationOriginator()
public ProxyMap getProxyForwarder()
public CoexistenceInfoProvider getCoexistenceProvider()
protected org.snmp4j.smi.OctetString getViewName(org.snmp4j.CommandResponderEvent req, CoexistenceInfo cinfo, int viewType)
protected void processNextSubRequest(SnmpRequest request, MOServer server, org.snmp4j.smi.OctetString context, SubRequest sreq) throws NoSuchElementException
NoSuchElementException
protected void unlockManagedObjectIfLockedByLookup(MOServer server, ManagedObject mo, LockRequest lockRequest)
ManagedObject
if the also provided LockRequest
indicates
that the managed object was locked by a preceding MOServer.lookup(MOQuery, LockRequest)
operation.server
- a MOServer that put the lock.mo
- the possibly locked managed object.lockRequest
- the lock request with the status of the (potentially acquired) lock.public void addCounterListener(org.snmp4j.event.CounterListener l)
public void removeCounterListener(org.snmp4j.event.CounterListener l)
protected void fireIncrementCounter(org.snmp4j.event.CounterEvent event)
Copyright © 2020 SNMP4J.org. All rights reserved.