hypercast.DT
Class DT_Server

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

public final class DT_Server
extends java.lang.Object
implements I_AdapterCallback, I_Node

This class implements the DT Protocol server.


Field Summary
 hypercast.I_UnicastAdapter adapter
          The adapter of the DT server.
 hypercast.DT.DT_AddressPair myAddressPair
          Used for sending messages.
static java.util.Random rand
           
static long T_REFRESH
           
 
Fields inherited from interface hypercast.I_Node
DEFAULT_CONFIG_FILE, PROTOSUB_BUDDYLIST, PROTOSUB_MULTICAST, PROTOSUB_NOSPEC, PROTOSUB_SERVER
 
Constructor Summary
DT_Server(hypercast.HyperCastConfig config, hypercast.I_UnicastAdapter Adapter)
           
 
Method Summary
 hypercast.DT.DT_Message createDTMessage(byte type, hypercast.DT.DT_AddressPair dst, hypercast.DT.DT_AddressPair cw, hypercast.DT.DT_AddressPair ccw)
           
 hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr, int offset)
          Creates a logical address object from a byte array.
 hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr, int offset, int index)
          Creates a logical address object based on the specified index from a byte array.
 hypercast.I_LogicalAddress createLogicalAddress(java.lang.String laStr)
          Creates a logical address object from a String.
 hypercast.I_AddressPair getAddressPair()
          Returns this logical and physical addresses of this node.
 hypercast.I_AddressPair[] getAllNeighbors()
          Returns the node's neighbors' physical/logical address pairs.
 hypercast.I_AddressPair[] getAllNeighbors(hypercast.I_LogicalAddress root)
          Returns the node's neighbors' physical/logical address pairs.
 hypercast.I_AddressPair[] getAllNeighbors(int index)
          Returns the node's ,which has specified index, neighbors' physical/logical address pairs.
 hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
          Returns the node's children's physical/logical address pairs, with respect to the spanning tree rooted at root.
 hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root, int index)
          Returns the node's, which has specified index, children's physical/logical address pairs , with respect to the spanning tree rooted at root.
 hypercast.I_LogicalAddress getLogicalAddress()
          Returns this logical addresses of this node.
 hypercast.I_LogicalAddress getLogicalAddress(int index)
          Returns this logical addresses of this node.
 hypercast.I_AddressPair getMyAddressPair(hypercast.I_LogicalAddress root)
          Returns the physical address/logical address pair of this node.
 hypercast.I_AddressPair getMyAddressPair(int index)
          Returns this logical and physical addresses of the node with specific index.
 int getOverlayHash()
          return the Overlay Hash
 hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
          Returns the addresspair of the next hop for a message routed by this node towards the root.
 hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root, int index)
          Returns the addresspair of the next hop corresponding to the node with specified index for a message routed by this node towards the root.
 hypercast.I_PhysicalAddress getPhysicalAddress()
          Returns this physical addresses of this node.
 hypercast.I_PhysicalAddress getPhysicalAddress(int index)
          Returns this physical addresses of this node.
 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.
 hypercast.DT.DT_Message handleMessage(hypercast.DT.DT_Message m)
          Process received message based on the message types.
 void joinOverlay()
          Joins the overlay.
 void leaveOverlay()
          Leaves the overlay.
static void main(java.lang.String[] args)
          Start the DT server.
 void messageArrivedFromAdapter(hypercast.I_Message m)
          handle messages when they arrived at the Message Buffer.
 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)
          restore a message from a byte array
 void setLogicalAddress(hypercast.I_LogicalAddress la)
          Sets the logical address to 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 method is called when timer expires
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

T_REFRESH

public static final long T_REFRESH
See Also:
Constant Field Values

adapter

public hypercast.I_UnicastAdapter adapter
The adapter of the DT server.


myAddressPair

public hypercast.DT.DT_AddressPair myAddressPair
Used for sending messages.


rand

public static java.util.Random rand
Constructor Detail

DT_Server

public DT_Server(hypercast.HyperCastConfig config,
                 hypercast.I_UnicastAdapter Adapter)
Method Detail

getOverlayHash

public int getOverlayHash()
return the Overlay Hash


messageArrivedFromAdapter

public void messageArrivedFromAdapter(hypercast.I_Message m)
handle messages when they arrived at the Message Buffer.

Specified by:
messageArrivedFromAdapter in interface I_AdapterCallback

handleMessage

public hypercast.DT.DT_Message handleMessage(hypercast.DT.DT_Message m)
Process received message based on the message types.


restoreMessage

public hypercast.I_Message restoreMessage(byte[] buffer,
                                          int[] startValidBytes,
                                          int endValidBytes)
restore a message from a byte array

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.

timerExpired

public void timerExpired(java.lang.Object Timer_Index)
This method is called when timer expires

Specified by:
timerExpired in interface I_AdapterCallback

createDTMessage

public hypercast.DT.DT_Message createDTMessage(byte type,
                                               hypercast.DT.DT_AddressPair dst,
                                               hypercast.DT.DT_AddressPair cw,
                                               hypercast.DT.DT_AddressPair ccw)

main

public static void main(java.lang.String[] args)
Start the DT server.


joinOverlay

public void joinOverlay()
Joins the overlay. Do nothing

Specified by:
joinOverlay in interface I_Node

leaveOverlay

public void leaveOverlay()
Leaves the overlay. Do nothing.

Specified by:
leaveOverlay in interface I_Node

getParent

public hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
Returns the addresspair of the next hop for a message routed by this node towards the root. Return null;

Specified by:
getParent in interface I_Node

getChildren

public hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
Returns the node's children's physical/logical address pairs, with respect to the spanning tree rooted at root. Return null;

Specified by:
getChildren in interface I_Node

getAllNeighbors

public hypercast.I_AddressPair[] getAllNeighbors()
Returns the node's neighbors' physical/logical address pairs. Return null;

Specified by:
getAllNeighbors in interface I_Node

getAddressPair

public hypercast.I_AddressPair getAddressPair()
Returns this logical and physical addresses of this node.

Specified by:
getAddressPair in interface I_Node

getPhysicalAddress

public hypercast.I_PhysicalAddress getPhysicalAddress()
Returns this physical addresses of this node.


getLogicalAddress

public hypercast.I_LogicalAddress getLogicalAddress()
Returns this logical addresses of this node.


createLogicalAddress

public hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr,
                                                       int offset)
Creates a logical address object from a byte array. Return null.

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. Return null.

Specified by:
createLogicalAddress in interface I_Node

setLogicalAddress

public void setLogicalAddress(hypercast.I_LogicalAddress la)
Sets the logical address to specified one. Do nothing.

Specified by:
setLogicalAddress in interface I_Node

getParent

public hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root,
                                           int index)
Returns the addresspair of the next hop corresponding to the node with specified index for a message routed by this node towards the root. Return null.


getChildren

public hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root,
                                             int index)
Returns the node's, which has specified index, children's physical/logical address pairs , with respect to the spanning tree rooted at root. Return null..


getAllNeighbors

public hypercast.I_AddressPair[] getAllNeighbors(int index)
Returns the node's ,which has specified index, neighbors' physical/logical address pairs. Return null.


getAllNeighbors

public hypercast.I_AddressPair[] getAllNeighbors(hypercast.I_LogicalAddress root)
Returns the node's neighbors' physical/logical address pairs. The logical address root contains index information. Return null.


getMyAddressPair

public hypercast.I_AddressPair getMyAddressPair(int index)
Returns this logical and physical addresses of the node with specific index.


getMyAddressPair

public hypercast.I_AddressPair getMyAddressPair(hypercast.I_LogicalAddress root)
Returns the physical address/logical address pair of this node. The logical address is ignored.


getPhysicalAddress

public hypercast.I_PhysicalAddress getPhysicalAddress(int index)
Returns this physical addresses of this node. Index is ignored.


getLogicalAddress

public hypercast.I_LogicalAddress getLogicalAddress(int index)
Returns this logical addresses of this node. Index is ignored.


createLogicalAddress

public hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr,
                                                       int offset,
                                                       int index)
Creates a logical address object based on the specified index from a byte array. Return null.


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. It does nothing in DT_server.

Specified by:
previousHopCheck in interface I_Node

setNotificationHandler

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

Specified by:
setNotificationHandler in interface I_Node

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)

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)