hypercast.DT
Class DT_Node_Multicast

java.lang.Object
  |
  +--hypercast.DT.DT_Node_Multicast
All Implemented Interfaces:
I_AdapterCallback, I_Node, I_Stats

public class DT_Node_Multicast
extends java.lang.Object
implements I_AdapterCallback, I_Node

This class implements the basic Delaunay triangulation node and also provides a bootstrap mechanism of overlay by multicasting.

Joins are initiated by the node multicasting a Beacon message to the overlay.


Field Summary
static int BEACON_TIMER_INDEX
          The Adapter timer index used for Beacon Message
static int INCOMPLETE
          Node state
static int LEADER_INCOMPLETE
          Node state
static int LEADER_STABLE
          Node state
static int SINGLE
          Node state
static int STABLE
          Node state
static int STOPPED
          Node state
 
Fields inherited from interface hypercast.I_Node
DEFAULT_CONFIG_FILE, PROTOSUB_BUDDYLIST, PROTOSUB_MULTICAST, PROTOSUB_NOSPEC, PROTOSUB_SERVER
 
Constructor Summary
DT_Node_Multicast(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter a)
           
DT_Node_Multicast(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter a, hypercast.DT.DT_LogicalAddress startingCoords)
           
DT_Node_Multicast(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter a, hypercast.DT.DT_LogicalAddress startingCoords, java.lang.String prefix)
           
DT_Node_Multicast(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter a, java.lang.String prefix)
           
 
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[] 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.
 int getState()
          Returns the current state of the node.
 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.
 void joinOverlay()
          Joins the overlay 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 by two timers: hello heartbeat and Beacon message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEACON_TIMER_INDEX

public static final int BEACON_TIMER_INDEX
The Adapter timer index used for Beacon Message

See Also:
Constant Field Values

SINGLE

public static final int SINGLE
Node state

See Also:
Constant Field Values

LEADER_STABLE

public static final int LEADER_STABLE
Node state

See Also:
Constant Field Values

STABLE

public static final int STABLE
Node state

See Also:
Constant Field Values

LEADER_INCOMPLETE

public static final int LEADER_INCOMPLETE
Node state

See Also:
Constant Field Values

INCOMPLETE

public static final int INCOMPLETE
Node state

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Node state

See Also:
Constant Field Values
Constructor Detail

DT_Node_Multicast

public DT_Node_Multicast(hypercast.HyperCastConfig c,
                         hypercast.I_MulticastAdapter a)

DT_Node_Multicast

public DT_Node_Multicast(hypercast.HyperCastConfig c,
                         hypercast.I_MulticastAdapter a,
                         hypercast.DT.DT_LogicalAddress startingCoords)

DT_Node_Multicast

public DT_Node_Multicast(hypercast.HyperCastConfig c,
                         hypercast.I_MulticastAdapter a,
                         java.lang.String prefix)

DT_Node_Multicast

public DT_Node_Multicast(hypercast.HyperCastConfig c,
                         hypercast.I_MulticastAdapter a,
                         hypercast.DT.DT_LogicalAddress startingCoords,
                         java.lang.String prefix)
Method Detail

joinOverlay

public void joinOverlay()
Joins the overlay 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)

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

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 by two timers: hello heartbeat and Beacon message. When the hello 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.


getState

public int getState()
Returns the current state of the node. State is one of: SINGLE, STABLE, UNSTABLE, etc.


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)