Class BaseNodeMonitor<T>

java.lang.Object
com.yahoo.search.cluster.BaseNodeMonitor<T>
Direct Known Subclasses:
TrafficNodeMonitor

public abstract class BaseNodeMonitor<T> extends 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
    The configuration of this monitor
    protected long
    The last time this node failed, in ms
    protected boolean
    Whether this node is quarantined for unstability
    protected boolean
     
    protected static Logger
     
    protected T
    The object representing the monitored node
    protected long
    The last time this node responded (failed or succeeded), in ms
    protected long
    The last time this node responded successfully
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseNodeMonitor(boolean internal)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Called when this node fails.
     
    boolean
    Returns whether or not this is monitoring an internal node.
    boolean
    Returns whether this node is currently in a state suitable for receiving traffic (default true)
    protected long
    now()
     
    abstract void
    Called when a response is received from this node.
    protected abstract void
    setWorking(boolean working, 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 Details

    • log

      protected static 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
    • configuration

      protected MonitorConfiguration configuration
      The configuration of this monitor
  • Constructor Details

    • BaseNodeMonitor

      public BaseNodeMonitor(boolean internal)
  • Method Details

    • getNode

      public T getNode()
    • isWorking

      public boolean isWorking()
      Returns whether this node is currently in a state suitable for receiving traffic (default true)
    • 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
    • now

      protected long now()
    • setWorking

      protected abstract void setWorking(boolean working, 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.