Package org.apache.bookkeeper.net
Class NetworkTopologyImpl.InnerNode
java.lang.Object
org.apache.bookkeeper.net.NodeBase
org.apache.bookkeeper.net.NetworkTopologyImpl.InnerNode
- All Implemented Interfaces:
Node
- Enclosing class:
- NetworkTopologyImpl
InnerNode represents a switch/router of a data center or rack.
Different from a leaf node, it has non-null children.
-
Field Summary
FieldsFields inherited from class org.apache.bookkeeper.net.NodeBase
level, location, name, parent, PATH_SEPARATOR, PATH_SEPARATOR_STR, ROOT -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an InnerNode from a path-like string.Construct an InnerNode from its name and its network location.InnerNode(String name, String location, NetworkTopologyImpl.InnerNode parent, int level) Construct an InnerNode from its name, its network location, its parent, and its level. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanAdd node n to the subtree of this node.protected booleanDetermine if children a leaves, default implementation callsisRack().protected NetworkTopologyImpl.InnerNodecreateParentNode(String parentName) Creates a parent node to be added to the list of children.(package private) NodeGet leafIndex leaf of this subtree if it is not in the excludedNode.(package private) int(package private) intGet number of leaves.(package private) booleanisAncestor(Node n) Judge if this node is an ancestor of node n.protected boolean(package private) booleanJudge if this node is the parent of node n.(package private) booleanisRack()Judge if this node represents a rack.(package private) booleanRemove node n from the subtree of this node.Methods inherited from class org.apache.bookkeeper.net.NodeBase
getLevel, getName, getNetworkLocation, getNetworkLocation, getParent, getPath, locationToDepth, normalize, setLevel, setNetworkLocation, setParent, toString
-
Field Details
-
children
-
-
Constructor Details
-
InnerNode
InnerNode(String path) Construct an InnerNode from a path-like string. -
InnerNode
Construct an InnerNode from its name and its network location. -
InnerNode
InnerNode(String name, String location, NetworkTopologyImpl.InnerNode parent, int level) Construct an InnerNode from its name, its network location, its parent, and its level.
-
-
Method Details
-
getChildren
- Returns:
- its children
-
getNumOfChildren
int getNumOfChildren()- Returns:
- the number of children this node has
-
isRack
boolean isRack()Judge if this node represents a rack.- Returns:
- true if it has no child or its children are not InnerNodes
-
isAncestor
Judge if this node is an ancestor of node n.- Parameters:
n- a node- Returns:
- true if this node is an ancestor of n
-
isParent
Judge if this node is the parent of node n.- Parameters:
n- a node- Returns:
- true if this node is the parent of n
-
add
Add node n to the subtree of this node.- Parameters:
n- node to be added- Returns:
- true if the node is added; false otherwise
-
createParentNode
Creates a parent node to be added to the list of children. Creates a node using the InnerNode four argument constructor specifying the name, location, parent, and level of this node.To be overridden in subclasses for specific InnerNode implementations, as alternative to overriding the full
add(Node)method.- Parameters:
parentName- The name of the parent node- Returns:
- A new inner node
- See Also:
-
remove
Remove node n from the subtree of this node.- Parameters:
n- node to be deleted- Returns:
- true if the node is deleted; false otherwise
-
getLeaf
Get leafIndex leaf of this subtree if it is not in the excludedNode.- Parameters:
leafIndex- an indexed leaf of the nodeexcludedNode- an excluded node (can be null)- Returns:
-
isLeafParent
protected boolean isLeafParent() -
areChildrenLeaves
protected boolean areChildrenLeaves()Determine if children a leaves, default implementation callsisRack().To be overridden in subclasses for specific InnerNode implementations, as alternative to overriding the full
getLeaf(int, Node)method.- Returns:
- true if children are leaves, false otherwise
-
getNumOfLeaves
int getNumOfLeaves()Get number of leaves.
-