Class DataManager

  • All Implemented Interfaces:
    AvailabilityService, org.springframework.beans.factory.InitializingBean

    public class DataManager
    extends java.lang.Object
    implements AvailabilityService, org.springframework.beans.factory.InitializingBean
    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

      Constructors 
      Constructor Description
      DataManager()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterPropertiesSet()
      Constructor.
      void assetInfoChanged​(int nodeid)
      assetInfoChanged
      java.util.Map<java.lang.String,​RTCCategory> getCategories()
      getCategories
      EuiLevel getEuiLevel​(RTCCategory category)
      Retrieves the availability statistics for the given category
      java.util.Collection<java.lang.Integer> getNodes​(RTCCategory category)  
      int getServiceCount​(int nodeid, RTCCategory category)
      Get the service count for the nodeid in the context of the passed category
      int getServiceDownCount​(int nodeid, RTCCategory category)
      Get the service down count for the nodeid in the context of the passed category
      double getValue​(int nodeid, RTCCategory category, 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​(RTCCategory category, long curTime, long rollingWindow)
      Get the value(uptime) for the category in the last 'rollingWindow' starting at current time
      void interfaceReparented​(java.net.InetAddress ip, int oldNodeId, int newNodeId)
      Reparent an interface.
      void nodeCategoryMembershipChanged​(int nodeid)
      nodeCategoryMembershipChanged
      void nodeGainedService​(int nodeid, java.net.InetAddress ip, java.lang.String svcName)
      Handles a node gained service event.
      void outageCreated​(int nodeid, java.net.InetAddress ip, java.lang.String svcName, long t)
      Handles a node outage created event.
      void outageResolved​(int nodeid, java.net.InetAddress ip, java.lang.String svcName, long t)
      Handles a node outage resolved event.
      void rtcNodeRescan​(int nodeid)
      Update the categories for a node.
      void serviceDeleted​(int nodeid, java.net.InetAddress ip, java.lang.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()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Constructor. Parses categories from the categories.xml and populates them with 'RTCNode' objects created from data read from the database (services and outage tables)
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.sql.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
        org.xml.sax.SAXException - if any.
        java.io.IOException - if any.
        java.sql.SQLException - if any.
        FilterParseException - if any.
        RTCException - if any.
        java.lang.Exception
      • nodeGainedService

        public void nodeGainedService​(int nodeid,
                                      java.net.InetAddress ip,
                                      java.lang.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
      • outageCreated

        public void outageCreated​(int nodeid,
                                  java.net.InetAddress ip,
                                  java.lang.String svcName,
                                  long t)
        Handles a node outage created 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
      • outageResolved

        public void outageResolved​(int nodeid,
                                   java.net.InetAddress ip,
                                   java.lang.String svcName,
                                   long t)
        Handles a node outage resolved event. 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​(int nodeid,
                                   java.net.InetAddress ip,
                                   java.lang.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​(int nodeid)

        assetInfoChanged

        Parameters:
        nodeid - a long.
      • nodeCategoryMembershipChanged

        public void nodeCategoryMembershipChanged​(int nodeid)

        nodeCategoryMembershipChanged

        Parameters:
        nodeid - a long.
      • rtcNodeRescan

        public void rtcNodeRescan​(int nodeid)
                           throws java.sql.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:
        java.sql.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​(java.net.InetAddress ip,
                                        int oldNodeId,
                                        int 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​(RTCCategory category,
                               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​(int nodeid,
                               RTCCategory category,
                               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​(int nodeid,
                                   RTCCategory category)
        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​(int nodeid,
                                       RTCCategory category)
        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
      • getNodes

        public java.util.Collection<java.lang.Integer> getNodes​(RTCCategory category)