|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.management.snmp.manager.SnmpEventReportDispatcher
public class SnmpEventReportDispatcher
Implements an SNMP event report dispatcher.
Listener objects can be registered in an
SnmpEventReportDispatcher
.
The SnmpEventReportDispatcher
listens for any incoming
trap or inform PDU: each time it receives a trap or an inform PDU, it
informs all the listeners.
By default, the dispatcher listens to the UDP port 162.
The SnmpEventReportDispatcher
class implements
Runnable
: it is expected to be used as a
Thread
object. The run method never returns.
An SnmpEventReportDispatcher
object maintains 2 lists of
listener objects. The listener objects implement the
SnmpTrapListener
or SnmpInformListener
interface and will be activated each time an SNMP event report (trap
or inform PDU) is received.
By default, the SnmpEventReportDispatcher will create one thread per received packet, and will invoke listener callbacks in that thread. Subclasses may override this behavior by redefining handlePacket() and handleCallback().
SnmpTrapListener
,
SnmpInformListener
Constructor Summary | |
---|---|
SnmpEventReportDispatcher()
Initializes an SnmpEventReportDispatcher which
listens on the port 162. |
|
SnmpEventReportDispatcher(int portNumber)
Initializes an SnmpEventReportDispatcher which listens
on the specified port. |
|
SnmpEventReportDispatcher(SnmpEngine engine,
int portNumber)
Initializes an SnmpEventReportDispatcher which listens
on the specified port. |
|
SnmpEventReportDispatcher(SnmpEngine engine,
int portNumber,
InetAddress address)
Initializes an SnmpEventReportDispatcher which listens
on the specified port. |
|
SnmpEventReportDispatcher(SnmpEngineParameters parameters,
SnmpEngineFactory factory,
int portNumber)
Initializes an SnmpEventReportDispatcher which listens
on the specified port. |
|
SnmpEventReportDispatcher(SnmpEngineParameters parameters,
SnmpEngineFactory factory,
int portNumber,
InetAddress address)
Initializes an SnmpEventReportDispatcher which listens
on the specified port. |
Method Summary | |
---|---|
void |
addInformListener(SnmpInformListener handler)
Adds an inform request listener to this SnmpEventReportDispatcher . |
void |
addTrapListener(SnmpTrapListener handler)
Adds a trap listener to this SnmpEventReportDispatcher . |
void |
close()
Closes the receiving socket, and terminates the receiving loop. |
boolean |
containsInformListener(SnmpInformListener handler)
Returns true if the specified object is listening
to inform requests. |
boolean |
containsTrapListener(SnmpTrapListener handler)
Returns true if the specified object is listening to traps. |
SnmpEngine |
getEngine()
Engine the SnmpEventReportDispatcher is linked with. |
SnmpEngineId |
getEngineId()
Get the engine Id. |
Enumeration |
getInformListeners()
Gets all of the inform request listeners. |
SnmpPduFactory |
getPduFactory()
Gets the PDU factory associated to this SnmpEventReportDispatcher . |
Long |
getSnmpInASNParseErrs()
Returns the snmpInASNParseErrs value defined in the RFC 1907 Snmp Group. |
Long |
getSnmpInBadVersions()
Returns the snmpInBadVersions value defined in the RFC 1907 Snmp Group. |
Long |
getSnmpInInforms()
Returns the number of received informs. |
Long |
getSnmpInPkts()
Returns the snmpInPkts value defined in the RFC 1907 Snmp Group. |
Long |
getSnmpInTraps()
Returns the number of received traps. |
Long |
getSnmpInvalidMsgs()
Returns snmpInvalidMsgs as defined in RFC 2572 SNMP-MPD-MIB. |
Long |
getSnmpUnknownSecurityModels()
Returns snmpUnknownSecurityModels as defined in RFC 2572 SNMP-MPD-MIB. |
Enumeration |
getTrapListeners()
Gets all of the trap listeners. |
protected void |
handleCallback(Runnable callbackHandler)
This method invokes a listener callback. |
protected void |
handlePacket(Runnable packetHandler)
This method handles a received SNMP DatagramPacket. |
void |
removeInformListener(SnmpInformListener handler)
Removes an inform request listener. |
void |
removeTrapListener(SnmpTrapListener handler)
Removes a trap listener. |
void |
run()
Dispatching loop. |
void |
setPduFactory(SnmpPduFactory factory)
Sets the PDU factory associated to this SnmpEventReportDispatcher . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SnmpEventReportDispatcher() throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which
listens on the port 162.
It instantiates an SnmpEngine.
WARNING : The SnmpEngineId is computed as follow:
SnmpEngineId
time based.
IllegalArgumentException
- If one of the
specified configuration file doesn't exist.
SocketException
- If the object cannot bind to the port 162.public SnmpEventReportDispatcher(int portNumber) throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which listens
on the specified port.
It instantiates an SnmpEngine.
WARNING : The SnmpEngineId is computed as follow:
SnmpEngineId
time based.
portNumber
- The port number.
IllegalArgumentException
- If one of the
specified configuration file doesn't exist.
SocketException
- If the object cannot bind to the
specified port.public SnmpEventReportDispatcher(SnmpEngineParameters parameters, SnmpEngineFactory factory, int portNumber) throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which listens
on the specified port.
It instantiates an SnmpEngine.
WARNING : The SnmpEngineId is computed as follow:
SnmpEngineId
time based.
parameters
- The engine parameters to use.factory
- The factory to use in order to create the engine.portNumber
- The port number.
IllegalArgumentException
- If one of the
specified configuration file doesn't exist.
SocketException
- If the object cannot bind to the
specified port.public SnmpEventReportDispatcher(SnmpEngineParameters parameters, SnmpEngineFactory factory, int portNumber, InetAddress address) throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which listens
on the specified port.
It instantiates an SnmpEngine.
WARNING : The SnmpEngineId is computed as follow:
SnmpEngineId
time based.
parameters
- The engine parameters to use.factory
- The factory to use in order to create the engine.portNumber
- The port number.address
- The Ip address the dispatcher will listen for events
on. If null, the dispatcher will listen on localhost.
IllegalArgumentException
- If one of the
specified configuration file doesn't exist.
SocketException
- If the object cannot bind to the
specified port.public SnmpEventReportDispatcher(SnmpEngine engine, int portNumber) throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which listens
on the specified port.
engine
- The SnmpEngine
to use.portNumber
- The port number.
IllegalArgumentException
- if the passed engine is null.
SocketException
- If the object cannot bind to the
specified port.public SnmpEventReportDispatcher(SnmpEngine engine, int portNumber, InetAddress address) throws SocketException, IllegalArgumentException
SnmpEventReportDispatcher
which listens
on the specified port.
engine
- The SnmpEngine
to use.portNumber
- The port number.address
- The Ip address the dispatcher will listen for events
on. If null, the dispatcher will listen on localhost.
IllegalArgumentException
- if the passed engine is null.
SocketException
- If the object cannot bind to the
specified port.Method Detail |
---|
public Long getSnmpInTraps()
public Long getSnmpInInforms()
public Long getSnmpInPkts()
snmpInPkts
value defined in the RFC 1907 Snmp Group.
This value is the total number of received packets. It sums traps, informs, failed decoding packet, bad SNMP version packets and USM discovery requests.
public Long getSnmpInASNParseErrs()
snmpInASNParseErrs
value defined in the RFC 1907 Snmp Group.
public Long getSnmpInBadVersions()
snmpInBadVersions
value defined in the RFC 1907 Snmp Group.
public Long getSnmpInvalidMsgs()
snmpInvalidMsgs
as defined in RFC 2572 SNMP-MPD-MIB.
public Long getSnmpUnknownSecurityModels()
snmpUnknownSecurityModels
as defined in RFC 2572 SNMP-MPD-MIB.
public SnmpEngine getEngine()
SnmpEventReportDispatcher
is linked with.
public SnmpEngineId getEngineId()
public void close() throws IOException
IOException
protected void handleCallback(Runnable callbackHandler)
This method is provided as a hook for subclasses. The default behavior of this method is:
protected void handleCallback(final Runnable callbackHandler) { callbackHandler.run(); }
callbackHandler
- A Runnable object wrapping the listener
callback to be invoked.protected void handlePacket(Runnable packetHandler)
This method is provided as a hook for subclasses.
protected void handlePacket(final Runnable packetHandler) { (new Thread(packetHandler)).start(); }
packetHandler
- A Runnable object wrapping the packet
to be handled.public void run()
This method is normally called by Thread.start
.
run
in interface Runnable
public void addTrapListener(SnmpTrapListener handler)
SnmpEventReportDispatcher
.
handler
- The listener to add.public void addInformListener(SnmpInformListener handler)
SnmpEventReportDispatcher
.
handler
- The listener to add.public void removeTrapListener(SnmpTrapListener handler)
handler
- The listener to be removed.public void removeInformListener(SnmpInformListener handler)
handler
- The listener to be removed.public boolean containsTrapListener(SnmpTrapListener handler)
true
if the specified object is listening to traps.
handler
- A listener.
true
if it is a registered listener,
false
otherwise.public boolean containsInformListener(SnmpInformListener handler)
true
if the specified object is listening
to inform requests.
handler
- A listener.
true
if it is a registered listener,
false
otherwise.public Enumeration getTrapListeners()
SnmpTrapListener
objects.public Enumeration getInformListeners()
SnmpInformListener
objects.public SnmpPduFactory getPduFactory()
SnmpEventReportDispatcher
.
public void setPduFactory(SnmpPduFactory factory)
SnmpEventReportDispatcher
.
factory
- The PDU factory (if null, the default factory is set).
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |