Class RTCNode


  • public class RTCNode
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      RTCNode​(int nodeid, java.net.InetAddress inetAddress, java.lang.String svcName, long rollingWindow)
      Constructor.
      RTCNode​(RTCNodeKey key, long rollingWindow)
      Constructor for RTCNode.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCategory​(java.lang.String catLabel)
      Add to the category list for this node.
      void addSvcTime​(long losttime, long regainedtime)
      Add a new 'RTCNodeSvcTime' entry for this node.
      boolean belongsTo​(java.lang.String catLabel)
      Check if this node belongs to the category.
      boolean equals​(java.lang.Object o)
      Compare RTCNodes.
      java.util.List<java.lang.String> getCategories()
      Return the list of categories this node belongs to.
      long getDownTime​(java.lang.String cat, long curTime, long rollingWindow)
      Get the down time.
      java.net.InetAddress getIP()
      Return the IP address.
      java.lang.Integer getNodeID()
      Return the node ID.
      java.lang.String getSvcName()
      Return the service name.
      int hashCode()
      boolean isServiceCurrentlyDown()
      Return if the service is currently down.
      void nodeLostService​(long t)
      Add a node lost service time.
      void nodeRegainedService​(long t)
      Add a node regained service time.
      void removeCategory​(java.lang.String catLabel)
      Remove a category from the node's context.
      void setNodeID​(int id)
      Set the node ID.
      java.lang.String toString()
      String representation.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RTCNode

        public RTCNode​(RTCNodeKey key,
                       long rollingWindow)

        Constructor for RTCNode.

        Parameters:
        key - a RTCNodeKey object.
      • RTCNode

        public RTCNode​(int nodeid,
                       java.net.InetAddress inetAddress,
                       java.lang.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​(java.lang.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​(java.lang.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 java.lang.Integer getNodeID()
        Return the node ID.
        Returns:
        the node ID
      • getSvcName

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

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

        public boolean belongsTo​(java.lang.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 java.util.List<java.lang.String> getCategories()
        Return the list of categories this node belongs to.
        Returns:
        list of categories for the node.
      • getDownTime

        public long getDownTime​(java.lang.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 java.lang.Object
      • equals

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

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