org.opennms.netmgt.trapd
Class TrapHandler

java.lang.Object
  extended by org.opennms.netmgt.trapd.TrapHandler
All Implemented Interfaces:
org.opennms.core.fiber.Fiber, org.opennms.core.fiber.PausableFiber, org.opennms.netmgt.snmp.TrapNotificationListener, org.opennms.netmgt.snmp.TrapProcessorFactory

public class TrapHandler
extends Object
implements org.opennms.core.fiber.PausableFiber, org.opennms.netmgt.snmp.TrapProcessorFactory, org.opennms.netmgt.snmp.TrapNotificationListener

The Trapd listens for SNMP traps on the standard port(162). Creates a SnmpTrapSession and implements the SnmpTrapHandler to get callbacks when traps are received

The received traps are converted into XML and sent to eventd

Note: Trapd is a PausableFiber so as to receive control events. However, a 'pause' on Trapd has no impact on the receiving and processing of traps

Author:
Brian Weaver , Sowmya Nataraj , Lawrence Karnowski , Mike Davidson , Tarus Balog , OpenNMS.org

Field Summary
 
Fields inherited from interface org.opennms.core.fiber.PausableFiber
PAUSE_PENDING, PAUSED, RESUME_PENDING
 
Fields inherited from interface org.opennms.core.fiber.Fiber
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
 
Constructor Summary
TrapHandler()
           Constructs a new Trapd object that receives and forwards trap messages via JSDT.
 
Method Summary
 org.opennms.netmgt.snmp.TrapProcessor createTrapProcessor()
           
 EventIpcManager getEventManager()
           
static TrapHandler getInstance()
          Returns the singular instance of the trapd daemon.
 String getName()
          Returns the name of the service.
 int getStatus()
          Returns the current status of the service.
 void init()
           
 void pause()
          Pauses Trapd
 void resume()
          Resumes Trapd
 void setEventManager(EventIpcManager eventMgr)
           
 void setTrapdConfig(TrapdConfig trapdConfig)
           
 void start()
          Create the SNMP trap session and create the communication channel to communicate with eventd.
 void stop()
          Stops the currently running service.
 void trapError(int error, String msg)
           
 void trapReceived(org.opennms.netmgt.snmp.TrapNotification trapNotification)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrapHandler

public TrapHandler()

Constructs a new Trapd object that receives and forwards trap messages via JSDT. The session is initialized with the default client name of OpenNMS.trapd. The trap session is started on the default port, as defined by the SNMP libarary.

See Also:
SnmpTrapSession
Method Detail

setTrapdConfig

public void setTrapdConfig(TrapdConfig trapdConfig)

createTrapProcessor

public org.opennms.netmgt.snmp.TrapProcessor createTrapProcessor()
Specified by:
createTrapProcessor in interface org.opennms.netmgt.snmp.TrapProcessorFactory

trapReceived

public void trapReceived(org.opennms.netmgt.snmp.TrapNotification trapNotification)
Specified by:
trapReceived in interface org.opennms.netmgt.snmp.TrapNotificationListener

init

public void init()

start

public void start()
Create the SNMP trap session and create the communication channel to communicate with eventd.

Specified by:
start in interface org.opennms.core.fiber.Fiber
Throws:
UndeclaredThrowableException - if an unexpected database, or IO exception occurs.
See Also:
SnmpTrapSession, SnmpTrapHandler

pause

public void pause()
Pauses Trapd

Specified by:
pause in interface org.opennms.core.fiber.PausableFiber

resume

public void resume()
Resumes Trapd

Specified by:
resume in interface org.opennms.core.fiber.PausableFiber

stop

public void stop()
Stops the currently running service. If the service is not running then the command is silently discarded.

Specified by:
stop in interface org.opennms.core.fiber.Fiber

getStatus

public int getStatus()
Returns the current status of the service.

Specified by:
getStatus in interface org.opennms.core.fiber.Fiber
Returns:
The service's status.

getInstance

public static TrapHandler getInstance()
Returns the singular instance of the trapd daemon. There can be only one instance of this service per virtual machine.


getName

public String getName()
Returns the name of the service.

Specified by:
getName in interface org.opennms.core.fiber.Fiber
Returns:
The service's name.

getEventManager

public EventIpcManager getEventManager()

setEventManager

public void setEventManager(EventIpcManager eventMgr)

trapError

public void trapError(int error,
                      String msg)
Specified by:
trapError in interface org.opennms.netmgt.snmp.TrapNotificationListener


Copyright ? 2007. All Rights Reserved.