OpenNMS API 1.2.3

org.opennms.netmgt.outage
Class OutageWriter

java.lang.Object
  extended byorg.opennms.netmgt.outage.OutageWriter
All Implemented Interfaces:
java.lang.Runnable

public final class OutageWriter
extends java.lang.Object
implements java.lang.Runnable

When a 'nodeLostService' is received, it is made sure that there is no 'open' outage record in the 'outages' table for this nodeid/ipaddr/serviceid - i.e that there is not already a record for this n/i/s where the 'lostService' time is known and the 'regainedService' time is NULL - if there is, the current 'lostService' event is ignored else a new outage is created. The 'interfaceDown' is similar to the 'nodeLostService' except that it acts relevant to a nodeid/ipaddr combination and a 'nodeDown' acts on a nodeid. When a 'nodeRegainedService' is received and there is an 'open' outage for the nodeid/ipaddr/serviceid, the outage is cleared. If not, the event is placed in the event cache in case a race condition has occurred that puts the "up" event in before the "down" event. (currently inactive). The 'interfaceUp' is similar to the 'nodeRegainedService' except that it acts relevant to a nodeid/ipaddr combination and a 'nodeUp' acts on a nodeid. When a 'deleteService' is received, the appropriate entry is marked for deletion is the 'ifservices' table - if this entry is the only entry for a node/ip combination, the corresponding entry in the 'ipinterface' table is marked for deletion and this is then cascaded to the node table All deletions are followed by an appropriate event(serviceDeleted or interfaceDeleted or..) being generated and sent to eventd. When an 'interfaceReparented' event is received, 'outages' table entries associated with the old nodeid/interface pairing are changed so that those outage entries will be associated with the new nodeid/interface pairing. The nodeLostService, interfaceDown, nodeDown, nodeUp, interfaceUp, nodeRegainedService, deleteService events update the svcLostEventID and the svcRegainedEventID fields as approppriate. The interfaceReparented event has no impact on these eventid reference fields.

Author:
Sowmya Nataraj , Mike Davidson , OpenNMS.org

Field Summary
private  Event m_event
          The event from which data is to be read.
private  boolean m_generateNodeDeletedEvent
           
private  BasicNetwork m_network
           
private  OutageManager m_outageMgr
           
private static java.lang.String SNMP_SVC
           
private static java.lang.String SNMPV2_SVC
           
 
Constructor Summary
OutageWriter(OutageManager mgr, Event event)
          The constructor.
 
Method Summary
private  Event createEvent(java.lang.String uei, java.util.Date eventDate, long nodeID, java.lang.String ipAddr, java.lang.String serviceName)
          This method creates an event for the passed parameters.
private  java.sql.Connection getConnection()
           
private  BasicInterface getInterface(long nodeID, java.lang.String ipAddr)
           
private  BasicNetwork getNetwork()
           
private  BasicNode getNode(long nodeID)
           
private  BasicService getService(BasicInterface iface, long serviceID)
           
private  BasicService getService(long nodeID, java.lang.String ipAddr, long serviceID)
           
private  long getServiceID(java.lang.String name)
           This method is used to convert the service name into a service id.
private  void handleInterfaceDown(long eventID, java.lang.String eventTime, BasicInterface iface)
          Handles interface down events.
private  void handleInterfaceReparented(java.lang.String ipAddr, Parms eventParms)
           Record the 'interfaceReparented' event in the outages table.
private  void handleInterfaceUp(long eventID, java.lang.String eventTime, BasicInterface iface)
          Handles interface up events.
private  void handleNodeDown(long eventID, java.lang.String eventTime, BasicNode node)
          Handles node down events.
private  void handleNodeLostService(long eventID, java.lang.String eventTime, BasicService svc)
          Handles node lost service events.
private  void handleNodeRegainedService(long eventID, java.lang.String eventTime, BasicService svc)
          Hanlde node regained service events.
private  void handleNodeUp(long eventID, java.lang.String eventTime, BasicNode node)
          Handle node up events.
private  void processEvent()
          Process an event.
 void run()
          Process the event depending on the UEI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNMP_SVC

private static final java.lang.String SNMP_SVC
See Also:
Constant Field Values

SNMPV2_SVC

private static final java.lang.String SNMPV2_SVC
See Also:
Constant Field Values

m_event

private Event m_event
The event from which data is to be read.


m_generateNodeDeletedEvent

private boolean m_generateNodeDeletedEvent

m_outageMgr

private OutageManager m_outageMgr

m_network

private BasicNetwork m_network
Constructor Detail

OutageWriter

public OutageWriter(OutageManager mgr,
                    Event event)
The constructor.

Parameters:
mgr -
event - the event for this outage writer.
Method Detail

getServiceID

private long getServiceID(java.lang.String name)
                   throws java.sql.SQLException

This method is used to convert the service name into a service id. It first looks up the information from a service map in OutagesManager and if no match is found, by performing a lookup in the database. If the conversion is successful then the corresponding integer identifier will be returned to the caller.

Parameters:
name - The name of the service
Returns:
The integer identifier for the service name.
Throws:
java.sql.SQLException - if there is an error accessing the stored data, the SQL text is malformed, or the result cannot be obtained.
See Also:
DB_GET_SVC_ID

handleNodeLostService

private void handleNodeLostService(long eventID,
                                   java.lang.String eventTime,
                                   BasicService svc)
Handles node lost service events. Record the 'nodeLostService' event in the outages table - create a new outage entry if the service is not already down.


handleInterfaceDown

private void handleInterfaceDown(long eventID,
                                 java.lang.String eventTime,
                                 BasicInterface iface)
Handles interface down events. Record the 'interfaceDown' event in the outages table - create a new outage entry for each active service of the nodeid/ip if service not already down.


handleNodeDown

private void handleNodeDown(long eventID,
                            java.lang.String eventTime,
                            BasicNode node)
Handles node down events. Record the 'nodeDown' event in the outages table - create a new outage entry for each active service of the nodeid if service is not already down.


handleNodeUp

private void handleNodeUp(long eventID,
                          java.lang.String eventTime,
                          BasicNode node)
Handle node up events. Record the 'nodeUp' event in the outages table - close all open outage entries for the nodeid in the outages table.


handleInterfaceUp

private void handleInterfaceUp(long eventID,
                               java.lang.String eventTime,
                               BasicInterface iface)
Handles interface up events. Record the 'interfaceUp' event in the outages table - close all open outage entries for the nodeid/ip in the outages table.


handleNodeRegainedService

private void handleNodeRegainedService(long eventID,
                                       java.lang.String eventTime,
                                       BasicService svc)
Hanlde node regained service events. Record the 'nodeRegainedService' event in the outages table - close the outage entry in the table if the service is currently down.

Parameters:
svc - TODO

handleInterfaceReparented

private void handleInterfaceReparented(java.lang.String ipAddr,
                                       Parms eventParms)

Record the 'interfaceReparented' event in the outages table. Change'outages' table entries associated with the old nodeid/interface pairing so that those outage entries will be associated with the new nodeid/interface pairing.

Note: This event has no impact on the event id reference fields


getConnection

private java.sql.Connection getConnection()
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getNetwork

private BasicNetwork getNetwork()

createEvent

private Event createEvent(java.lang.String uei,
                          java.util.Date eventDate,
                          long nodeID,
                          java.lang.String ipAddr,
                          java.lang.String serviceName)
This method creates an event for the passed parameters.

Parameters:
uei - Event to generate and send
eventDate - Time to be set for the event
nodeID - Node identifier associated with this event
ipAddr - Interface address associated with this event
serviceName - Service name associated with this event

processEvent

private void processEvent()
Process an event. Read the event UEI, nodeid, interface and service - depending on the UEI, read event parms, if necessary, and process as appropriate.


getNode

private BasicNode getNode(long nodeID)

getInterface

private BasicInterface getInterface(long nodeID,
                                    java.lang.String ipAddr)

getService

private BasicService getService(long nodeID,
                                java.lang.String ipAddr,
                                long serviceID)

getService

private BasicService getService(BasicInterface iface,
                                long serviceID)

run

public void run()
Process the event depending on the UEI.

Specified by:
run in interface java.lang.Runnable

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.