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

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

public final class HC_AddressPair
extends java.lang.Object
implements I_AddressPair

This class encapsulates the functions of the Logical-Physical Address pair. It provides both physical and logical address for a hypercube overlay node. We also include the concept of age of the variable so that we can use this same class in the Neigborhood View


Field Summary
private  int Age
          The age of the protocol node (in HeartBeats).
private  HC_LogicalAddress LA
          The logical address of the protocol node
private  I_PhysicalAddress PA
          The physical address of the protocol node
private  HC_Node parent
          The HC_Node that created this object.
 
Constructor Summary
(package private) HC_AddressPair(HC_Node hcnode, HC_AddressPair addrpair, boolean ishroot)
          Constructs a HC_AddressPair from a HC_AddressPair and a boolean flag.
(package private) HC_AddressPair(HC_Node hcnode, HC_LogicalAddress laddr, I_PhysicalAddress paddr, boolean ishroot)
          Constructs HC_AddressPair from a HC_LogicalAddress, I_PhysicalAddress.
 
Method Summary
 boolean age()
          Ages a AddressPair entry and returns true if the AddressPair is still "alive".
 int getAge()
          Gets the age of the node
 I_LogicalAddress getLogicalAddress()
          Gets a copy of the internal HC_LogicalAddress object, or null if the object is null.
 I_PhysicalAddress getPhysicalAddress()
          Gets a copy of the internal I_PhysicalAddress object, or null if the object is null.
 void resetAge()
          Resets Age to MaxAge + MaxMissingNeighbor.
 void setAge(int age)
          Sets Age to the new age.
 java.lang.String toString()
          Gets the string format of the HC_AddressPair object return string format: nnn.nnn.nnn.nnn/nnnn:LA repeate
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

PA

private I_PhysicalAddress PA
The physical address of the protocol node

LA

private HC_LogicalAddress LA
The logical address of the protocol node

Age

private int Age
The age of the protocol node (in HeartBeats). Unlike humans, HC_AddressPairs start with a high value for Age and then it decreases over time. If the Age ever reaches zero, the HC_AddressPair has become "stale". HC_AddressPairs can be rejuvenated by a call to setAge or resetAge.

parent

private HC_Node parent
The HC_Node that created this object. It is required for the values MaxAge and MaxMissingNeighbor.
Constructor Detail

HC_AddressPair

HC_AddressPair(HC_Node hcnode,
               HC_LogicalAddress laddr,
               I_PhysicalAddress paddr,
               boolean ishroot)
Constructs HC_AddressPair from a HC_LogicalAddress, I_PhysicalAddress. Just copies the arguments into internal objects and sets the Age variable to MaxAge + MaxMissingNeighbor. Either LogicalAddress or PhysicalAddress can be null.
If the HC_AddressPair is an HRoot, then MissingNeighbor does not apply.
Parameters:
laddr - a HC_LogicalAddress object
paddr - an I_PhysicalAddress object
ishroot - a flag indicating if the HC_AddressPair represents an HRoot

HC_AddressPair

HC_AddressPair(HC_Node hcnode,
               HC_AddressPair addrpair,
               boolean ishroot)
Constructs a HC_AddressPair from a HC_AddressPair and a boolean flag. Just copies the arguments into internal objects and sets the Age variable to MaxAge + MaxMissingNeighbor
If the HC_AddressPair is an HRoot, then MissingNeighbor does not apply.
Parameters:
addrpair - HC_AddressPair object
ishroot - a flag indicating if the HC_AddressPair represents an HRoot
Method Detail

age

public boolean age()
Ages a AddressPair entry and returns true if the AddressPair is still "alive". Decreases age by 1 if age is greater than 0, and then returns true if age is still greater than 0.
Returns:
true if the data is not stale, and false, otherwise

resetAge

public void resetAge()
Resets Age to MaxAge + MaxMissingNeighbor.

setAge

public void setAge(int age)
Sets Age to the new age.
Parameters:
age - the new age

getAge

public int getAge()
Gets the age of the node
Returns:
age of the node

getLogicalAddress

public I_LogicalAddress getLogicalAddress()
Gets a copy of the internal HC_LogicalAddress object, or null if the object is null.
Specified by:
getLogicalAddress in interface I_AddressPair
Returns:
copy of HC_LogicalAddress stored

getPhysicalAddress

public I_PhysicalAddress getPhysicalAddress()
Gets a copy of the internal I_PhysicalAddress object, or null if the object is null.
Specified by:
getPhysicalAddress in interface I_AddressPair
Returns:
copy of PhysicalAddress stored

toString

public java.lang.String toString()
Gets the string format of the HC_AddressPair object return string format: nnn.nnn.nnn.nnn/nnnn:LA repeate
Returns:
String representation of the object
Overrides:
toString in class java.lang.Object