hypercast.DT
Class DT_Node

java.lang.Object
  |
  +--hypercast.DT.DT_Node
All Implemented Interfaces:
I_AdapterCallback, I_Node, I_Stats
Direct Known Subclasses:
DT_Node_ServerJoin

public abstract class DT_Node
extends java.lang.Object
implements I_AdapterCallback, I_Node

This class is a basic Delaunay triangulation node. That is, it maintains logical links and can resolve most bad configurations, but it does not have any mechanism for joining a Overlay or resolving partitions. A derived class (such as DT_Node_ServerJoin) must contain a mechanism for joining the Overlay.


Field Summary
 
Fields inherited from interface hypercast.I_Node
DEFAULT_CONFIG_FILE, PROTOSUB_BUDDYLIST, PROTOSUB_MULTICAST, PROTOSUB_NOSPEC, PROTOSUB_SERVER
 
Method Summary
 hypercast.I_Message createDTMessage(byte type, hypercast.DT.DT_AddressPair dst, hypercast.DT.DT_AddressPair cw, hypercast.DT.DT_AddressPair ccw)
          This method creates a new DT_Message based on parameters.
 hypercast.I_LogicalAddress createLogicalAddress(byte[] array, int offset)
          Constructs a DT_LogicalAddress from a byte array.
 hypercast.I_LogicalAddress createLogicalAddress(java.lang.String laStr)
          Creates a logical address object from a String.
 void deleteNeighbor(hypercast.DT.DT_AddressPair dtap)
          Deletes a neighbor from the neighborhood table and updates timers.
 hypercast.I_AddressPair getAddressPair()
          Returns the physical address/logical address pair of this node.
 hypercast.I_AddressPair[] getAllNeighbors()
          Returns the AddressPairs of all the neighbors
 hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
          Return the AddressPairs of neighbor that are children of this node in a spanning tree rooted at rootCoords.
 hypercast.I_AddressPair getNextHopToLeader()
          Returns the AddressPair of the neighbor with the greatest coordinates.
 hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
          Returns AddressPair of neighbor that is parent of this node in a spanning tree rooted at rootCoords.
 org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the schema element which represents the root of the sub-tree, specified by the given xpath, in read schema tree.
 org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the result of query for the statistics specified by the given xpath.
 java.lang.String getStatsName()
          Gets the element name of this I_Stats instance.
 org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath)
          Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.
 boolean isLeader()
          Returns true if none of the node's neighbors has a greater logical address.
 void joinOverlay()
          Joins the overlay multicast group.
 void leaveOverlay()
          Leaves the overlay multicast group.
 void messageArrivedFromAdapter(hypercast.I_Message a)
          This function, a member of I_AdapterCallback, is called whenever a protocol message arrives.
 boolean previousHopCheck(hypercast.I_LogicalAddress src, hypercast.I_LogicalAddress dst, hypercast.I_LogicalAddress prehop)
          Verify the previous hop of the message.
 hypercast.I_Message restoreMessage(byte[] buffer, int[] startValidBytes, int endValidBytes)
          Creates a protocol message from a byte[].
 void setLogicalAddress(hypercast.I_LogicalAddress la)
          Sets the logical address of this node to the specified one.
 void setNotificationHandler(hypercast.NotificationHandler nh)
          Set notification handler.
 org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc, org.apache.xpath.XPath xpath, org.w3c.dom.Element newValue)
          Set the statistics specified by the given xpath.
 void setStatsName(java.lang.String name)
          Assigns a name to this I_Stats instance.
 void timerExpired(java.lang.Object Timer_Index)
          This function, a member of I_AdapterCallback, is called for the heartbeat timer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

joinOverlay

public void joinOverlay()
Joins the overlay multicast group.

Specified by:
joinOverlay in interface I_Node

leaveOverlay

public void leaveOverlay()
Leaves the overlay multicast group.

Specified by:
leaveOverlay in interface I_Node

restoreMessage

public hypercast.I_Message restoreMessage(byte[] buffer,
                                          int[] startValidBytes,
                                          int endValidBytes)
Creates a protocol message from a byte[]. Required in order to implement I_AdapterCallback.

Specified by:
restoreMessage in interface I_AdapterCallback
Parameters:
buffer - the byte array buffer of a incoming stream
startValidBytes - the start index to create a message from
endValidBytes - the total length of bytes in this buffer
Returns:
null if buffer does not contain a complete message.
See Also:
I_AdapterCallback.restoreMessage(byte[], int[], int)

isLeader

public boolean isLeader()
Returns true if none of the node's neighbors has a greater logical address.


getAddressPair

public hypercast.I_AddressPair getAddressPair()
Returns the physical address/logical address pair of this node.

Specified by:
getAddressPair in interface I_Node

getParent

public hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
Returns AddressPair of neighbor that is parent of this node in a spanning tree rooted at rootCoords. This is calculated by finding the neighbor that forms the smallest angle with rootCoords.

Specified by:
getParent in interface I_Node

getChildren

public hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
Return the AddressPairs of neighbor that are children of this node in a spanning tree rooted at rootCoords. This based on if DT_Node.getParent() of the neighbor would return this node.

Specified by:
getChildren in interface I_Node

getAllNeighbors

public hypercast.I_AddressPair[] getAllNeighbors()
Returns the AddressPairs of all the neighbors

Specified by:
getAllNeighbors in interface I_Node

getNextHopToLeader

public hypercast.I_AddressPair getNextHopToLeader()
Returns the AddressPair of the neighbor with the greatest coordinates.

Returns:
null if this node's LogicalAddress is greater than all its neighbors.

createLogicalAddress

public hypercast.I_LogicalAddress createLogicalAddress(byte[] array,
                                                       int offset)
Constructs a DT_LogicalAddress from a byte array.

Specified by:
createLogicalAddress in interface I_Node

createLogicalAddress

public hypercast.I_LogicalAddress createLogicalAddress(java.lang.String laStr)
Creates a logical address object from a String.

Specified by:
createLogicalAddress in interface I_Node

setLogicalAddress

public void setLogicalAddress(hypercast.I_LogicalAddress la)
Sets the logical address of this node to the specified one.

Specified by:
setLogicalAddress in interface I_Node

previousHopCheck

public boolean previousHopCheck(hypercast.I_LogicalAddress src,
                                hypercast.I_LogicalAddress dst,
                                hypercast.I_LogicalAddress prehop)
Verify the previous hop of the message. If checkmode is set to "neighborCheck", this method checks if the previous hop is a neighbor; otherwise this method checks if the previous hop is a valid sender of OL messages.

Specified by:
previousHopCheck in interface I_Node

setNotificationHandler

public void setNotificationHandler(hypercast.NotificationHandler nh)
Set notification handler.

Specified by:
setNotificationHandler in interface I_Node

timerExpired

public void timerExpired(java.lang.Object Timer_Index)
This function, a member of I_AdapterCallback, is called for the heartbeat timer. When the timer occurs, the node sends Hello messages to all of its neighbors. At the same time, the node checks if any of its neighbors has timed out.

Specified by:
timerExpired in interface I_AdapterCallback

messageArrivedFromAdapter

public void messageArrivedFromAdapter(hypercast.I_Message a)
This function, a member of I_AdapterCallback, is called whenever a protocol message arrives. The function determines the proper reaction to each message type.

Specified by:
messageArrivedFromAdapter in interface I_AdapterCallback

deleteNeighbor

public void deleteNeighbor(hypercast.DT.DT_AddressPair dtap)
Deletes a neighbor from the neighborhood table and updates timers.


createDTMessage

public hypercast.I_Message createDTMessage(byte type,
                                           hypercast.DT.DT_AddressPair dst,
                                           hypercast.DT.DT_AddressPair cw,
                                           hypercast.DT.DT_AddressPair ccw)
This method creates a new DT_Message based on parameters. It is called by all sending methods and can be overrided in secure node class.


getStatsName

public java.lang.String getStatsName()
Description copied from interface: I_Stats
Gets the element name of this I_Stats instance. The element name is originally assigned from the attribute StstsName in the configuration file, and can be changed by this method.

Specified by:
getStatsName in interface I_Stats
See Also:
I_Stats.getStatsName()

setStatsName

public void setStatsName(java.lang.String name)
Description copied from interface: I_Stats
Assigns a name to this I_Stats instance. The assigned name becomes the tag of the element associated to this I_Stats instance on the statistics tree.

Specified by:
setStatsName in interface I_Stats
Parameters:
name - the name assigned to the I_Stats instance.
See Also:
I_Stats.setStatsName(String)

getStats

public org.w3c.dom.Element[] getStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath)
                               throws HyperCastStatsException
Return the result of query for the statistics specified by the given xpath.

Specified by:
getStats in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance represents the statistics to be queried.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree.
See Also:
I_Stats.getStats(org.w3c.dom.Document, org.apache.xpath.XPath)

setStats

public org.w3c.dom.Element[] setStats(org.w3c.dom.Document doc,
                                      org.apache.xpath.XPath xpath,
                                      org.w3c.dom.Element newValue)
                               throws HyperCastStatsException
Set the statistics specified by the given xpath. The value actually set is returned.

Specified by:
setStats in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance represents the statistics to be queried.
newValue - Element representing the value or sub-tree to be set.
Throws:
HyperCastStatsException - If the xpath does not specify a valid subtree or if any part of the the subtree is read-only, or if the newValue does not conform with the expected format.
See Also:
I_Stats.setStats(org.w3c.dom.Document, org.apache.xpath.XPath, org.w3c.dom.Element)

getReadSchema

public org.w3c.dom.Element[] getReadSchema(org.w3c.dom.Document doc,
                                           org.apache.xpath.XPath xpath)
                                    throws HyperCastStatsException
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in read schema tree.

Specified by:
getReadSchema in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance representing the statistics which is the root of the sub-tree to be queried.
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getReadSchema(Document, XPath)

getWriteSchema

public org.w3c.dom.Element[] getWriteSchema(org.w3c.dom.Document doc,
                                            org.apache.xpath.XPath xpath)
                                     throws HyperCastStatsException
Return the schema element which represents the root of the sub-tree, specified by the given xpath, in write schema tree.

Specified by:
getWriteSchema in interface I_Stats
Parameters:
doc - Document used for create new elements or nodes.
xpath - XPath instance representing the statistics which is the root of the sub-tree to be queried.
Throws:
HyperCastStatsException - If some part of the specified subtree does not correctly implement this interface method.
See Also:
I_Stats.getWriteSchema(Document, XPath)