sg.edu.nus.peer.info
Class TreeNode

java.lang.Object
  extended by sg.edu.nus.peer.info.TreeNode
All Implemented Interfaces:
java.io.Serializable

public class TreeNode
extends java.lang.Object
implements java.io.Serializable

Implement the data structure of each BATON node.

Version:
1.0 2006-2-7
Author:
Vu Quang Hieu, (Modified by) Xu Linhao
See Also:
Serialized Form

Field Summary
static int ACTIVE
           
static int FAILED
           
static int INACTIVE
           
static int MASTER
           
static int SLAVE
           
 
Constructor Summary
TreeNode(LogicalInfo logicalInfo, ParentNodeInfo parentNode, ChildNodeInfo leftChild, ChildNodeInfo rightChild, AdjacentNodeInfo leftAdjacent, AdjacentNodeInfo rightAdjacent, RoutingTableInfo leftRoutingTable, RoutingTableInfo rightRoutingTable, ContentInfo content, int numOfExpectedRTReply, int status)
          Contruct a tree node.
TreeNode(java.lang.String serializeData)
          Construct a tree node with a serialized string value.
 
Method Summary
 void addCoOwnerList(PhysicalInfo info)
          Put an instance of PhysicalInfo into the coOwner list.
 void clearCoOwnerList()
          Clear the coOwner list.
 void clearNumOfQuery()
          Clear the number of queries that the node has processed.
 void deleteAllWork()
          Remove all incoming data objects to be handled.
 ContentInfo getContent()
          Get the index key set.
 PhysicalInfo getCoOwnerList(int idx)
          Get the idx-th of member of the coOwner list.
 int getCoOwnerSize()
          Get the size of the coOwner list.
 AdjacentNodeInfo getLeftAdjacentNode()
          Get the left adjacent node of the node.
 ChildNodeInfo getLeftChild()
          Get the left child node of the node.
 RoutingTableInfo getLeftRoutingTable()
          Get the left routing table of the node.
 int getLNElement()
           
 int getLNOrder()
           
 LogicalInfo getLogicalInfo()
          Get the logical information of the node.
 LogicalInfo getMissingNode()
          Get the missing node when processing reply messages.
 int getNumOfExpectedRTReply()
          Get the number of expected replies for constructing routing table.
 int getNumOfQuery()
          Get the number of queries to be processed.
 ParentNodeInfo getParentNode()
          Get the parent node of the node.
 java.lang.String getRemainWork()
          Get the remainder of the incoming data objects to be handled.
 AdjacentNodeInfo getRightAdjacentNode()
          Get the right adjacent node of the node.
 ChildNodeInfo getRightChild()
          Get the right child node of the node
 RoutingTableInfo getRightRoutingTable()
          Get the right routing table of the node.
 int getRNElement()
           
 int getRNOrder()
           
 int getRole()
          Get the role of the node.
 int getStatus()
          Get the status of the workload at node.
 java.lang.String getWork()
          Get the first incoming data object to be handled.
 java.lang.String getWork(int idx)
          Get the incoming data object to be handled on a specified position.
 int getWorkSize()
          Get the number of incoming data object to be handled.
 boolean hasWork()
          Determine if there still have some incoming data objects to be handled.
 void incNumOfQuery(int num)
          Increase the number of queries to be processed.
 boolean isNotifyImbalance()
          Determine if the imbalance status is notified to other nodes.
 boolean isProcessLoadBalance()
          Determine if is processing the load balance.
 void notifyImbalance(boolean bool)
          Set the status of the notification of the imbalance status.
 void processLoadBalance(boolean bool)
          Set the status of the process of the load balance at node.
 void putWork(java.lang.String incomingData)
          Store the incoming data objects to be handled into a container.
 PhysicalInfo removeCoOwnerList(int idx)
          Remove an item from the coOwner list.
 void setContent(ContentInfo content)
          Set the index key set.
 void setLeftAdjacentNode(AdjacentNodeInfo leftAdjacent)
          Set the left adjacent node of the node.
 void setLeftChild(ChildNodeInfo leftChild)
          Set the left child node of the node.
 void setLNElement(int num)
           
 void setLNOrder(int order)
           
 void setMissingNode(LogicalInfo info)
          Set the missing node when processing reply messages.
 void setNumOfExpectedRTReply(int numOfExpectedRTReply)
          Set the number of expected replies for constructing routing table.
 void setParentNode(ParentNodeInfo parentNode)
          Set the parent node of the node.
 void setRightAdjacentNode(AdjacentNodeInfo rightAdjacent)
          Set the right adjacent node of the node.
 void setRightChild(ChildNodeInfo rightChild)
          Set the right child node of the node.
 void setRNElement(int num)
           
 void setRNOrder(int order)
           
 void setRole(int role)
          Set the role of the node.
 void setStatus(int status)
          Set the status of the workload at node.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SLAVE

public static final int SLAVE
See Also:
Constant Field Values

MASTER

public static final int MASTER
See Also:
Constant Field Values

INACTIVE

public static final int INACTIVE
See Also:
Constant Field Values

ACTIVE

public static final int ACTIVE
See Also:
Constant Field Values

FAILED

public static final int FAILED
See Also:
Constant Field Values
Constructor Detail

TreeNode

public TreeNode(LogicalInfo logicalInfo,
                ParentNodeInfo parentNode,
                ChildNodeInfo leftChild,
                ChildNodeInfo rightChild,
                AdjacentNodeInfo leftAdjacent,
                AdjacentNodeInfo rightAdjacent,
                RoutingTableInfo leftRoutingTable,
                RoutingTableInfo rightRoutingTable,
                ContentInfo content,
                int numOfExpectedRTReply,
                int status)
Contruct a tree node.

Parameters:
logicalInfo - the logical information of the node
parentNode - the parent node
leftChild - the left child node
rightChild - the right child node
leftAdjacent - the left adjacent node
rightAdjacent - the right adjacent node
leftRoutingTable - the left routing table
rightRoutingTable - the right routing table
content - the index key set
numOfExpectedRTReply - the number of expected replies for routing table
status - how many replies are conducted

TreeNode

public TreeNode(java.lang.String serializeData)
Construct a tree node with a serialized string value.

Parameters:
serializeData - the serialized string value
Method Detail

getLogicalInfo

public LogicalInfo getLogicalInfo()
Get the logical information of the node.

Returns:
the logical information of the node

setParentNode

public void setParentNode(ParentNodeInfo parentNode)
Set the parent node of the node.

Parameters:
parentNode - the parent node of the node

getParentNode

public ParentNodeInfo getParentNode()
Get the parent node of the node.

Returns:
the parent node of the node

setLeftChild

public void setLeftChild(ChildNodeInfo leftChild)
Set the left child node of the node.

Parameters:
leftChild - the left child nod of the node

getLeftChild

public ChildNodeInfo getLeftChild()
Get the left child node of the node.

Returns:
the left child node of the node

setRightChild

public void setRightChild(ChildNodeInfo rightChild)
Set the right child node of the node.

Parameters:
rightChild - the right child node of the node

getRightChild

public ChildNodeInfo getRightChild()
Get the right child node of the node

Returns:
the right child node of the node

setLeftAdjacentNode

public void setLeftAdjacentNode(AdjacentNodeInfo leftAdjacent)
Set the left adjacent node of the node.

Parameters:
leftAdjacent - the left adjacent node of the node

getLeftAdjacentNode

public AdjacentNodeInfo getLeftAdjacentNode()
Get the left adjacent node of the node.

Returns:
the left adjacent node of the node

setRightAdjacentNode

public void setRightAdjacentNode(AdjacentNodeInfo rightAdjacent)
Set the right adjacent node of the node.

Parameters:
rightAdjacent - the right adjacent node of the node

getRightAdjacentNode

public AdjacentNodeInfo getRightAdjacentNode()
Get the right adjacent node of the node.

Returns:
the right adjacent node of the node

getLeftRoutingTable

public RoutingTableInfo getLeftRoutingTable()
Get the left routing table of the node.

Returns:
the left routing table of the node

getRightRoutingTable

public RoutingTableInfo getRightRoutingTable()
Get the right routing table of the node.

Returns:
the right routing table of the node

setContent

public void setContent(ContentInfo content)
Set the index key set.

Parameters:
content - the index key set

getContent

public ContentInfo getContent()
Get the index key set.

Returns:
the index key set

setNumOfExpectedRTReply

public void setNumOfExpectedRTReply(int numOfExpectedRTReply)
Set the number of expected replies for constructing routing table.

Parameters:
numOfExpectedRTReply - the number of expected replies for constructing routing table

getNumOfExpectedRTReply

public int getNumOfExpectedRTReply()
Get the number of expected replies for constructing routing table.

Returns:
the number of expected replies for constructing routing table

setStatus

public void setStatus(int status)
Set the status of the workload at node.

Parameters:
status - the status of the workload at node

getStatus

public int getStatus()
Get the status of the workload at node.

Returns:
the status of the workload at node

putWork

public void putWork(java.lang.String incomingData)
Store the incoming data objects to be handled into a container.

Parameters:
incomingData - the incoming data objects to be handled

hasWork

public boolean hasWork()
Determine if there still have some incoming data objects to be handled.

Returns:
true if still have; otherwise, false

getWork

public java.lang.String getWork()
Get the first incoming data object to be handled.

Returns:
the first incoming data object to be handled

getWork

public java.lang.String getWork(int idx)
Get the incoming data object to be handled on a specified position.

Returns:
the first incoming data object to be handled on a specified position

getWorkSize

public int getWorkSize()
Get the number of incoming data object to be handled.

Returns:
the number of incoming data object to be handled

deleteAllWork

public void deleteAllWork()
Remove all incoming data objects to be handled.


getRemainWork

public java.lang.String getRemainWork()
Get the remainder of the incoming data objects to be handled.

Returns:
the remainder of the incoming data objects to be handled

isNotifyImbalance

public boolean isNotifyImbalance()
Determine if the imbalance status is notified to other nodes.

Returns:
true if notify other nodes; otherwise, false

notifyImbalance

public void notifyImbalance(boolean bool)
Set the status of the notification of the imbalance status.

Parameters:
bool - the status of the notification of the imbalance status

getMissingNode

public LogicalInfo getMissingNode()
Get the missing node when processing reply messages.

Returns:
the missing node when processing reply messages

setMissingNode

public void setMissingNode(LogicalInfo info)
Set the missing node when processing reply messages.

Parameters:
info - the missing node when processing reply messages

getLNElement

public int getLNElement()
Returns:
the number of left neighbors

setLNElement

public void setLNElement(int num)
Parameters:
num - the number of left neighbors

getRNElement

public int getRNElement()
Returns:
the number of right neighbors

setRNElement

public void setRNElement(int num)
Parameters:
num - the number of right neighbors

getLNOrder

public int getLNOrder()
Returns:
the balance status of the left neighbor

setLNOrder

public void setLNOrder(int order)
Parameters:
order - the balance status of the left neighbor

getRNOrder

public int getRNOrder()
Returns:
the balance status of the right neighbor

setRNOrder

public void setRNOrder(int order)
Parameters:
order - the balance status of the right neighbor

isProcessLoadBalance

public boolean isProcessLoadBalance()
Determine if is processing the load balance.

Returns:
true if is processing; otherwise, false

processLoadBalance

public void processLoadBalance(boolean bool)
Set the status of the process of the load balance at node.

Parameters:
bool - the status of the process of the load balance at node

getRole

public int getRole()
Get the role of the node.

Returns:
the role of the node

setRole

public void setRole(int role)
Set the role of the node.

Parameters:
role - the role of the node

addCoOwnerList

public void addCoOwnerList(PhysicalInfo info)
Put an instance of PhysicalInfo into the coOwner list.

Parameters:
info - the instance of PhysicalInfo

getCoOwnerList

public PhysicalInfo getCoOwnerList(int idx)
Get the idx-th of member of the coOwner list.

Parameters:
idx - the position of the member
Returns:
if index position is valid, return the instance of PhysicalInfo; otherwise, throw exception

getCoOwnerSize

public int getCoOwnerSize()
Get the size of the coOwner list.

Returns:
the size of the coOwner list

removeCoOwnerList

public PhysicalInfo removeCoOwnerList(int idx)
Remove an item from the coOwner list.

Parameters:
idx - the position of the item to be removed
Returns:
the instance of PhysicalInfo to be removed

clearCoOwnerList

public void clearCoOwnerList()
Clear the coOwner list.


incNumOfQuery

public void incNumOfQuery(int num)
Increase the number of queries to be processed.

Parameters:
num - the number of queries to be processed

getNumOfQuery

public int getNumOfQuery()
Get the number of queries to be processed.

Returns:
the number of queries to be processed

clearNumOfQuery

public void clearNumOfQuery()
Clear the number of queries that the node has processed.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object