|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.net.NetworkTopology
public class NetworkTopology
The class represents a cluster of computer with a tree hierarchical network topology. For example, a cluster may be consists of many data centers filled with racks of computers. In a network topology, leaves represent data nodes (computers) and inner nodes represent switches/routers that manage traffic in/out of data centers or racks.
Field Summary | |
---|---|
static String |
DEFAULT_RACK
|
static org.apache.commons.logging.Log |
LOG
|
Constructor Summary | |
---|---|
NetworkTopology()
|
Method Summary | |
---|---|
void |
add(DatanodeDescriptor node)
Add a data node Update data node counter & rack counter if neccessary |
DatanodeDescriptor |
chooseRandom(String scope)
randomly choose one node from scope if scope starts with ~, choose one from the all datanodes except for the ones in scope; otherwise, choose one from scope |
boolean |
contains(DatanodeDescriptor node)
Check if the tree contains data node node |
int |
countNumOfAvailableNodes(String scope,
List<DatanodeDescriptor> excludedNodes)
return the number of leaves in scope but not in excludedNodes if scope starts with ~, return the number of datanodes that are not in scope and excludedNodes; |
int |
getDistance(DatanodeDescriptor node1,
DatanodeDescriptor node2)
Return the distance between two data nodes It is assumed that the distance from one node to its parent is 1 The distance between two nodes is calculated by summing up their distances to their closest common ancestor. |
Node |
getNode(String loc)
Given a string representation of a node, return its reference |
int |
getNumOfLeaves()
Return the total number of data nodes |
int |
getNumOfRacks()
Return the total number of racks |
boolean |
isOnSameRack(DatanodeDescriptor node1,
DatanodeDescriptor node2)
Check if two data nodes are on the same rack |
void |
remove(DatanodeDescriptor node)
Remove a data node Update data node counter & rack counter if neccessary |
void |
sortByDistance(DatanodeDescriptor reader,
DatanodeDescriptor[] nodes)
Sorts nodes array by their distances to reader. |
String |
toString()
convert a network tree to a string |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_RACK
public static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public NetworkTopology()
Method Detail |
---|
public void add(DatanodeDescriptor node)
node
- data node to be added
IllegalArgumentException
- if add a data node to a leavepublic void remove(DatanodeDescriptor node)
node
- data node to be removedpublic boolean contains(DatanodeDescriptor node)
node
- a data node
public Node getNode(String loc)
loc
- a path-like string representation of a node
public int getNumOfRacks()
public int getNumOfLeaves()
public int getDistance(DatanodeDescriptor node1, DatanodeDescriptor node2)
node1
- one data nodenode2
- another data node
public boolean isOnSameRack(DatanodeDescriptor node1, DatanodeDescriptor node2)
node1
- one data nodenode2
- another data node
IllegalArgumentException
- when either node1 or node2 is null, or
node1 or node2 do not belong to the clusterpublic DatanodeDescriptor chooseRandom(String scope)
scope
- range of datanodes from which a node will be choosen
public int countNumOfAvailableNodes(String scope, List<DatanodeDescriptor> excludedNodes)
scope
- a path string that may start with ~excludedNodes
- a list of data nodes
public String toString()
toString
in class Object
public void sortByDistance(DatanodeDescriptor reader, DatanodeDescriptor[] nodes)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |