public class PeerMap extends Object
Constructor and Description |
---|
PeerMap(Number160 self,
int bagSize,
int cacheTimeoutMillis,
int maxNrBeforeExclude,
int[] waitingTimeBetweenNodeMaintenenceSeconds,
int cachSize,
boolean acceptFirstClassOnly)
Deprecated.
|
PeerMap(Number160 self,
int bagSize,
int cacheTimeoutMillis,
int maxNrBeforeExclude,
int[] waitingTimeBetweenNodeMaintenenceSeconds,
int cachSize,
MapAcceptHandler mapHandler)
Creates the bag for the peers.
|
Modifier and Type | Method and Description |
---|---|
void |
addAddressFilter(InetAddress address) |
void |
addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener) |
void |
addPeerOfflineListener(PeerStatusListener peerListener) |
SortedSet<PeerAddress> |
closePeers(Number160 id,
int atLeast)
Returns close peer from the set to a given key.
|
boolean |
contains(PeerAddress peerAddress) |
static Comparator<PeerAddress> |
createComparator(Number160 id) |
Comparator<PeerAddress> |
createPeerComparator() |
Comparator<PeerAddress> |
createPeerComparator(Number160 id)
Creates a comparator that orders to peers according to their distance to the specified id.
|
List<PeerAddress> |
getAll()
Return all addresses from the neighbor list.
|
Statistics |
getStatistics() |
int |
isCloser(Number160 id,
Number160 rn,
Number160 rn2)
Returns -1 if the first key is closer to the key, if the second is closer, then 1 is returned.
|
int |
isCloser(Number160 id,
PeerAddress rn,
PeerAddress rn2)
Returns -1 if the first remote node is closer to the key, if the second is closer, then 1 is returned.
|
static int |
isKadCloser(Number160 id,
PeerAddress rn,
PeerAddress rn2)
Returns -1 if the first remote node is closer to the key, if the secondBITS is closer, then 1 is returned.
|
boolean |
isPeerRemovedTemporarly(PeerAddress remotePeer)
Checks if this peer has been removed.
|
boolean |
peerFound(PeerAddress remotePeer,
PeerAddress referrer)
Adds a neighbor to the neighbor list.
|
boolean |
peerOffline(PeerAddress remotePeer,
boolean force)
Remove a peer from the list.
|
Collection<PeerAddress> |
peersForMaintenance() |
void |
removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener) |
void |
removePeerOfflineListener(PeerStatusListener peerListener) |
Number160 |
self()
Each node that has a bag has an ID itself to define what is close.
|
int |
size()
The peerCount keeps track of the total number of peer in the system.
|
String |
toString() |
boolean |
updateExistingPeerAddress(PeerAddress peerAddress)
Checks if a peer already existis in this map and if it does, it will update the entry becaues the peer address
(e.g.
|
@Deprecated public PeerMap(Number160 self, int bagSize, int cacheTimeoutMillis, int maxNrBeforeExclude, int[] waitingTimeBetweenNodeMaintenenceSeconds, int cachSize, boolean acceptFirstClassOnly)
public PeerMap(Number160 self, int bagSize, int cacheTimeoutMillis, int maxNrBeforeExclude, int[] waitingTimeBetweenNodeMaintenenceSeconds, int cachSize, MapAcceptHandler mapHandler)
self
- The peer ID of this peerconfiguration
- Configuration settings for this mappublic void addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
public void removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
public void addPeerOfflineListener(PeerStatusListener peerListener)
public void removePeerOfflineListener(PeerStatusListener peerListener)
public Statistics getStatistics()
public int size()
public Number160 self()
public boolean peerFound(PeerAddress remotePeer, PeerAddress referrer)
remotePeer
- The node that should be addedreferrer
- If we had direct contact and we know for sure that this node is online, we set firsthand to true.
Information from 3rd party peers are always second hand and treated as suchpublic boolean peerOffline(PeerAddress remotePeer, boolean force)
remotePeer
- The node that should be removedforce
- A flag that removes a peer immediately.public Collection<PeerAddress> peersForMaintenance()
public boolean isPeerRemovedTemporarly(PeerAddress remotePeer)
node
- The node to checkpublic boolean updateExistingPeerAddress(PeerAddress peerAddress)
peerAddress
- The address of the peer that may have been changed.public boolean contains(PeerAddress peerAddress)
public SortedSet<PeerAddress> closePeers(Number160 id, int atLeast)
id
- The key that should be close to the keys in the mapatLeast
- The number we want to find at leastpublic int isCloser(Number160 id, PeerAddress rn, PeerAddress rn2)
key
- The key to search fornodeAddress1
- The remote node on the routing path to node close to keynodeAddress2
- An other remote node on the routing path to node close to keypublic int isCloser(Number160 id, Number160 rn, Number160 rn2)
key
- The key to search forkey1
- The first keykey2
- The second keypublic static int isKadCloser(Number160 id, PeerAddress rn, PeerAddress rn2)
id
- The id as a distance referencern
- The peer to test if closer to the idrn2
- The other peer to test if closer to the idpublic static Comparator<PeerAddress> createComparator(Number160 id)
public Comparator<PeerAddress> createPeerComparator(Number160 id)
id
- The id that defines the metricpublic Comparator<PeerAddress> createPeerComparator()
public List<PeerAddress> getAll()
public void addAddressFilter(InetAddress address)
Copyright © 2013. All Rights Reserved.