|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--edu.virginia.cs.mng.hypercast.DT.DT_Neighborhood
This class keeps track of the Neighborhood table and LogicalAddress of a node in the Delaunay triangulation. It also provides a large variety of helper functions.
The neighbors are kept unsorted in a Vector. The neighbors can be accessed either through their index in the Vector, or by the neighbor's Physical Address. For each neighbor, DT_Neighborhood stores an AddressPair and the time the most recent message was received from that neighbor.
DT_Neighborhood maintains a property on the neighbors. This property is: In a Delaunay triangulation of the node's Logical Address and its neighbors' Logical Addresses, there would be an edge connecting the node's LA to each of its neighbor's LAs. When a node is inserted causes this property to be violate, neighbors are removed to restore the property. For any problems, contact Jorg Liebeherr at jorg@cs.virginia.edu
| Field Summary | |
private I_UnicastAdapter |
adapter
Network adapter (used for times and Physical Address). |
private java.lang.String |
addNeighborDebug
|
private OverlaySocketConfig |
config
Source of constants & error/log message display |
private static double |
MIN_ANGLE
Corrective value for double arithmetic when calculating CW and CCW neighbors. |
private DT_AddressPair |
myAddressPair
The physical and logical address of this node. |
private java.util.Vector |
neighbors
NeighborhooEntries of the node's neighbors. |
| Constructor Summary | |
DT_Neighborhood(OverlaySocketConfig c,
I_UnicastAdapter ua,
DT_LogicalAddress startingCoords)
Constructor. |
|
| Method Summary | |
void |
addNeighbor(DT_AddressPair addr,
DT_AddressPair cw,
DT_AddressPair ccw,
boolean hasThisNodeAsNeighbor)
Inserts a neighbor and then removes neighbors to make neighborhood consistent |
private boolean |
amIParent(DT_NeighborhoodEntry nodeEntry,
DT_LogicalAddress root)
Returns true if this node is the parent of the neighbor node
in a spanning tree rooted at root |
boolean |
contains(I_PhysicalAddress addr)
Returns true if one of the neighbors has a phyiscal address equal to the parameter. |
DT_AddressPair[] |
getAllNeighbors()
Returns the AddressPairs of all the neighbors |
DT_AddressPair |
getCCWNeighbor(DT_LogicalAddress la)
Finds the neighbor with the CCW smallest angle to the parameter with respect to this node. |
DT_AddressPair[] |
getChildren(DT_LogicalAddress root)
Return the AddressPairs of neighbor that are children of this node in a spanning tree rooted at rootCoords. |
DT_AddressPair |
getCWNeighbor(DT_LogicalAddress la)
Finds the neighbor with the CCW smallest angle to the parameter with respect to this node. |
private DT_NeighborhoodEntry |
getEntry(int i)
|
long |
getLastContactTimeOfNeighborAtIndex(int i)
Returns the Nth neighbor's LastContactTime (the last time a message was received from that neighbor). |
DT_LogicalAddress |
getLogicalAddress()
Returns logical address of this node. |
DT_AddressPair |
getMyAddressPair()
|
DT_AddressPair |
getNeighborAtIndex(int i)
Returns the Nth neighbor's AddressPair. |
DT_AddressPair |
getNeighborAtSameAngle(DT_LogicalAddress la)
Returns neighbors that lies as the same angle as the parameter with respect to this node. |
DT_AddressPair |
getNeighborWithThisPA(I_PhysicalAddress addr)
Returns the AddressPair of the neighbor whose physical address equals the parameter. |
DT_AddressPair |
getNextHopToLeader()
Returns the neighbor with the greatest coordinates. |
DT_AddressPair |
getNodeCCWOfNeighborAtIndex(int i)
Returns the Nth neighbor's CCW neighbor's AddressPair. |
DT_AddressPair |
getNodeCWOfNeighborAtIndex(int i)
Returns the Nth neighbor's CW neighbor's AddressPair. |
int |
getNumOfNeighbors()
Returns the number of neighbors. |
DT_AddressPair |
getParent(DT_LogicalAddress rootCoords)
Returns AddressPair of neighbor that is parent of this node in a spanning tree rooted at rootCoords. |
I_PhysicalAddress |
getPhysicalAddress()
Returns physical address of this node. |
java.lang.String[] |
getSchema()
Part of I_Stats interface. |
java.lang.String |
getStats(java.lang.String name)
Part of I_Stats interface. |
boolean |
hasFourOnCircle()
Returns true if any 4 neighbors lie on a circle |
int |
indexOfNeighbor(I_PhysicalAddress addr)
Finds the index of the neighbor whose physical address equals the parameter. |
int |
isConsistent()
Test Function. |
boolean |
isEmpty()
Returns true if there are no neighbors. |
boolean |
isLeader()
Returns true if no neighbor's Logical Address is greaterThan this node's LogicalAddress. |
boolean |
isStable()
Returns true every neighbor's CW and CCW entry are in the neighborhood. |
boolean |
isThisClosest(DT_Point p)
Returns true if this node is at least as close to the point p as any of its neighbors. |
boolean |
neighborAtIndexHasThisNodeAsNeighbor(int i)
Returns if Nth neighbor has this node as a neighbor. |
boolean |
neighborHasThisLA(DT_LogicalAddress la)
Returns true if there exists a neighbor with a LogicalAddress equal to the parameter. |
private void |
randomShiftMyCoordinates()
Changes this node's LogicalAddress by a small amount. |
void |
removeAllNeighbors()
Remove all neighbors from the Neighborhood. |
void |
removeNeighbor(DT_AddressPair addrs)
Removes neighbor identified by the PhysicalAddress of its AddressPair. |
void |
removeNeighbor(I_PhysicalAddress addr)
Removes neighbor identified by its PhysicalAddress. |
void |
removeNeighbor(int i)
Removes neighbor identified by its index |
private void |
removeNonNeighbors()
Returns the neighborhood to consistency. |
void |
setStats(java.lang.String name,
java.lang.String value)
Part of I_Stats interface. |
boolean |
shouldBeNeighbor(DT_LogicalAddress la)
Returns true if the node with LogicalAddress la can be added as a neighbor. |
java.lang.String |
toString()
Creates a string containing the state of the neighborhood. |
(package private) boolean |
updateContactTable(I_PhysicalAddress addr,
DT_AddressPair cw,
DT_AddressPair ccw,
boolean hasThisNodeAsNeighbor)
Sets the contact time for the neighbor identified by its PhysicalAddress. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private OverlaySocketConfig config
private I_UnicastAdapter adapter
private DT_AddressPair myAddressPair
private java.util.Vector neighbors
DT_NeighborhoodEntryprivate java.lang.String addNeighborDebug
private static double MIN_ANGLE
| Constructor Detail |
public DT_Neighborhood(OverlaySocketConfig c,
I_UnicastAdapter ua,
DT_LogicalAddress startingCoords)
startingCoords - The starting address of this node.| Method Detail |
private DT_NeighborhoodEntry getEntry(int i)
public DT_AddressPair getMyAddressPair()
public DT_LogicalAddress getLogicalAddress()
public I_PhysicalAddress getPhysicalAddress()
public final int getNumOfNeighbors()
public boolean isEmpty()
public boolean isLeader()
public boolean isStable()
public DT_AddressPair getNeighborAtIndex(int i)
public DT_AddressPair getNodeCWOfNeighborAtIndex(int i)
public DT_AddressPair getNodeCCWOfNeighborAtIndex(int i)
public boolean neighborAtIndexHasThisNodeAsNeighbor(int i)
public long getLastContactTimeOfNeighborAtIndex(int i)
public boolean contains(I_PhysicalAddress addr)
public int indexOfNeighbor(I_PhysicalAddress addr)
public DT_AddressPair getNeighborWithThisPA(I_PhysicalAddress addr)
public boolean neighborHasThisLA(DT_LogicalAddress la)
public DT_AddressPair getParent(DT_LogicalAddress rootCoords)
rootCoords.
This is calculated by finding the neighbor that forms the smallest angle with rootCoords.public DT_AddressPair[] getChildren(DT_LogicalAddress root)
rootCoords.
This based on if DT_Neighborhood.getParent() of the neighbor would return this node.
private boolean amIParent(DT_NeighborhoodEntry nodeEntry,
DT_LogicalAddress root)
node
in a spanning tree rooted at rootgetParentpublic DT_AddressPair[] getAllNeighbors()
public DT_AddressPair getNextHopToLeader()
public boolean isThisClosest(DT_Point p)
p as any of its neighbors.public boolean hasFourOnCircle()
public boolean shouldBeNeighbor(DT_LogicalAddress la)
la can be added as a neighbor.public DT_AddressPair getNeighborAtSameAngle(DT_LogicalAddress la)
public DT_AddressPair getCCWNeighbor(DT_LogicalAddress la)
MIN_ANGLEMIN_ANGLEpublic DT_AddressPair getCWNeighbor(DT_LogicalAddress la)
MIN_ANGLEMIN_ANGLEpublic int isConsistent()
public void addNeighbor(DT_AddressPair addr,
DT_AddressPair cw,
DT_AddressPair ccw,
boolean hasThisNodeAsNeighbor)
public void removeNeighbor(I_PhysicalAddress addr)
public void removeNeighbor(int i)
public void removeNeighbor(DT_AddressPair addrs)
public void removeAllNeighbors()
boolean updateContactTable(I_PhysicalAddress addr,
DT_AddressPair cw,
DT_AddressPair ccw,
boolean hasThisNodeAsNeighbor)
private void randomShiftMyCoordinates()
private void removeNonNeighbors()
public java.lang.String getStats(java.lang.String name)
throws StatsException
I_Stats.getStats(java.lang.String)
public void setStats(java.lang.String name,
java.lang.String value)
throws StatsException
I_Stats.setStats(java.lang.String, java.lang.String)
public java.lang.String[] getSchema()
throws StatsException
I_Stats.getSchema()public java.lang.String toString()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||