org.opennms.netmgt.rtc
Class DataManager

java.lang.Object
  extended by org.opennms.netmgt.rtc.DataManager

public class DataManager
extends Object

Contains and maintains all the data for the RTC. The basic datablock is a 'RTCNode' that gets added to relevant 'RTCCategory's. it also gets added to a map with different keys for easy lookup The map('RTCHashMap') is keyed with 'RTCNodeKey's(a nodeid/ip/svc combination), nodeid/ip combinations and nodeid and these keys either lookup a single RTCNode or lists of 'RTCNode's Incoming events have a method in the DataManager to alter data - for e.g., a 'nodeGainedService' event would result in the 'nodeGainedService()' method being called by the DataUpdater(s).

Author:
Sowmya Nataraj , OpenNMS.org

Constructor Summary
DataManager()
          Constructor.
 
Method Summary
 void assetInfoChanged(long nodeid)
           
 Map<String,RTCCategory> getCategories()
           
 int getServiceCount(long nodeid, String catLabel)
          Get the service count for the nodeid in the context of the passed category
 int getServiceDownCount(long nodeid, String catLabel)
          Get the service down count for the nodeid in the context of the passed category
 double getValue(long nodeid, String catLabel, long curTime, long rollingWindow)
          Get the value(uptime) for the nodeid in the last 'rollingWindow' starting at current time in the context of the passed category
 double getValue(String catLabel, long curTime, long rollingWindow)
          Get the value(uptime) for the category in the last 'rollingWindow' starting at current time
 void interfaceDown(long nodeid, String ip, long t)
          Add a lost service entry to the right nodes.
 void interfaceReparented(String ip, long oldNodeId, long newNodeId)
          Reparent an interface.
 void interfaceUp(long nodeid, String ip, long t)
          Add a regained service entry to the right nodes.
 void nodeCategoryMembershipChanged(long nodeid)
           
 void nodeDown(long nodeid, long t)
          Add a lost service entry to the right nodes.
 void nodeGainedService(long nodeid, String ip, String svcName)
          Handles a node gained service event.
 void nodeLostService(long nodeid, String ip, String svcName, long t)
          Handles a node lost service event.
 void nodeRegainedService(long nodeid, String ip, String svcName, long t)
          Add a regained service entry to the right node.
 void nodeUp(long nodeid, long t)
          Add a regained service entry to the right nodes.
 void rtcNodeRescan(long nodeid)
          Update the categories for a node.
 void serviceDeleted(long nodeid, String ip, String svcName)
          Remove node from the map and the categories on a 'serviceDeleted' event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataManager

public DataManager()
            throws SAXException,
                   IOException,
                   SQLException,
                   FilterParseException,
                   RTCException
Constructor. Parses categories from the categories.xml and populates them with 'RTCNode' objects created from data read from the database (services and outage tables)

Throws:
SQLException - if there is an error reading initial data from the database
FilterParseException - if a rule in the categories.xml was incorrect
RTCException - if the initialization/data reading does not go through
SAXException
IOException
Method Detail

nodeGainedService

public void nodeGainedService(long nodeid,
                              String ip,
                              String svcName)
Handles a node gained service event. Add a new entry to the map and the categories on a 'serviceGained' event

Parameters:
nodeid - the node id
ip - the IP address
svcName - the service name

nodeLostService

public void nodeLostService(long nodeid,
                            String ip,
                            String svcName,
                            long t)
Handles a node lost service event. Add a lost service entry to the right node

Parameters:
nodeid - the node id
ip - the IP address
svcName - the service name
t - the time at which service was lost

interfaceDown

public void interfaceDown(long nodeid,
                          String ip,
                          long t)
Add a lost service entry to the right nodes.

Parameters:
nodeid - the node id
ip - the IP address
t - the time at which service was lost

nodeDown

public void nodeDown(long nodeid,
                     long t)
Add a lost service entry to the right nodes.

Parameters:
nodeid - the node id
t - the time at which service was lost

nodeUp

public void nodeUp(long nodeid,
                   long t)
Add a regained service entry to the right nodes.

Parameters:
nodeid - the node id
t - the time at which service was regained

interfaceUp

public void interfaceUp(long nodeid,
                        String ip,
                        long t)
Add a regained service entry to the right nodes.

Parameters:
nodeid - the node id
ip - the IP address
t - the time at which service was regained

nodeRegainedService

public void nodeRegainedService(long nodeid,
                                String ip,
                                String svcName,
                                long t)
Add a regained service entry to the right node.

Parameters:
nodeid - the node id
ip - the IP address
svcName - the service name
t - the time at which service was regained

serviceDeleted

public void serviceDeleted(long nodeid,
                           String ip,
                           String svcName)
Remove node from the map and the categories on a 'serviceDeleted' event.

Parameters:
nodeid - the nodeid on which service was deleted
ip - the ip on which service was deleted
svcName - the service that was deleted

assetInfoChanged

public void assetInfoChanged(long nodeid)

nodeCategoryMembershipChanged

public void nodeCategoryMembershipChanged(long nodeid)

rtcNodeRescan

public void rtcNodeRescan(long nodeid)
                   throws SQLException,
                          FilterParseException,
                          RTCException
Update the categories for a node. This method will update the categories for all interfaces on a node.

Parameters:
nodeid - the nodeid on which SNMP service was added
Throws:
SQLException - if the database read fails due to an SQL error
FilterParseException - if filtering the data against the category rule fails due to the rule being incorrect
RTCException - if the database read or filtering the data against the category rule fails for some reason

interfaceReparented

public void interfaceReparented(String ip,
                                long oldNodeId,
                                long newNodeId)
Reparent an interface. This effectively means updating the nodelist of the categories and the map Use the ip/oldnodeid combination to get all nodes that will be affected - for each of these nodes, remove the old entry and add a new one with new keys to the map Note: Each of these nodes could belong to more than one category. However, category rule evaluation is done based ONLY on the IP - therefore changing the nodeID on the node should update the categories appropriately

Parameters:
ip - the interface to reparent
oldNodeId - the node that the ip belonged to earlier
newNodeId - the node that the ip now belongs to

getValue

public double getValue(String catLabel,
                       long curTime,
                       long rollingWindow)
Get the value(uptime) for the category in the last 'rollingWindow' starting at current time

Parameters:
catLabel - the category to which the node should belong to
curTime - the current time
rollingWindow - the window for which value is to be calculated
Returns:
the value(uptime) for the category in the last 'rollingWindow' starting at current time

getValue

public double getValue(long nodeid,
                       String catLabel,
                       long curTime,
                       long rollingWindow)
Get the value(uptime) for the nodeid in the last 'rollingWindow' starting at current time in the context of the passed category

Parameters:
nodeid - the node for which value is to be calculated
catLabel - the category to which the node should belong to
curTime - the current time
rollingWindow - the window for which value is to be calculated
Returns:
the value(uptime) for the node in the last 'rollingWindow' starting at current time in the context of the passed category

getServiceCount

public int getServiceCount(long nodeid,
                           String catLabel)
Get the service count for the nodeid in the context of the passed category

Parameters:
nodeid - the node for which service count is to be calculated
catLabel - the category to which the node should belong to
Returns:
the service count for the nodeid in the context of the passed category

getServiceDownCount

public int getServiceDownCount(long nodeid,
                               String catLabel)
Get the service down count for the nodeid in the context of the passed category

Parameters:
nodeid - the node for which service down count is to be calculated
catLabel - the category to which the node should belong to
Returns:
the service down count for the nodeid in the context of the passed category

getCategories

public Map<String,RTCCategory> getCategories()
Returns:
the categories


Copyright © 2009. All Rights Reserved.