Package org.apache.hadoop.net
Class InnerNodeImpl
java.lang.Object
org.apache.hadoop.net.NodeBase
org.apache.hadoop.net.InnerNodeImpl
InnerNode represents a switch/router of a data center or rack.
Different from a leaf node, it has non-null children.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intFields inherited from class org.apache.hadoop.net.NodeBase
level, location, name, parent, PATH_SEPARATOR, PATH_SEPARATOR_STR, ROOT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInnerNodeImpl(String path) Construct an InnerNode from a path-like string.protectedInnerNodeImpl(String name, String location, InnerNode parent, int level) Construct an InnerNode from its name, its network location, its parent, and its level. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd node n to the subtree of this nodebooleanget leafIndex leaf of this subtree if it is not in the excludedNodeGiven a node's string representation, return a reference to the nodeintintinthashCode()booleanisAncestor(Node n) Judge if this node is an ancestor of node n.booleanJudge if this node is the parent of node n.booleanisRack()Judge if this node represents a rack.booleanRemove node n from the subtree of this nodeMethods inherited from class org.apache.hadoop.net.NodeBase
getLevel, getName, getNetworkLocation, getParent, getPath, getPathComponents, locationToDepth, normalize, setLevel, setNetworkLocation, setParent, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.net.Node
getLevel, getName, getNetworkLocation, getParent, setLevel, setNetworkLocation, setParent
-
Field Details
-
children
-
childrenMap
-
numOfLeaves
protected int numOfLeaves
-
-
Constructor Details
-
InnerNodeImpl
Construct an InnerNode from a path-like string.- Parameters:
path- input path.
-
InnerNodeImpl
Construct an InnerNode from its name, its network location, its parent, and its level.- Parameters:
name- input name.location- input location.parent- input parent.level- input level.
-
-
Method Details
-
getChildren
- Specified by:
getChildrenin interfaceInnerNode- Returns:
- its children
-
getNumOfChildren
public int getNumOfChildren()- Specified by:
getNumOfChildrenin interfaceInnerNode- Returns:
- the number of children this node has.
-
isRack
public 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
-
getNextAncestorName
-
add
Description copied from interface:InnerNodeAdd node n to the subtree of this node -
remove
Description copied from interface:InnerNodeRemove node n from the subtree of this node -
getLoc
Description copied from interface:InnerNodeGiven a node's string representation, return a reference to the node- Specified by:
getLocin interfaceInnerNode- Parameters:
loc- string location of the form /rack/node- Returns:
- null if the node is not found or the childnode is there but
not an instance of
InnerNodeImpl
-
getLeaf
Description copied from interface:InnerNodeget leafIndex leaf of this subtree if it is not in the excludedNode -
getNumOfLeaves
public int getNumOfLeaves()- Specified by:
getNumOfLeavesin interfaceInnerNode- Returns:
- the number of leave nodes.
-
hashCode
public int hashCode() -
equals
-