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
static class NetworkTopologyImpl.InnerNode extends NodeBase
InnerNode represents a switch/router of a data center or rack. Different from a leaf node, it has non-null children.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Node>
children
-
Fields inherited from class org.apache.bookkeeper.net.NodeBase
level, location, name, parent, PATH_SEPARATOR, PATH_SEPARATOR_STR, ROOT
-
-
Constructor Summary
Constructors Constructor Description InnerNode(java.lang.String path)
Construct an InnerNode from a path-like string.InnerNode(java.lang.String name, java.lang.String location)
Construct an InnerNode from its name and its network location.InnerNode(java.lang.String name, java.lang.String location, NetworkTopologyImpl.InnerNode parent, int level)
Construct an InnerNode from its name, its network location, its parent, and its level.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) boolean
add(Node n)
Add node n to the subtree of this node.protected boolean
areChildrenLeaves()
Determine if children a leaves, default implementation callsisRack()
.protected NetworkTopologyImpl.InnerNode
createParentNode(java.lang.String parentName)
Creates a parent node to be added to the list of children.(package private) java.util.List<Node>
getChildren()
(package private) Node
getLeaf(int leafIndex, Node excludedNode)
Get leafIndex leaf of this subtree if it is not in the excludedNode.(package private) int
getNumOfChildren()
(package private) int
getNumOfLeaves()
Get number of leaves.(package private) boolean
isAncestor(Node n)
Judge if this node is an ancestor of node n.protected boolean
isLeafParent()
(package private) boolean
isParent(Node n)
Judge if this node is the parent of node n.(package private) boolean
isRack()
Judge if this node represents a rack.(package private) boolean
remove(Node n)
Remove 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 Detail
-
children
protected java.util.List<Node> children
-
-
Constructor Detail
-
InnerNode
InnerNode(java.lang.String path)
Construct an InnerNode from a path-like string.
-
InnerNode
InnerNode(java.lang.String name, java.lang.String location)
Construct an InnerNode from its name and its network location.
-
InnerNode
InnerNode(java.lang.String name, java.lang.String location, NetworkTopologyImpl.InnerNode parent, int level)
Construct an InnerNode from its name, its network location, its parent, and its level.
-
-
Method Detail
-
getChildren
java.util.List<Node> 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
boolean isAncestor(Node n)
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
boolean isParent(Node n)
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
boolean add(Node n)
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
protected NetworkTopologyImpl.InnerNode createParentNode(java.lang.String parentName)
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:
InnerNode(String, String, InnerNode, int)
-
remove
boolean remove(Node n)
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
Node getLeaf(int leafIndex, Node excludedNode)
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.
-
-