Package org.apache.hadoop.net
Class NetworkTopologyWithNodeGroup
java.lang.Object
org.apache.hadoop.net.NetworkTopology
org.apache.hadoop.net.NetworkTopologyWithNodeGroup
@LimitedPrivate({"HDFS","MapReduce"})
@Unstable
public class NetworkTopologyWithNodeGroup
extends NetworkTopology
The class extends NetworkTopology to represents a cluster of computer with
a 4-layers hierarchical network topology.
In this network topology, leaves represent data nodes (computers) and inner
nodes represent switches/routers that manage traffic in/out of data centers,
racks or physical host (with virtual switch).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.net.NetworkTopology
NetworkTopology.InvalidTopologyException -
Field Summary
FieldsFields inherited from class org.apache.hadoop.net.NetworkTopology
DEFAULT_RACK, LOG, netlock, numOfRacks -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a leaf node Update node counter & rack counter if necessaryprotected NodeReturn a reference to the node given its string representation.getNodeGroup(String loc) Given a string representation of a node group for a specific network locationGiven a string representation of a rack for a specific network location To be overridden in subclasses for specific NetworkTopology implementations, as alternative to overriding the fullNetworkTopology.getRack(String)method.protected intReturns an integer weight which specifies how far away {node} is away from {reader}.booleanCheck if network topology is aware of NodeGroupbooleanisOnSameNodeGroup(Node node1, Node node2) Check if two nodes are on the same node group (hypervisor) The assumption here is: each nodes are leaf nodes.booleanisOnSameRack(Node node1, Node node2) Check if two nodes are on the same rackvoidRemove a node Update node counter and rack counter if necessaryvoidsortByDistance(Node reader, Node[] nodes, int activeLen) Sort nodes array by their distances to reader.Methods inherited from class org.apache.hadoop.net.NetworkTopology
chooseRandom, chooseRandom, chooseRandom, contains, countNumOfAvailableNodes, decommissionNode, getDatanodesInRack, getDistance, getDistanceByPath, getFirstHalf, getInstance, getInstance, getLastHalf, getLeaves, getNode, getNumOfLeaves, getNumOfNonEmptyRacks, getNumOfRacks, getWeightUsingNetworkLocation, hasClusterEverBeenMultiRack, incrementRacks, init, isChildScope, isNodeInScope, isSameParents, recommissionNode, shuffle, sortByDistance, sortByDistanceUsingNetworkLocation, sortByDistanceUsingNetworkLocation, toString
-
Field Details
-
DEFAULT_NODEGROUP
- See Also:
-
-
Constructor Details
-
NetworkTopologyWithNodeGroup
public NetworkTopologyWithNodeGroup()
-
-
Method Details
-
getNodeForNetworkLocation
Description copied from class:NetworkTopologyReturn a reference to the node given its string representation. Default implementation delegates toNetworkTopology.getNode(String).To be overridden in subclasses for specific NetworkTopology implementations, as alternative to overriding the full
NetworkTopology.add(Node)method.- Overrides:
getNodeForNetworkLocationin classNetworkTopology- Parameters:
node- The string representation of this node's network location is used to retrieve a Node object.- Returns:
- a reference to the node; null if the node is not in the tree
- See Also:
-
getRack
Description copied from class:NetworkTopologyGiven a string representation of a rack for a specific network location To be overridden in subclasses for specific NetworkTopology implementations, as alternative to overriding the fullNetworkTopology.getRack(String)method.- Overrides:
getRackin classNetworkTopology- Parameters:
loc- a path-like string representation of a network location- Returns:
- a rack string
-
getNodeGroup
Given a string representation of a node group for a specific network location- Parameters:
loc- a path-like string representation of a network location- Returns:
- a node group string
-
isOnSameRack
Description copied from class:NetworkTopologyCheck if two nodes are on the same rack- Overrides:
isOnSameRackin classNetworkTopology- Parameters:
node1- one node (can be null)node2- another node (can be null)- Returns:
- true if node1 and node2 are on the same rack; false otherwise
-
isOnSameNodeGroup
Check if two nodes are on the same node group (hypervisor) The assumption here is: each nodes are leaf nodes.- Overrides:
isOnSameNodeGroupin classNetworkTopology- Parameters:
node1- one node (can be null)node2- another node (can be null)- Returns:
- true if node1 and node2 are on the same node group; false otherwise
- Throws:
IllegalArgumentException- when either node1 or node2 is null, or node1 or node2 do not belong to the cluster
-
isNodeGroupAware
public boolean isNodeGroupAware()Check if network topology is aware of NodeGroup- Overrides:
isNodeGroupAwarein classNetworkTopology- Returns:
- Check if network topology is aware of NodeGroup.
-
add
Add a leaf node Update node counter & rack counter if necessary- Overrides:
addin classNetworkTopology- Parameters:
node- node to be added; can be null- Throws:
IllegalArgumentException- if add a node to a leave or node to be added is not a leaf
-
remove
Remove a node Update node counter and rack counter if necessary- Overrides:
removein classNetworkTopology- Parameters:
node- node to be removed; can be null
-
getWeight
Description copied from class:NetworkTopologyReturns an integer weight which specifies how far away {node} is away from {reader}. A lower value signifies that a node is closer.- Overrides:
getWeightin classNetworkTopology- Parameters:
reader- Node where data will be readnode- Replica of data- Returns:
- weight
-
sortByDistance
Sort nodes array by their distances to reader.This is the same as
NetworkTopology.sortByDistance(Node, Node[], int)except with a four-level network topology which contains the additional network distance of a "node group" which is between local and same rack.- Overrides:
sortByDistancein classNetworkTopology- Parameters:
reader- Node where data will be readnodes- Available replicas with the requested dataactiveLen- Number of active nodes at the front of the array
-