edu.virginia.cs.mng.hypercast.DT
Class DT_Node

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.DT.DT_Node
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
protected  I_UnicastAdapter adapter
          Network adapter (used for timers and Physical Address).
private  java.util.Vector bandwidthCheckpoints
          Vector of DT_BandwidthCheckpoint.
protected  OverlaySocketConfig config
          Source of constants & error/log message display
private  long FAST_HEARTBEAT_TIME
          In milliseconds, the maximum time to wait to send a message to the neighbors informing them of a change to the neighbor table.
private static long FAST_HEARTBEAT_TIME_DEFAULT
          String for the default update time.
private static java.lang.String FAST_HEARTBEAT_TIME_PROPERTY_NAME
          Name of property controlling update.
private static int HEARTBEAT_TIMER_INDEX
          Adapter timer index used for heartbeat.
private  boolean HeartbeatSetToFastHeartbeat
          Keeps track of whether heartbeat is set to Fast or Slow heartbeat.
protected  boolean joined
          True if joinOverlay has been called without matching leaveGroup.
private  long lastChangeToNeighborhood
          Time of last change to the neighborhood.
private  double maxReceiveRateInAHeartbeat
          Max burst seen since last joinOverlay.
private  double maxSendRateInAHeartbeat
          Max burst seen since last joinOverlay.
(package private)  java.lang.String MessageCallBackDebug
          Debug string.
protected  int messagesReceivedInLastHeartbeat
          Used the calculate the burst-message-load.
protected  int messagesSentInLastHeartbeat
          Used the calculate the burst-message-load.
protected  DT_Neighborhood neighborhood
          The list of neighbors
private static java.lang.String NODE_COORDS_DEFAULT
          String for the default coordinates.
private static java.lang.String NODE_COORDS_PROPERTY_NAME
          Name of property controlling coordinates.
protected static java.util.Random rand
          It may be used to generate the node's LogicalAddress.
private  long SLOW_HEARTBEAT_TIME
          In milliseconds, the time between the keep-alive messages.
private static long SLOW_HEARTBEAT_TIME_DEFAULT
          String for the default keep alive time.
private static java.lang.String SLOW_HEARTBEAT_TIME_PROPERTY_NAME
          Name of property controlling keep alive.
private  boolean StableAtHeartbeat
          True if isStable() returned true at the last expiration of the heartbeat timer.
(package private)  java.lang.Object startStopLock
          Object used to prevent problems while starting and stopping the node.
private  long startTime
          Time of the call to joinGroup()
(package private)  TimedStopper stopper
          Object used to stop all threads TIMEOUT seconds after the call to leaveGroup().
private  long stopTime
          Time of the call to leaveGroup()
private  long timeOfLastHeartbeat
          Used the calculate the burst-message-load.
protected  long TIMEOUT_TIME
          In milliseconds, the time required before a silent neighbor is removed.
private static long TIMEOUT_TIME_DEFAULT
          String for the default timeout time.
private static java.lang.String TIMEOUT_TIME_PROPERTY_NAME
          Name of property controlling timeout time.
(package private)  java.lang.String TimerCallBackDebug
          Debug string.
private  boolean timerCleared
          Used to coordinate resetting and clearing of the heartbeat timer.
 
Constructor Summary
(package private) DT_Node(OverlaySocketConfig c, I_UnicastAdapter a)
           
(package private) DT_Node(OverlaySocketConfig c, I_UnicastAdapter a, DT_LogicalAddress startingCoords)
           
 
Method Summary
protected  void changeSlowHeartbeatToFastHeartbeat()
           
private  DT_LogicalAddress createLogicalAddress()
          Creates the node's logical address given properties.
 I_LogicalAddress createLogicalAddress(byte[] array, int offset)
          Constructs a DT_LogicalAddress from a byte array.
 void deleteNeighbor(DT_AddressPair dtap)
          Deletes a neighbor from the neighborhood table and updates timers.
 I_AddressPair[] getAllNeighbors()
          Returns the AddressPairs of all the neighbors
 I_AddressPair[] getChildren(I_LogicalAddress root)
          Return the AddressPairs of neighbor that are children of this node in a spanning tree rooted at rootCoords.
 I_AddressPair getMyAddressPair()
          Returns the physical address/logical address pair of this node.
 I_AddressPair getNextHopToLeader()
          Returns the AddressPair of the neighbor with the greatest coordinates.
 I_AddressPair getParent(I_LogicalAddress root)
          Returns AddressPair of neighbor that is parent of this node in a spanning tree rooted at rootCoords.
 java.lang.String[] getSchema()
          Part of I_Stats interface.
 java.lang.String getStats(java.lang.String name)
          Part of I_Stats interface.
protected  void goodbyeAllNeighbors()
          Sends a Goodbye message to all of the node's neighbors.
private  void handleGoodbye(DT_Message m)
          Removes the sender of the message from the neighborhood.
private  void handleHello(DT_Message m)
          Preforms actions associated with the arrival of a Hello or HelloNotNeighbor message.
protected  void handleNewNode(DT_Message m)
          Used by NewNode method of joins.
protected  void handleNodePing(DT_Message m)
           
private  void handleTimeoutTimer(long currentTime)
          Remove nodes that have timed out.
protected  void helloAllNeighbors()
          Sends a Hello message to all of the node's neighbors.
private  boolean isCandidateNeighbor(DT_AddressPair dest)
           
 boolean isLeader()
          Returns true if none of the node's neighbors has a greater logical address.
 void joinGroup()
          Joins the overlay multicast group.
 void leaveGroup()
          Leaves the overlay multicast group.
 void messageArrivedFromAdapter(I_Message a)
          This function, a member of I_AdapterCallBack, is called whenever a protocol message arrives.
 I_Message restoreMessage(byte[] buffer, int[] startValidBytes, int endValidBytes)
          Creates a protocol message from a byte[].
protected  void sendGoodbyeMessage(DT_AddressPair dst)
          Sends a Goodbye message to a node.
protected  void sendHelloNeighborMessage(DT_AddressPair dst)
          Sends a Hello message to a node.
protected  void sendHelloNotNeighborMessage(DT_AddressPair dst)
          Send a HelloNotNeighbor message to a node
private  void sendHellosToCandidateNeighbors()
           
protected  void sendNewNodeMessage(DT_AddressPair dst, DT_AddressPair target)
           
protected  void sendTestMessage(DT_AddressPair dst, DT_AddressPair target)
           
 void setStats(java.lang.String name, java.lang.String value)
          Part of I_Stats interface.
 void timerExpired(int timerIndex)
          This function, a member of I_AdapterCallBack, is called for the heartbeat timer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

rand

protected static java.util.Random rand
It may be used to generate the node's LogicalAddress.

HEARTBEAT_TIMER_INDEX

private static final int HEARTBEAT_TIMER_INDEX
Adapter timer index used for heartbeat.

SLOW_HEARTBEAT_TIME_DEFAULT

private static final long SLOW_HEARTBEAT_TIME_DEFAULT
String for the default keep alive time.

SLOW_HEARTBEAT_TIME_PROPERTY_NAME

private static final java.lang.String SLOW_HEARTBEAT_TIME_PROPERTY_NAME
Name of property controlling keep alive.

FAST_HEARTBEAT_TIME_DEFAULT

private static final long FAST_HEARTBEAT_TIME_DEFAULT
String for the default update time.

FAST_HEARTBEAT_TIME_PROPERTY_NAME

private static final java.lang.String FAST_HEARTBEAT_TIME_PROPERTY_NAME
Name of property controlling update.

TIMEOUT_TIME_DEFAULT

private static final long TIMEOUT_TIME_DEFAULT
String for the default timeout time.

TIMEOUT_TIME_PROPERTY_NAME

private static final java.lang.String TIMEOUT_TIME_PROPERTY_NAME
Name of property controlling timeout time.

NODE_COORDS_DEFAULT

private static final java.lang.String NODE_COORDS_DEFAULT
String for the default coordinates.

NODE_COORDS_PROPERTY_NAME

private static final java.lang.String NODE_COORDS_PROPERTY_NAME
Name of property controlling coordinates.

SLOW_HEARTBEAT_TIME

private long SLOW_HEARTBEAT_TIME
In milliseconds, the time between the keep-alive messages. Set from the OverlaySocketConfig object.

FAST_HEARTBEAT_TIME

private long FAST_HEARTBEAT_TIME
In milliseconds, the maximum time to wait to send a message to the neighbors informing them of a change to the neighbor table.

TIMEOUT_TIME

protected long TIMEOUT_TIME
In milliseconds, the time required before a silent neighbor is removed. Set from the OverlaySocketConfig object.

timerCleared

private boolean timerCleared
Used to coordinate resetting and clearing of the heartbeat timer.

neighborhood

protected DT_Neighborhood neighborhood
The list of neighbors

config

protected OverlaySocketConfig config
Source of constants & error/log message display

adapter

protected I_UnicastAdapter adapter
Network adapter (used for timers and Physical Address).

joined

protected boolean joined
True if joinOverlay has been called without matching leaveGroup.

timeOfLastHeartbeat

private long timeOfLastHeartbeat
Used the calculate the burst-message-load.

messagesReceivedInLastHeartbeat

protected int messagesReceivedInLastHeartbeat
Used the calculate the burst-message-load.

messagesSentInLastHeartbeat

protected int messagesSentInLastHeartbeat
Used the calculate the burst-message-load.

maxReceiveRateInAHeartbeat

private double maxReceiveRateInAHeartbeat
Max burst seen since last joinOverlay.

maxSendRateInAHeartbeat

private double maxSendRateInAHeartbeat
Max burst seen since last joinOverlay.

bandwidthCheckpoints

private java.util.Vector bandwidthCheckpoints
Vector of DT_BandwidthCheckpoint. Used to record bandwidth used in an experiment.
See Also:
DT_BandwidthCheckpoint

HeartbeatSetToFastHeartbeat

private boolean HeartbeatSetToFastHeartbeat
Keeps track of whether heartbeat is set to Fast or Slow heartbeat.

StableAtHeartbeat

private boolean StableAtHeartbeat
True if isStable() returned true at the last expiration of the heartbeat timer.

TimerCallBackDebug

java.lang.String TimerCallBackDebug
Debug string.

MessageCallBackDebug

java.lang.String MessageCallBackDebug
Debug string.

startTime

private long startTime
Time of the call to joinGroup()

lastChangeToNeighborhood

private long lastChangeToNeighborhood
Time of last change to the neighborhood. Used to determine how long a node has been stable.

stopTime

private long stopTime
Time of the call to leaveGroup()

startStopLock

java.lang.Object startStopLock
Object used to prevent problems while starting and stopping the node.

stopper

TimedStopper stopper
Object used to stop all threads TIMEOUT seconds after the call to leaveGroup().
Constructor Detail

DT_Node

DT_Node(OverlaySocketConfig c,
        I_UnicastAdapter a)

DT_Node

DT_Node(OverlaySocketConfig c,
        I_UnicastAdapter a,
        DT_LogicalAddress startingCoords)
Method Detail

createLogicalAddress

private DT_LogicalAddress createLogicalAddress()
Creates the node's logical address given properties.
Throws:
java.lang.IllegalArgumentException - if properties are incorrectly formatted.

joinGroup

public void joinGroup()
Joins the overlay multicast group.
Specified by:
joinGroup in interface I_Node

leaveGroup

public void leaveGroup()
Leaves the overlay multicast group.
Specified by:
leaveGroup in interface I_Node

restoreMessage

public 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
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.

getMyAddressPair

public I_AddressPair getMyAddressPair()
Returns the physical address/logical address pair of this node.
Specified by:
getMyAddressPair in interface I_Node

getParent

public I_AddressPair getParent(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 I_AddressPair[] getChildren(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 I_AddressPair[] getAllNeighbors()
Returns the AddressPairs of all the neighbors
Specified by:
getAllNeighbors in interface I_Node

getNextHopToLeader

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

createLogicalAddress

public I_LogicalAddress createLogicalAddress(byte[] array,
                                             int offset)
Constructs a DT_LogicalAddress from a byte array.
Specified by:
createLogicalAddress in interface I_Node

timerExpired

public void timerExpired(int timerIndex)
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

handleTimeoutTimer

private void handleTimeoutTimer(long currentTime)
Remove nodes that have timed out.

sendHellosToCandidateNeighbors

private void sendHellosToCandidateNeighbors()

isCandidateNeighbor

private boolean isCandidateNeighbor(DT_AddressPair dest)

helloAllNeighbors

protected final void helloAllNeighbors()
Sends a Hello message to all of the node's neighbors.

messageArrivedFromAdapter

public void messageArrivedFromAdapter(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

handleGoodbye

private void handleGoodbye(DT_Message m)
Removes the sender of the message from the neighborhood.

handleHello

private void handleHello(DT_Message m)
Preforms actions associated with the arrival of a Hello or HelloNotNeighbor message.

handleNewNode

protected void handleNewNode(DT_Message m)
Used by NewNode method of joins.

handleNodePing

protected void handleNodePing(DT_Message m)

changeSlowHeartbeatToFastHeartbeat

protected final void changeSlowHeartbeatToFastHeartbeat()

goodbyeAllNeighbors

protected final void goodbyeAllNeighbors()
Sends a Goodbye message to all of the node's neighbors.

sendHelloNeighborMessage

protected final void sendHelloNeighborMessage(DT_AddressPair dst)
Sends a Hello message to a node.

sendHelloNotNeighborMessage

protected final void sendHelloNotNeighborMessage(DT_AddressPair dst)
Send a HelloNotNeighbor message to a node

sendGoodbyeMessage

protected final void sendGoodbyeMessage(DT_AddressPair dst)
Sends a Goodbye message to a node.

sendNewNodeMessage

protected void sendNewNodeMessage(DT_AddressPair dst,
                                  DT_AddressPair target)

sendTestMessage

protected void sendTestMessage(DT_AddressPair dst,
                               DT_AddressPair target)

deleteNeighbor

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

getStats

public java.lang.String getStats(java.lang.String name)
                          throws StatsException
Part of I_Stats interface.
See Also:
I_Stats.getStats(java.lang.String)

setStats

public void setStats(java.lang.String name,
                     java.lang.String value)
              throws StatsException
Part of I_Stats interface.
See Also:
I_Stats.setStats(java.lang.String, java.lang.String)

getSchema

public java.lang.String[] getSchema()
                             throws StatsException
Part of I_Stats interface.
See Also:
I_Stats.getSchema()