Class RTCNode


  • public class RTCNode
    extends Object
    The main unit for the RTCManager.

    RTCNode is the main data unit for the RTCManager - these datablocks are created initially as data is read from the database and later if a 'nodeGainedService' is received - each node maintains its node id, ip address, service name and a list of 'RTCNodeSvcTime's

    Also, each node knows and maintains a list of categories that this tuple belongs to

    Author:
    Sowmya Kumaraswamy , OpenNMS.org
    See Also:
    RTCNodeSvcTime, RTCNodeSvcTimesList
    • Constructor Detail

      • RTCNode

        public RTCNode​(RTCNodeKey key,
                       long rollingWindow)

        Constructor for RTCNode.

        Parameters:
        key - a RTCNodeKey object.
      • RTCNode

        public RTCNode​(int nodeid,
                       InetAddress inetAddress,
                       String svcName,
                       long rollingWindow)
        Constructor.
        Parameters:
        nodeid - the node id
        inetAddress - the IP address
        svcName - the service
    • Method Detail

      • setNodeID

        public void setNodeID​(int id)
        Set the node ID.
        Parameters:
        id - the node ID
      • addSvcTime

        public void addSvcTime​(long losttime,
                               long regainedtime)
        Add a new 'RTCNodeSvcTime' entry for this node.
        Parameters:
        losttime - time at which service was lost
        regainedtime - time at which service was regained
      • addCategory

        public void addCategory​(String catLabel)
        Add to the category list for this node.
        Parameters:
        catLabel - category label of the category this node has been added to
      • removeCategory

        public void removeCategory​(String catLabel)
        Remove a category from the node's context.
        Parameters:
        catLabel - category label of the category this node has been added to
      • nodeLostService

        public void nodeLostService​(long t)
        Add a node lost service time. Add a losttime entry to the service times list - create a new service time entry in the list
        Parameters:
        t - the time at which service was lost
      • nodeRegainedService

        public void nodeRegainedService​(long t)
        Add a node regained service time. Add a regained time entry to the service times list - set the regained time in the last serice time entry in the list
        Parameters:
        t - the time at which node regained service
      • getNodeID

        public Integer getNodeID()
        Return the node ID.
        Returns:
        the node ID
      • getSvcName

        public String getSvcName()
        Return the service name.
        Returns:
        the service name
      • getIP

        public InetAddress getIP()
        Return the IP address.
        Returns:
        the IP address
      • belongsTo

        public boolean belongsTo​(String catLabel)
        Check if this node belongs to the category.
        Parameters:
        catLabel - category label
        Returns:
        true if the node belongs to this category, false otherwise
      • getCategories

        public List<String> getCategories()
        Return the list of categories this node belongs to.
        Returns:
        list of categories for the node.
      • getDownTime

        public long getDownTime​(String cat,
                                long curTime,
                                long rollingWindow)
                         throws NodeNotInCategoryException
        Get the down time. Return the total outage time for this node in the 'rollingWindow' milliseconds since 'curTime' for the category
        Parameters:
        cat - the category in the context which of which downtime is needed
        curTime - the start time (or current time) from which we go back rollinWindow interval
        rollingWindow - the window for which downtime is required
        Returns:
        the total outage time for this node
        Throws:
        NodeNotInCategoryException
      • isServiceCurrentlyDown

        public boolean isServiceCurrentlyDown()
        Return if the service is currently down.
        Returns:
        true if the service is currently down
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object o)
        Compare RTCNodes. Overrides the 'equals()' method in the superclass
        Overrides:
        equals in class Object
      • toString

        public String toString()
        String representation. Returns a string representation of this object that has the nodeid/ip/servicename details
        Overrides:
        toString in class Object