org.apache.hadoop.tools.rumen
Class AbstractClusterStory

java.lang.Object
  extended by org.apache.hadoop.tools.rumen.AbstractClusterStory
All Implemented Interfaces:
ClusterStory
Direct Known Subclasses:
ZombieCluster

public abstract class AbstractClusterStory
extends Object
implements ClusterStory

AbstractClusterStory provides a partial implementation of ClusterStory by parsing the topology tree.


Field Summary
protected  Set<MachineNode> machineNodes
           
protected  int maximumDistance
           
protected  Map<String,MachineNode> mNodeMap
           
protected  MachineNode[] mNodesFlattened
           
protected  Set<RackNode> rackNodes
           
protected  Map<String,RackNode> rNodeMap
           
 
Constructor Summary
AbstractClusterStory()
           
 
Method Summary
protected  void buildMachineNodeMap()
           
protected  void buildRackNodeMap()
           
 int distance(Node a, Node b)
          Determine the distance between two Nodes.
 MachineNode getMachineByName(String name)
          Get MachineNode by its host name.
 Set<MachineNode> getMachines()
          Get all machines of the cluster.
 int getMaximumDistance()
          Get the maximum distance possible between any two nodes.
 RackNode getRackByName(String name)
          Get RackNode by its name.
 Set<RackNode> getRacks()
          Get all racks of the cluster.
 MachineNode[] getRandomMachines(int expected, Random random)
          Select a random set of machines.
protected  void parseTopologyTree()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.tools.rumen.ClusterStory
getClusterTopology
 

Field Detail

machineNodes

protected Set<MachineNode> machineNodes

rackNodes

protected Set<RackNode> rackNodes

mNodesFlattened

protected MachineNode[] mNodesFlattened

mNodeMap

protected Map<String,MachineNode> mNodeMap

rNodeMap

protected Map<String,RackNode> rNodeMap

maximumDistance

protected int maximumDistance
Constructor Detail

AbstractClusterStory

public AbstractClusterStory()
Method Detail

getMachines

public Set<MachineNode> getMachines()
Description copied from interface: ClusterStory
Get all machines of the cluster.

Specified by:
getMachines in interface ClusterStory
Returns:
A read-only set that contains all machines of the cluster.

getRacks

public Set<RackNode> getRacks()
Description copied from interface: ClusterStory
Get all racks of the cluster.

Specified by:
getRacks in interface ClusterStory
Returns:
A read-only set that contains all racks of the cluster.

getRandomMachines

public MachineNode[] getRandomMachines(int expected,
                                       Random random)
Description copied from interface: ClusterStory
Select a random set of machines.

Specified by:
getRandomMachines in interface ClusterStory
Parameters:
expected - The expected sample size.
random - Random number generator to use.
Returns:
An array of up to expected number of MachineNodes.

buildMachineNodeMap

protected void buildMachineNodeMap()

getMachineByName

public MachineNode getMachineByName(String name)
Description copied from interface: ClusterStory
Get MachineNode by its host name.

Specified by:
getMachineByName in interface ClusterStory
Returns:
The MachineNode with the same name. Or null if not found.

distance

public int distance(Node a,
                    Node b)
Description copied from interface: ClusterStory
Determine the distance between two Nodes. Currently, the distance is loosely defined as the length of the longer path for either a or b to reach their common ancestor.

Specified by:
distance in interface ClusterStory
Returns:
The distance between Node a and Node b.

buildRackNodeMap

protected void buildRackNodeMap()

getRackByName

public RackNode getRackByName(String name)
Description copied from interface: ClusterStory
Get RackNode by its name.

Specified by:
getRackByName in interface ClusterStory
Returns:
The RackNode with the same name. Or null if not found.

getMaximumDistance

public int getMaximumDistance()
Description copied from interface: ClusterStory
Get the maximum distance possible between any two nodes.

Specified by:
getMaximumDistance in interface ClusterStory
Returns:
the maximum distance possible between any two nodes.

parseTopologyTree

protected void parseTopologyTree()


Copyright © 2009 The Apache Software Foundation