Package org.apache.bookkeeper.net
Class StabilizeNetworkTopology
- java.lang.Object
-
- org.apache.bookkeeper.net.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
StabilizeNetworkTopology.NodeStatus
-
Field Summary
Fields Modifier and Type Field Description protected NetworkTopologyImpl
impl
protected java.util.concurrent.ConcurrentMap<Node,StabilizeNetworkTopology.NodeStatus>
nodeStatuses
protected long
stabilizePeriodMillis
protected io.netty.util.HashedWheelTimer
timer
-
Fields inherited from interface org.apache.bookkeeper.net.NetworkTopology
DEFAULT_RACK, DEFAULT_REGION, DEFAULT_REGION_AND_RACK, DEFAULT_UPGRADEDOMAIN, DEFAULT_ZONE, DEFAULT_ZONE_AND_UPGRADEDOMAIN
-
-
Constructor Summary
Constructors Constructor Description StabilizeNetworkTopology(io.netty.util.HashedWheelTimer timer, int stabilizePeriodSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Node node)
Add a node to the network topology.boolean
contains(Node node)
Check if the tree contains node node.int
countNumOfAvailableNodes(java.lang.String scope, java.util.Collection<Node> excludedNodes)
Return the number of leaves in scope but not in excludedNodes.java.util.Set<Node>
getLeaves(java.lang.String loc)
Returns the nodes under a location.Node
getNode(java.lang.String loc)
Retrieve a node from the network topology.int
getNumOfRacks()
Returns number of racks in the network topology.void
remove(Node node)
Remove a node from network topology.(package private) void
updateNode(Node node, boolean tentativeToRemove)
-
-
-
Field Detail
-
impl
protected final NetworkTopologyImpl impl
-
timer
protected final io.netty.util.HashedWheelTimer timer
-
nodeStatuses
protected final java.util.concurrent.ConcurrentMap<Node,StabilizeNetworkTopology.NodeStatus> nodeStatuses
-
stabilizePeriodMillis
protected final long stabilizePeriodMillis
-
-
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 interfaceNetworkTopology
- 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 interfaceNetworkTopology
- 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 interfaceNetworkTopology
- 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 interfaceNetworkTopology
- Returns:
-
getNumOfRacks
public int getNumOfRacks()
Description copied from interface:NetworkTopology
Returns number of racks in the network topology.- Specified by:
getNumOfRacks
in interfaceNetworkTopology
- 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 interfaceNetworkTopology
- 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 interfaceNetworkTopology
- Parameters:
scope
- a path string that may start with ~excludedNodes
- a list of nodes- Returns:
- number of available nodes
-
-