Fairness.Trees
Class TreeManager

java.lang.Object
  extended by Fairness.Trees.TreeManager
Direct Known Subclasses:
PastryTreeManager, RandomTreeManager, SimpleTreeManager

public abstract class TreeManager
extends java.lang.Object

The TreeManager manages the construction of the stripe trees, and is also responsible for assigning node IDs and stripe IDs.


Field Summary
protected  Simulation sim
           
 
Constructor Summary
TreeManager()
           
 
Method Summary
 void addNode(Node node)
          Adds a Node to this TreeManager for it to manage and build into trees.
 java.lang.String forestToString()
          Return a String version of the whole forest.
protected  java.util.Collection<Node> getAllNodes()
          Returns all nodes in the network.
abstract  int getNextNodeId()
          Returns the next node ID using the node ID allocation algorithm from this TreeManager.
abstract  java.util.Collection<Node> getRootNodes()
          After a tree reconstruction, returns the nodes that are the roots of their stripe trees.
abstract  void rebuildTree()
          A method to completely rebuild the Node tree given all nodes in the system.
protected  void setUp()
          Called when the public setup method is called.
 void setUp(Simulation sim)
          Sets up the tree manager to run within the given simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sim

protected Simulation sim
Constructor Detail

TreeManager

public TreeManager()
Method Detail

getAllNodes

protected java.util.Collection<Node> getAllNodes()
Returns all nodes in the network.


setUp

public void setUp(Simulation sim)
Sets up the tree manager to run within the given simulation.

Parameters:
sim - non-null Simulation

setUp

protected void setUp()
Called when the public setup method is called. At this time, the sim parameter has been initialized, and getAllNodes also should be valid to call.


getRootNodes

public abstract java.util.Collection<Node> getRootNodes()
After a tree reconstruction, returns the nodes that are the roots of their stripe trees. It is assumed that the Node is the root of its primary stripe and of no other. That is, Node getParent( getStripeId() ) should return null.

Returns:
non-null Collection of 0 or more Node.

rebuildTree

public abstract void rebuildTree()
A method to completely rebuild the Node tree given all nodes in the system.


addNode

public void addNode(Node node)
Adds a Node to this TreeManager for it to manage and build into trees.

Parameters:
node - non-null Node that has an ID that came from getNextNodeId.

getNextNodeId

public abstract int getNextNodeId()
Returns the next node ID using the node ID allocation algorithm from this TreeManager.


forestToString

public java.lang.String forestToString()
Return a String version of the whole forest.