org.apache.hadoop.tools.rumen
Class Node

java.lang.Object
  extended by org.apache.hadoop.tools.rumen.Node
All Implemented Interfaces:
Comparable<Node>
Direct Known Subclasses:
MachineNode, RackNode

public class Node
extends Object
implements Comparable<Node>

Node represents a node in the cluster topology. A node can be a MachineNode, or a RackNode, etc.


Constructor Summary
Node(String name, int level)
           
 
Method Summary
 boolean addChild(Node child)
          Add a child node to this node.
 int compareTo(Node o)
           
 boolean equals(Object obj)
           
 Set<Node> getChildren()
          Get the children of this node.
 int getLevel()
          Get the level of the node.
 String getName()
          Get the name of the node.
 Node getParent()
          Get the parent node.
 boolean hasChildren()
          Does this node have any children?
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(String name,
            int level)
Parameters:
name - A unique name to identify a node in the cluster.
level - The level of the node in the cluster
Method Detail

getName

public String getName()
Get the name of the node.

Returns:
The name of the node.

getLevel

public int getLevel()
Get the level of the node.

Returns:
The level of the node.

addChild

public boolean addChild(Node child)
Add a child node to this node.

Parameters:
child - The child node to be added. The child node should currently not be belong to another cluster topology.
Returns:
Boolean indicating whether the node is successfully added.

hasChildren

public boolean hasChildren()
Does this node have any children?

Returns:
Boolean indicate whether this node has any children.

getChildren

public Set<Node> getChildren()
Get the children of this node.

Returns:
The children of this node. If no child, an empty set will be returned. The returned set is read-only.

getParent

public Node getParent()
Get the parent node.

Returns:
the parent node. If root node, return null.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Node o)
Specified by:
compareTo in interface Comparable<Node>


Copyright © 2009 The Apache Software Foundation