Package org.opennms.netmgt.rtc
Class DataManager
- java.lang.Object
-
- org.opennms.netmgt.rtc.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)
assetInfoChangedjava.util.Map<java.lang.String,RTCCategory>
getCategories()
getCategoriesEuiLevel
getEuiLevel(RTCCategory category)
Retrieves the availability statistics for the given categoryjava.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 categoryint
getServiceDownCount(int nodeid, RTCCategory category)
Get the service down count for the nodeid in the context of the passed categorydouble
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 categorydouble
getValue(RTCCategory category, long curTime, long rollingWindow)
Get the value(uptime) for the category in the last 'rollingWindow' starting at current timevoid
interfaceReparented(java.net.InetAddress ip, int oldNodeId, int newNodeId)
Reparent an interface.void
nodeCategoryMembershipChanged(int nodeid)
nodeCategoryMembershipChangedvoid
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.
-
-
-
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 interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
java.sql.SQLException
- if there is an error reading initial data from the databaseFilterParseException
- if a rule in the categories.xml was incorrectRTCException
- if the initialization/data reading does not go throughorg.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 idip
- the IP addresssvcName
- 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 idip
- the IP addresssvcName
- the service namet
- 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 idip
- the IP addresssvcName
- the service namet
- 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 deletedip
- the ip on which service was deletedsvcName
- 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 errorFilterParseException
- if filtering the data against the category rule fails due to the rule being incorrectRTCException
- 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 reparentoldNodeId
- the node that the IP belonged to earliernewNodeId
- 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 tocurTime
- the current timerollingWindow
- 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 calculatedcatLabel
- the category to which the node should belong tocurTime
- the current timerollingWindow
- 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 calculatedcatLabel
- 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 calculatedcatLabel
- 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 java.util.Map<java.lang.String,RTCCategory> getCategories()
getCategories
- Specified by:
getCategories
in interfaceAvailabilityService
- Returns:
- the categories
-
getNodes
public java.util.Collection<java.lang.Integer> getNodes(RTCCategory category)
-
getEuiLevel
public EuiLevel getEuiLevel(RTCCategory category)
Description copied from interface:AvailabilityService
Retrieves the availability statistics for the given category- Specified by:
getEuiLevel
in interfaceAvailabilityService
- Returns:
- a
EuiLevel
object.
-
-