| Constructor and Description |
|---|
PeerMapKadImpl(Number160 self,
int bagSize,
int cacheSize,
int cacheTimeout,
int maxFail,
int[] maintenanceTimeoutsSeconds)
Creates a bag of peers
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAddressFilter(InetAddress address) |
void |
addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener) |
void |
addPeerOfflineListener(PeerOfflineListener peerListener) |
SortedSet<PeerAddress> |
closePeers(Number160 id,
int atLeast)
Returns close peer from the set to a given key.
|
boolean |
contains(PeerAddress peerAddress) |
Comparator<PeerAddress> |
createPeerComparator() |
Comparator<PeerAddress> |
createPeerComparator(Number160 id)
Creates a comparator that orders to peers according to their distance to
the specified id.
|
Collection<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.
|
boolean |
isPeerRemovedTemporarly(PeerAddress remoteNode)
Checks if this peer has been removed.
|
boolean |
peerOffline(PeerAddress remotePeer,
boolean force)
Remove a peer from the list.
|
boolean |
peerOnline(PeerAddress remotePeer,
PeerAddress referrer)
Adds a neighbor to the neighbor list.
|
Collection<PeerAddress> |
peersForMaintenance() |
void |
removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener) |
void |
removePeerOfflineListener(PeerOfflineListener 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() |
public PeerMapKadImpl(Number160 self, int bagSize, int cacheSize, int cacheTimeout, int maxFail, int[] maintenanceTimeoutsSeconds)
self - The id of this peerbagSize - The size of a bag. The original Kademlia suggests 20, but
we can go much lower, as we dont have a fixed limit for a bag. The
bagSize is a suggestion and if maxpeers has not been reached, the
peer is added even though it exceeds the bag limit.cacheSize - The size of the cache of removed peerscacheTimeout - The time that a removed peer will be in the cache in
milliseconds.peerMapChangeListener - Listeners that will be called if a peer is
added or removed.public void addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
addPeerMapChangeListener in interface PeerMappublic void removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
removePeerMapChangeListener in interface PeerMappublic void addPeerOfflineListener(PeerOfflineListener peerListener)
addPeerOfflineListener in interface PeerMappublic void removePeerOfflineListener(PeerOfflineListener peerListener)
removePeerOfflineListener in interface PeerMappublic Statistics getStatistics()
getStatistics in interface PeerMappublic int size()
public Number160 self()
PeerMappublic boolean peerOnline(PeerAddress remotePeer, PeerAddress referrer)
PeerMappeerOnline in interface PeerMapremotePeer - The node that should be addedpublic boolean peerOffline(PeerAddress remotePeer, boolean force)
PeerMappeerOffline in interface PeerMapremotePeer - The node that should be removedpublic Collection<PeerAddress> peersForMaintenance()
peersForMaintenance in interface PeerMappublic boolean isPeerRemovedTemporarly(PeerAddress remoteNode)
PeerMapisPeerRemovedTemporarly in interface PeerMapremoteNode - The node to checkpublic boolean contains(PeerAddress peerAddress)
public SortedSet<PeerAddress> closePeers(Number160 id, int atLeast)
PeerMapclosePeers in interface PeerMapid - 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)
PeerMapisCloser in interface PeerMapid - The key to search forrn - The remote node on the routing path to node close to
keyrn2 - An other remote node on the routing path to node
close to keypublic int isCloser(Number160 id, Number160 rn, Number160 rn2)
PeerMappublic Comparator<PeerAddress> createPeerComparator(Number160 id)
PeerMapcreatePeerComparator in interface PeerMapid - The id that defines the metricpublic Comparator<PeerAddress> createPeerComparator()
createPeerComparator in interface PeerMappublic Collection<PeerAddress> getAll()
PeerMappublic void addAddressFilter(InetAddress address)
addAddressFilter in interface PeerMapCopyright © 2011. All Rights Reserved.