hypercast.HC
Class HC_Node

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

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

HC_Node is a full implementation of the Hypercube protocol. 1. One new constructor is added which contain a string "prefix" in their parameters. The prefix is used for getting attributes. 3. A new method createDTMessage is added which is the constructor of HC_Message and is called by all sending methods. It can be overrided by the extended security node classes. 4. For all timer related methods, such as setTimer, getTimer, cleanTimer and timerExpired, the "timer type" parameter is redifined as a general "Object" instead of a int variable. 5. The Timer in the node adapter is started/stopped explicitly.


Field Summary
static byte Dead
          The state of this node, dead
static byte HRoot
          The state of this node, hroot
static byte HRootMissingNeighbor
          The state of this node, hroot missing neighbor
static byte HRootMissingNeighborAction
          The state of this node, hroot missing neighbor action
static byte Joining
          The state of this node, joinng
static byte JoiningWait
          The state of this node, wait for joining
static byte Leaving
          The state of this node, leaving
static byte MissingNeighbor
          The state of this node, missing neighbor
static byte MissingNeighborAction
          The state of this node, missing neighbor action
static byte Stable
          The state of this node, stable
static byte StartHypercube
          The state of this node, start a hypercube
 
Fields inherited from interface hypercast.I_Node
DEFAULT_CONFIG_FILE, PROTOSUB_BUDDYLIST, PROTOSUB_MULTICAST, PROTOSUB_NOSPEC, PROTOSUB_SERVER
 
Constructor Summary
HC_Node(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter madapter)
          Constructs a HC_Node object with an infrustructure I_UnicastAdapter
HC_Node(hypercast.HyperCastConfig c, hypercast.I_MulticastAdapter madapter, java.lang.String prefix)
          Constructs a HC_Node object with an infrustructure I_UnicastAdapter and attribute prefix
 
Method Summary
 hypercast.HC.HC_Message createHCMessage(byte type, hypercast.I_PhysicalAddress paddr, hypercast.HC.HC_LogicalAddress laddr, hypercast.HC.HC_LogicalAddress root, int seq, byte[] data)
          This method creates a new DT_Message based on parameters.
 hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr, int offset)
          Creates an I_LogicalAddress object from an bytes array.
 hypercast.I_LogicalAddress createLogicalAddress(java.lang.String laStr)
          Creates a logical address object from a String.
 hypercast.I_AddressPair getAddressPair()
          Gets the AddressPair of this node
 hypercast.I_AddressPair[] getAllNeighbors()
          Gets the AddressPair[] of this node's all neighbors
 hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
          Gets the AddressPair[] of this node's Children with reference to a given Root
 hypercast.HC.HC_AddressPair getHRoot()
          Gets the AddressPair of the HRoot
 java.lang.String getLAAddress(java.lang.String NodePALAPair)
          Gets logical address from a node's AddressPair
 java.lang.String getNeighborAttribute(int index, java.lang.String attribute)
          Gets neighbor's physical address or logical address
 java.lang.String getPAAddress(java.lang.String NodePALAPair)
          Gets physical address from a node's AddressPair.
 hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
          Gets the AddressPair[] of this node's Children with reference to a given Root.
 hypercast.HC.HC_AddressPair getPred()
          Gets the AddressPair of the Predecessesor of this node in the Hypercube
 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.
 byte getState()
          Gets the node's current state
 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.
 hypercast.HC.HC_AddressPair getSucc()
          Gets the AddressPair of the Sueecssor of this node in the Hypercube
 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 a multicast group
 void leaveOverlay()
          Leaves a multicast group
static int MaxAddress()
          Gets the maximum logical address number of this hypercube.
 void messageArrivedFromAdapter(hypercast.I_Message msg)
          Processes the message received from an I_UnicastAdapter.
 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[] recvbuff, int[] validBytesStart, int validBytesEnd)
          Creates an HC_Message if there are enough valid bytes in the buffer.
 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_ID)
          This function processes a timer event
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Joining

public static final byte Joining
The state of this node, joinng

See Also:
Constant Field Values

Stable

public static final byte Stable
The state of this node, stable

See Also:
Constant Field Values

MissingNeighbor

public static final byte MissingNeighbor
The state of this node, missing neighbor

See Also:
Constant Field Values

MissingNeighborAction

public static final byte MissingNeighborAction
The state of this node, missing neighbor action

See Also:
Constant Field Values

HRoot

public static final byte HRoot
The state of this node, hroot

See Also:
Constant Field Values

HRootMissingNeighbor

public static final byte HRootMissingNeighbor
The state of this node, hroot missing neighbor

See Also:
Constant Field Values

HRootMissingNeighborAction

public static final byte HRootMissingNeighborAction
The state of this node, hroot missing neighbor action

See Also:
Constant Field Values

Leaving

public static final byte Leaving
The state of this node, leaving

See Also:
Constant Field Values

StartHypercube

public static final byte StartHypercube
The state of this node, start a hypercube

See Also:
Constant Field Values

JoiningWait

public static final byte JoiningWait
The state of this node, wait for joining

See Also:
Constant Field Values

Dead

public static final byte Dead
The state of this node, dead

See Also:
Constant Field Values
Constructor Detail

HC_Node

public HC_Node(hypercast.HyperCastConfig c,
               hypercast.I_MulticastAdapter madapter)
Constructs a HC_Node object with an infrustructure I_UnicastAdapter

Parameters:
c - an HyperCastConfig object
madapter - an object of I_MulticastAdapter.

HC_Node

public HC_Node(hypercast.HyperCastConfig c,
               hypercast.I_MulticastAdapter madapter,
               java.lang.String prefix)
Constructs a HC_Node object with an infrustructure I_UnicastAdapter and attribute prefix

Parameters:
c - an HyperCastConfig object
madapter - an object of I_MulticastAdapter.
prefix - property prefix
Method Detail

joinOverlay

public void joinOverlay()
/** Joins a multicast group

Specified by:
joinOverlay in interface I_Node

leaveOverlay

public void leaveOverlay()
Leaves a multicast group

Specified by:
leaveOverlay in interface I_Node

MaxAddress

public static int MaxAddress()
Gets the maximum logical address number of this hypercube. Basically need a 1 in each of the positions. So shift and add 1 for MaxHypercubeDim-1 times

Returns:
The MaxLogicalAddress

restoreMessage

public hypercast.I_Message restoreMessage(byte[] recvbuff,
                                          int[] validBytesStart,
                                          int validBytesEnd)
Creates an HC_Message if there are enough valid bytes in the buffer.

Specified by:
restoreMessage in interface I_AdapterCallback
Parameters:
recvbuff - the byte array buffer of a incoming stream
validBytesStart - the start index to create a message from
validBytesEnd - 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)

createLogicalAddress

public hypercast.I_LogicalAddress createLogicalAddress(byte[] laddr,
                                                       int offset)
Creates an I_LogicalAddress object from an bytes array.

Specified by:
createLogicalAddress in interface I_Node
Parameters:
laddr - bytes array
Returns:
an object of type I_LogicalAddress

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

messageArrivedFromAdapter

public void messageArrivedFromAdapter(hypercast.I_Message msg)
Processes the message received from an I_UnicastAdapter. This is the kernel part of the Hypercast protocol. The HC_Node(Hypercast protocol node) changes it's soft state based on the Messages it receives.

Specified by:
messageArrivedFromAdapter in interface I_AdapterCallback
Parameters:
msg - I_Message

timerExpired

public void timerExpired(java.lang.Object Timer_ID)
This function processes a timer event

This is also the kernel part of the Hypercast protocol. The HC_Node changes it's state, pings it's neighborhod everytime there is a timer event comes in.

Specified by:
timerExpired in interface I_AdapterCallback
Parameters:
Timer_ID - time event ID

createHCMessage

public hypercast.HC.HC_Message createHCMessage(byte type,
                                               hypercast.I_PhysicalAddress paddr,
                                               hypercast.HC.HC_LogicalAddress laddr,
                                               hypercast.HC.HC_LogicalAddress root,
                                               int seq,
                                               byte[] data)
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.


getAddressPair

public hypercast.I_AddressPair getAddressPair()
Gets the AddressPair of this node

Specified by:
getAddressPair in interface I_Node
Returns:
an HC_AddressPair object

getHRoot

public hypercast.HC.HC_AddressPair getHRoot()
Gets the AddressPair of the HRoot

Returns:
HC_AddressPair object of the HRoot

getSucc

public hypercast.HC.HC_AddressPair getSucc()
Gets the AddressPair of the Sueecssor of this node in the Hypercube

Returns:
HC_AddressPair object of the Successor

getPred

public hypercast.HC.HC_AddressPair getPred()
Gets the AddressPair of the Predecessesor of this node in the Hypercube

Returns:
HC_AddressPair object of the Pressesor

getParent

public hypercast.I_AddressPair[] getParent(hypercast.I_LogicalAddress root)
Gets the AddressPair[] of this node's Children with reference to a given Root. * If the hroot != null and children != null, return children's addresspairs. * else, return null.

Specified by:
getParent in interface I_Node
Parameters:
root - HC_LogicalAddress object of a Root
Returns:
HC_AddressPair object of the Parent

getChildren

public hypercast.I_AddressPair[] getChildren(hypercast.I_LogicalAddress root)
Gets the AddressPair[] of this node's Children with reference to a given Root

Specified by:
getChildren in interface I_Node
Parameters:
root - HC_LogicalAddress object of a Root
Returns:
HC_AddressPair array of the Children

getAllNeighbors

public hypercast.I_AddressPair[] getAllNeighbors()
Gets the AddressPair[] of this node's all neighbors

Specified by:
getAllNeighbors in interface I_Node
Returns:
HC_AddressPair array of all the neighbors

getState

public byte getState()
Gets the node's current state

Returns:
the Node's current state

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)

getNeighborAttribute

public java.lang.String getNeighborAttribute(int index,
                                             java.lang.String attribute)
Gets neighbor's physical address or logical address

Parameters:
attribute - PA or LA
Returns:
index the index of the neighbor

getPAAddress

public java.lang.String getPAAddress(java.lang.String NodePALAPair)
Gets physical address from a node's AddressPair.


getLAAddress

public java.lang.String getLAAddress(java.lang.String NodePALAPair)
Gets logical address from a node's AddressPair