Class BaseNodeMonitor<T>

  • Direct Known Subclasses:
    TrafficNodeMonitor

    public abstract class BaseNodeMonitor<T>
    extends java.lang.Object
    A node monitor is responsible for maintaining the state of a monitored node. It has the following properties:
    • A node is taken out of operation if it fails
    • A node is put back in operation when it responds correctly again responseAfterFailLimit times unless it has failed failQuarantineLimit. In the latter case it won't be put into operation again before that time period has expired
    Author:
    bratseth
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected MonitorConfiguration configuration
      The configuration of this monitor
      protected long failedAt
      The last time this node failed, in ms
      protected boolean isQuarantined
      Whether this node is quarantined for unstability
      protected boolean isWorking  
      protected static java.util.logging.Logger log  
      protected T node
      The object representing the monitored node
      protected long respondedAt
      The last time this node responded (failed or succeeded), in ms
      protected long succeededAt
      The last time this node responded successfully
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseNodeMonitor​(boolean internal)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract void failed​(ErrorMessage error)
      Called when this node fails.
      T getNode()  
      boolean isIdle()
      Deprecated.
      Not used
      boolean isInternal()
      Returns whether or not this is monitoring an internal node.
      boolean isQuarantined()
      Deprecated.
      Not used
      boolean isWorking()
      Returns whether this node is currently in a state suitable for receiving traffic (default true)
      protected long now()  
      abstract void responded()
      Called when a response is received from this node.
      protected abstract void setWorking​(boolean working, java.lang.String explanation)
      Thread-safely changes the state of this node if required
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        protected static java.util.logging.Logger log
      • node

        protected T node
        The object representing the monitored node
      • isWorking

        protected boolean isWorking
      • isQuarantined

        protected boolean isQuarantined
        Whether this node is quarantined for unstability
      • failedAt

        protected long failedAt
        The last time this node failed, in ms
      • respondedAt

        protected long respondedAt
        The last time this node responded (failed or succeeded), in ms
      • succeededAt

        protected long succeededAt
        The last time this node responded successfully
    • Constructor Detail

      • BaseNodeMonitor

        public BaseNodeMonitor​(boolean internal)
    • Method Detail

      • getNode

        public T getNode()
      • isWorking

        public boolean isWorking()
        Returns whether this node is currently in a state suitable for receiving traffic (default true)
      • isQuarantined

        @Deprecated
        public boolean isQuarantined()
        Deprecated.
        Not used
      • failed

        public abstract void failed​(ErrorMessage error)
        Called when this node fails.
        Parameters:
        error - a description of the error
      • responded

        public abstract void responded()
        Called when a response is received from this node. If the node was quarantined and it has been in that state for more than QuarantineTime milliseconds, it is taken out of quarantine. if it is not in quarantine but is not working, it may be set to working if this method is called at least responseAfterFailLimit times
      • isIdle

        @Deprecated
        public boolean isIdle()
        Deprecated.
        Not used
      • now

        protected long now()
      • setWorking

        protected abstract void setWorking​(boolean working,
                                           java.lang.String explanation)
        Thread-safely changes the state of this node if required
      • isInternal

        public boolean isInternal()
        Returns whether or not this is monitoring an internal node. Default is false.