edu.virginia.cs.mng.hypercast.HC
Class HC_Node

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.HC.HC_Node

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

HC_Node is a full implementation of the Hypercube protocol.


Field Summary
private  I_MulticastAdapter Adapter
          The multicast adapter that this protocol node runs on
private  OverlaySocketConfig config
          The OverlaySocketConfig object containing the properties of this group.
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
private  boolean joined
          True if joinGroup has not been followed by a leaveGroup
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
(package private)  int MaxAge
          The maximum time of a node's age, in heartbeats (Ttimeout / Theartbeat)
(package private) static int MaxHypercubeDim
          The maximum of the Hypercube dimension, pretty much must be 31
(package private)  int MaxMissingNeighbor
          The maximum missing neighbor time of a node, in heartbeats (Tmissing / Theartbeat)
private  int MaxSuppressJoinBeacon
          The maximum supressing joining time of a node, in heartbeats (Tjoining / Theartbeat)
static byte MissingNeighbor
          The state of this node, missing neighbor
static byte MissingNeighborAction
          The state of this node, missing neighbor action
(package private)  HC_LogicalAddress MyLogicalAddress
          The logical address of this node
private  byte MyState
          The state of this node
private  HC_Neighborhood neighbors
          The neighborhood of this node
private  int SleepTime
          The Heart Beat time of the node, in ms
static byte Stable
          The state of this node, stable
static byte StartHypercube
          The state of this node, start a hypercube
 
Constructor Summary
HC_Node(OverlaySocketConfig c, I_MulticastAdapter madapter)
          Constructs a HC_Node object with an infrustructure I_UnicastAdapter
 
Method Summary
 I_LogicalAddress createLogicalAddress(byte[] laddr, int offset)
          Creates an I_LogicalAddress object from an bytes array.
 I_AddressPair[] getAllNeighbors()
          Gets the AddressPair[] of this node's all neighbors
 I_AddressPair[] getChildren(I_LogicalAddress root)
          Gets the AddressPair[] of this node's Children with reference to a given Root
 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
 I_AddressPair getMyAddressPair()
          Gets the AddressPair of this node
 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.
 I_AddressPair getParent(I_LogicalAddress root)
          Gets the AddressPair[] of this node's Children with reference to a given Root.
 HC_AddressPair getPred()
          Gets the AddressPair of the Predecessesor of this node in the Hypercube
 java.lang.String[] getSchema()
          Get the Statistics information description of this Adapter.
 byte getState()
          Gets the node's current state
 java.lang.String getStats(java.lang.String name)
          Get the Statistics information of this HC_Node.
 HC_AddressPair getSucc()
          Gets the AddressPair of the Sueecssor of this node in the Hypercube
 void joinGroup()
          Joins a multicast group
 void leaveGroup()
          Leaves a multicast group
private  void leaveNeighborhood()
          Sends leave message to all neighbors
static int MaxAddress()
          Gets the maximum logical address number of this hypercube.
 void messageArrivedFromAdapter(I_Message msg)
          Processes the message received from an I_UnicastAdapter.
private  void multicastSend(byte type)
          Sends Hypercast Messages to Multicast address through the Adapter
private  void pingNeighbors()
          Sends ping message to all neighbors
private  void resetNeighborhood()
          Resets all neighbors
 I_Message restoreMessage(byte[] recvbuff, int[] validBytesStart, int validBytesEnd)
          Creates an HC_Message if there are enough valid bytes in the buffer.
 void setStats(java.lang.String name, java.lang.String value)
          Sets the Statistic information in this Adapter.
 void timerExpired(int timerID)
          This function processes a timer event This is also the kernel part of the Hypercast protocol.
private  void unicastSend(byte type, I_PhysicalAddress paddr, HC_LogicalAddress laddr)
          Sends Hypercast Messages to Unicast address through the Adapter
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

config

private OverlaySocketConfig config
The OverlaySocketConfig object containing the properties of this group.

Adapter

private I_MulticastAdapter Adapter
The multicast adapter that this protocol node runs on

neighbors

private HC_Neighborhood neighbors
The neighborhood of this node

MyLogicalAddress

HC_LogicalAddress MyLogicalAddress
The logical address of this node

MyState

private byte MyState
The state of this node

Joining

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

Stable

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

MissingNeighbor

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

MissingNeighborAction

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

HRoot

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

HRootMissingNeighbor

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

HRootMissingNeighborAction

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

Leaving

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

StartHypercube

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

JoiningWait

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

Dead

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

MaxHypercubeDim

static final int MaxHypercubeDim
The maximum of the Hypercube dimension, pretty much must be 31

SleepTime

private int SleepTime
The Heart Beat time of the node, in ms

MaxAge

int MaxAge
The maximum time of a node's age, in heartbeats (Ttimeout / Theartbeat)

MaxMissingNeighbor

int MaxMissingNeighbor
The maximum missing neighbor time of a node, in heartbeats (Tmissing / Theartbeat)

MaxSuppressJoinBeacon

private int MaxSuppressJoinBeacon
The maximum supressing joining time of a node, in heartbeats (Tjoining / Theartbeat)

joined

private boolean joined
True if joinGroup has not been followed by a leaveGroup
Constructor Detail

HC_Node

public HC_Node(OverlaySocketConfig c,
               I_MulticastAdapter madapter)
Constructs a HC_Node object with an infrustructure I_UnicastAdapter
Parameters:
adp - an object of I_MulticastAdapter
Method Detail

joinGroup

public void joinGroup()
Joins a multicast group
Specified by:
joinGroup in interface I_Node

leaveGroup

public void leaveGroup()
Leaves a multicast group
Specified by:
leaveGroup 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 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
See Also:
I_AdapterCallBack.restoreMessage(byte[], int[], int)

createLogicalAddress

public 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

messageArrivedFromAdapter

public void messageArrivedFromAdapter(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(int timerID)
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:
time_id - time event ID

unicastSend

private void unicastSend(byte type,
                         I_PhysicalAddress paddr,
                         HC_LogicalAddress laddr)
Sends Hypercast Messages to Unicast address through the Adapter
Parameters:
type - Message type
paddr - I_PhysicalAddress of destination
laddr - HC_LogicalAddress of destination

multicastSend

private void multicastSend(byte type)
Sends Hypercast Messages to Multicast address through the Adapter
Parameters:
type - Message type

pingNeighbors

private void pingNeighbors()
Sends ping message to all neighbors

resetNeighborhood

private void resetNeighborhood()
Resets all neighbors

leaveNeighborhood

private void leaveNeighborhood()
Sends leave message to all neighbors

getMyAddressPair

public I_AddressPair getMyAddressPair()
Gets the AddressPair of this node
Specified by:
getMyAddressPair in interface I_Node
Returns:
an HC_AddressPair object

getHRoot

public HC_AddressPair getHRoot()
Gets the AddressPair of the HRoot
Returns:
HC_AddressPair object of the HRoot

getSucc

public HC_AddressPair getSucc()
Gets the AddressPair of the Sueecssor of this node in the Hypercube
Returns:
HC_AddressPair object of the Successor

getPred

public HC_AddressPair getPred()
Gets the AddressPair of the Predecessesor of this node in the Hypercube
Returns:
HC_AddressPair object of the Pressesor

getParent

public I_AddressPair getParent(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 I_AddressPair[] getChildren(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 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

getStats

public java.lang.String getStats(java.lang.String name)
                          throws StatsException
Get the Statistics information of this HC_Node.
Parameters:
name - the String representation of a Statistic name
Returns:
String representation of the Statistic
Throws:
throw - StatisticNotFound exception

setStats

public void setStats(java.lang.String name,
                     java.lang.String value)
              throws StatsException
Sets the Statistic information in this Adapter.
Parameters:
name - the String representation of a Statistic name
value - the String representation of the Statistic value
Throws:
throw - WriteToAReadOnlyValue exception
throw - StatisticNotFound exception

getSchema

public java.lang.String[] getSchema()
                             throws StatsException
Get the Statistics information description of this Adapter.
Returns:
the String description of the Schema.

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