public class PeersSet
extends java.lang.Object
A "PeersSet" is a set of "PeersNode" objects. A "PeersNode" is a set of end points (peers, "Destination" objects). A "PeersNode" is a set of peers within the same IP address. Each "PeersNode" object has a leader node, corresponding the lowest destination according the ordering criteria. The "PeersSet" general leader is the lowest among the PeersNode leaders.
The leader nodes play special roles in "SyncClock" and "ProxyManager" services.
Modifier and Type | Field and Description |
---|---|
private IPPort |
localNode |
private java.util.HashMap<java.lang.Long,PeersNode> |
nodes |
Modifier and Type | Method and Description |
---|---|
boolean |
addDestination(Destination dest)
Adds a destination into the data structure.
|
Destination |
getDestinationByIPPort(IPPort ipp)
Gets a "Destination" reference from the IPPort identity.
|
Destination |
getGeneralLeader()
Gets the leader among leaders.
|
Destination[] |
getIPDestinations(long ip)
Gets an array containing the "Destinations" running in a specific IP address.
|
Destination[] |
getLocalDestinations()
Gets an array containing the "Destinations" running in the local IP address.
|
IPPort |
getLocalNode() |
Destination |
getNodeLeader(long nodeIP)
Gets the "Destination" node leader in node specified by IP (as long).
|
long[] |
getPeersSetIPs()
Gets an array of the IP's in the party.
|
int[] |
getRemoteNoLeaderDestPorts(long ipAsLong)
Gets an array of remote destinations (in the specified IP) not including the leader one.
|
boolean |
isDestinationContained(IPPort ipp)
Checks if an end point is in the data structure.
|
boolean |
removeDestination(Destination dest)
Remove a destination from the data structure.
|
private IPPort localNode
private java.util.HashMap<java.lang.Long,PeersNode> nodes
PeersSet(IPPort ipp)
ipp
- the local node identity as IPPort.public boolean addDestination(Destination dest)
dest
- the "Destination" to store.public Destination getDestinationByIPPort(IPPort ipp)
ipp
- public Destination getGeneralLeader()
public Destination[] getIPDestinations(long ip)
public Destination[] getLocalDestinations()
public IPPort getLocalNode()
public Destination getNodeLeader(long nodeIP)
nodeIP
- the IP address (long representation) of the node.public long[] getPeersSetIPs()
public int[] getRemoteNoLeaderDestPorts(long ipAsLong)
ipAsLong
- public boolean isDestinationContained(IPPort ipp)
ipp
- public boolean removeDestination(Destination dest)
dest
- the "Destination" to remove.