Class StabilizeNetworkTopology

  • All Implemented Interfaces:
    NetworkTopology

    public class StabilizeNetworkTopology
    extends java.lang.Object
    implements NetworkTopology
    This is going to provide a stabilize network topology regarding to flapping zookeeper registration.
    • Constructor Detail

      • StabilizeNetworkTopology

        public StabilizeNetworkTopology​(io.netty.util.HashedWheelTimer timer,
                                        int stabilizePeriodSeconds)
    • Method Detail

      • updateNode

        void updateNode​(Node node,
                        boolean tentativeToRemove)
      • add

        public void add​(Node node)
        Description copied from interface: NetworkTopology
        Add a node to the network topology.
        Specified by:
        add in interface NetworkTopology
        Parameters:
        node - add the node to network topology
      • remove

        public void remove​(Node node)
        Description copied from interface: NetworkTopology
        Remove a node from network topology.
        Specified by:
        remove in interface NetworkTopology
        Parameters:
        node - remove the node from network topology
      • contains

        public boolean contains​(Node node)
        Description copied from interface: NetworkTopology
        Check if the tree contains node node.
        Specified by:
        contains in interface NetworkTopology
        Parameters:
        node - node to check
        Returns:
        true if node is already in the network topology, otherwise false.
      • getNode

        public Node getNode​(java.lang.String loc)
        Description copied from interface: NetworkTopology
        Retrieve a node from the network topology.
        Specified by:
        getNode in interface NetworkTopology
        Returns:
      • getNumOfRacks

        public int getNumOfRacks()
        Description copied from interface: NetworkTopology
        Returns number of racks in the network topology.
        Specified by:
        getNumOfRacks in interface NetworkTopology
        Returns:
        number of racks in the network topology.
      • getLeaves

        public java.util.Set<Node> getLeaves​(java.lang.String loc)
        Description copied from interface: NetworkTopology
        Returns the nodes under a location.
        Specified by:
        getLeaves in interface NetworkTopology
        Parameters:
        loc - network location
        Returns:
        nodes under a location
      • countNumOfAvailableNodes

        public int countNumOfAvailableNodes​(java.lang.String scope,
                                            java.util.Collection<Node> excludedNodes)
        Description copied from interface: NetworkTopology
        Return the number of leaves in scope but not in excludedNodes.

        If scope starts with ~, return the number of nodes that are not in scope and excludedNodes;

        Specified by:
        countNumOfAvailableNodes in interface NetworkTopology
        Parameters:
        scope - a path string that may start with ~
        excludedNodes - a list of nodes
        Returns:
        number of available nodes