Class ClusterMonitor<T>


  • public class ClusterMonitor<T>
    extends java.lang.Object
    Monitors of a cluster of remote nodes. The monitor uses an internal thread for node monitoring. All public methods of this class are multithread safe.
    Author:
    bratseth
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(T node, boolean internal)
      Adds a new node for monitoring.
      void failed​(T node, ErrorMessage error)
      Called from ClusterSearcher/NodeManager when a node failed
      MonitorConfiguration getConfiguration()
      Returns the configuration of this cluster monitor
      BaseNodeMonitor<T> getNodeMonitor​(T node)
      Returns the monitor of the given node, or null if this node has not been added
      java.util.Iterator<BaseNodeMonitor<T>> nodeMonitorIterator()
      Returns a thread-safe snapshot of the NodeMonitors of all added nodes
      java.util.List<BaseNodeMonitor<T>> nodeMonitors()
      Returns a thread-safe snapshot of the NodeMonitors of all added nodes
      void ping​(java.util.concurrent.Executor executor)
      Ping all nodes which needs pinging to discover state changes
      void responded​(T node)
      Called when a node responded
      void shutdown()
      Must be called when this goes out of use
      void start()  
      • Methods inherited from class java.lang.Object

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

      • ClusterMonitor

        @Deprecated
        public ClusterMonitor​(NodeManager<T> manager)
        Deprecated.
        It is not advised to start the monitoring thread in the constructor. Use ClusterMonitor(NodeManager manager, false) and explicit start().
      • ClusterMonitor

        public ClusterMonitor​(NodeManager<T> manager,
                              boolean startPingThread)
    • Method Detail

      • start

        public void start()
      • getConfiguration

        public MonitorConfiguration getConfiguration()
        Returns the configuration of this cluster monitor
      • add

        public void add​(T node,
                        boolean internal)
        Adds a new node for monitoring. The object representing the node must
        • Have a sensible toString
        • Have a sensible identity (equals and hashCode)
        Parameters:
        node - the object representing the node
        internal - whether or not this node is internal to this cluster
      • getNodeMonitor

        public BaseNodeMonitor<T> getNodeMonitor​(T node)
        Returns the monitor of the given node, or null if this node has not been added
      • failed

        public void failed​(T node,
                           ErrorMessage error)
        Called from ClusterSearcher/NodeManager when a node failed
      • responded

        public void responded​(T node)
        Called when a node responded
      • ping

        public void ping​(java.util.concurrent.Executor executor)
        Ping all nodes which needs pinging to discover state changes
      • nodeMonitorIterator

        public java.util.Iterator<BaseNodeMonitor<T>> nodeMonitorIterator()
        Returns a thread-safe snapshot of the NodeMonitors of all added nodes
      • nodeMonitors

        public java.util.List<BaseNodeMonitor<T>> nodeMonitors()
        Returns a thread-safe snapshot of the NodeMonitors of all added nodes
      • shutdown

        public void shutdown()
        Must be called when this goes out of use