|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--edu.virginia.cs.mng.hypercast.HC.HC_Neighborhood
This class encapsulates the HC_Neighborhood and do all functions regarding that
Specifically, it should do the following jobs:
ageNeighborhood : Should be able to age data and remove stale data
empty : Should be able to check if the HC_Neighborhood is empty
register: It should be able to take a PhysicalAddress-LogicalAddress <
pair and return true if it was able to install it/reset its
age and false otherwise
remove : Remove a neighbor if the physical address matches the one in
the HC_Neighborhood entry
searchTear:
Should return the HC_LogicalAddress of the lowest tear, and
HC_Global.MaxAddress if none exists. The tear reported is
Ttimeout + Tmissing time units old
searchLittleTear:
Should return the HC_LogicalAddress of the lowest tear, and
HC_Global.MaxAddress if none exists. This differs from searchTear in
that tears which are only Ttimeout old are reported
getNthNeighbor:
Gets the HC_AddressPair of the Nth neighbor
resetNeighborhood:
Removes all entries from the neighborhood table
| Field Summary | |
(package private) HC_AddressPair |
HRoot
AddressPair of the HRoot |
(package private) int |
HRootSeqNum
HRoot sequence number |
(package private) int |
MNTimeOut
MissingNeighbor Time |
(package private) HC_AddressPair[] |
NView
AddressPair array of all neighbors |
private HC_Node |
parent
Hypercast node object |
| Constructor Summary | |
HC_Neighborhood(HC_Node hcnode)
Constructs HC_Neighborhood objects with an initialization object and a HC_Node object Initialize each of the entries in the HC_Neighborhood table to be "unknown", that is, Physical Address is null in each of those HC_AddressPair objects |
|
| Method Summary | |
int |
ageNeighborhood()
Checks the age of all the Neighborhood. |
boolean |
empty()
Checks if the neighborhood is empty. |
HC_AddressPair |
getHRoot()
Gets HRoot's AddressPair |
int |
getHRootSeqNum()
Gets HRoot's sequence number |
HC_AddressPair |
getNeighborPair(HC_LogicalAddress laddr)
Gets the AddressPair of a neighbor with a logical address |
HC_AddressPair[] |
getNeighbors()
Gets all neighbor's AddressPair |
HC_AddressPair |
getNthNeighbor(int n)
Gets the AddressPair of the Nth neighbor |
int |
getNumOfNeighbors()
Returns the number of neighbors in neighbor table |
boolean |
register(HC_AddressPair addrpair)
Registers the HC_AddressPair to the node's neighborhood table Algorithm: 1. |
boolean |
remove(HC_AddressPair addrpair)
Removes a HC_AddressPair from the neighborhood table Algorithm: Find the Index and check if physical address is the same (a) If yes, remove and make that point unknown (b) If no, make it false |
void |
resetNeighborhood()
Resets the neighborhood table |
int |
searchLittleTear()
Searches Little Tear in all the neighborhood Algorithm: The tear found is one where the neighborhood table entry has been missing for Ttimeout time. |
int |
searchTear()
Searches a Tear in all neighborhood Algorithm: The tear found is one where the neighborhood table entry has been missing Check each neighbor in turn, in increasing logical address order. |
void |
setHRootSeqNum(int newseqnum)
Set HRoot sequence number to a new value |
java.lang.String |
toString()
Converts the HC_Neighborhood object to String format |
boolean |
updateHRoot(HC_LogicalAddress laddr,
int curseqnum)
Updates HRoot with HRoot HC_LogicalAddress and sequence number |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
HC_AddressPair[] NView
HC_AddressPair HRoot
int HRootSeqNum
int MNTimeOut
private HC_Node parent
| Constructor Detail |
public HC_Neighborhood(HC_Node hcnode)
Initialize each of the entries in the HC_Neighborhood table to be "unknown", that is, Physical Address is null in each of those HC_AddressPair objects
a - HC_Node object with respect to which the neighborhood will be constructed.| Method Detail |
public int ageNeighborhood()
public boolean empty()
public int getNumOfNeighbors()
public boolean register(HC_AddressPair addrpair)
Algorithm:
1. Calculate the index of the HC_LogicalAddress in the Neighborhood View
(a) If it is not a neighbor return false
2. Check if the index is occupied;
(a) If it is, check if the PhysicalAddress is the same
(i) If it is, reset the age, and return true
(ii) If it is not, return false
(b) If it is not, install the Pair, and return true
addrpair - a LogicalAddress/PhysicalAddress pair
public boolean updateHRoot(HC_LogicalAddress laddr,
int curseqnum)
laddr - a HC_LogicalAddress objectcurseqnum - current sequence numberpublic boolean remove(HC_AddressPair addrpair)
Algorithm:
Find the Index and check if physical address is the same
(a) If yes, remove and make that point unknown
(b) If no, make it false
addrpair - a Node Addresspublic int searchTear()
Algorithm:
The tear found is one where the neighborhood table entry has been missing
Check each neighbor in turn, in increasing logical address order.
Stop when the neighbor's LA exceeds that of the known HRoot.
If a neighbor is found to be absent, report it as a tear.
public int searchLittleTear()
Algorithm:
The tear found is one where the neighborhood table entry has been missing
for Ttimeout time.
Check each neighbor in turn, in increasing logical address order.
Stop when the neighbor's LA exceeds that of the known HRoot.
If a neighbor is found to be absent, report it as a tear.
public HC_AddressPair getNthNeighbor(int n)
integer - representing the Index of neighborpublic HC_AddressPair getNeighborPair(HC_LogicalAddress laddr)
a - Neighbor's HC_LogicalAddresspublic HC_AddressPair[] getNeighbors()
public HC_AddressPair getHRoot()
public int getHRootSeqNum()
public void setHRootSeqNum(int newseqnum)
an - integer representing the new sequence numberpublic void resetNeighborhood()
public java.lang.String toString()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||