|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tomp2p.peers.PeerMapKadImpl
public class PeerMapKadImpl
This routing implementation uses is based on Kademlia. However, many changes have been applied to make it faster and more flexible. This class is partially thread-safe.
Constructor Summary | |
---|---|
PeerMapKadImpl(Number160 self,
int bagSize,
int cacheTimeoutMillis,
int maxNrBeforeExclude,
int[] waitingTimeBetweenNodeMaintenenceSeconds,
int cachSize,
boolean isBehindFirewall)
Creates the bag for the peers. |
Method Summary | |
---|---|
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. |
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 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()
|
void |
updateExistingPeerAddress(PeerAddress peerAddress)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PeerMapKadImpl(Number160 self, int bagSize, int cacheTimeoutMillis, int maxNrBeforeExclude, int[] waitingTimeBetweenNodeMaintenenceSeconds, int cachSize, boolean isBehindFirewall)
self
- The peer ID of this peerconfiguration
- Configuration settings for this mapMethod Detail |
---|
public void addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
addPeerMapChangeListener
in interface PeerMap
public void removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
removePeerMapChangeListener
in interface PeerMap
public void addPeerOfflineListener(PeerStatusListener peerListener)
addPeerOfflineListener
in interface PeerMap
public void removePeerOfflineListener(PeerStatusListener peerListener)
removePeerOfflineListener
in interface PeerMap
public Statistics getStatistics()
getStatistics
in interface PeerMap
public int size()
size
in interface PeerMap
public Number160 self()
PeerMap
self
in interface PeerMap
public boolean peerFound(PeerAddress remotePeer, PeerAddress referrer)
PeerMap
peerFound
in interface PeerMap
remotePeer
- The node that should be added
public boolean peerOffline(PeerAddress remotePeer, boolean force)
PeerMap
peerOffline
in interface PeerMap
remotePeer
- The node that should be removed
public Collection<PeerAddress> peersForMaintenance()
peersForMaintenance
in interface PeerMap
public boolean isPeerRemovedTemporarly(PeerAddress remotePeer)
PeerMap
isPeerRemovedTemporarly
in interface PeerMap
remotePeer
- The node to check
public void updateExistingPeerAddress(PeerAddress peerAddress)
public boolean contains(PeerAddress peerAddress)
contains
in interface PeerMap
public SortedSet<PeerAddress> closePeers(Number160 id, int atLeast)
PeerMap
closePeers
in interface PeerMap
id
- The key that should be close to the keys in the mapatLeast
- The number we want to find at least
public int isCloser(Number160 id, PeerAddress rn, PeerAddress rn2)
PeerMap
isCloser
in interface PeerMap
id
- 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 key
public int isCloser(Number160 id, Number160 rn, Number160 rn2)
PeerMap
isCloser
in interface PeerMap
id
- The key to search forrn
- The first keyrn2
- The second key
public String toString()
toString
in class Object
public static Comparator<PeerAddress> createComparator(Number160 id)
public Comparator<PeerAddress> createPeerComparator(Number160 id)
PeerMap
createPeerComparator
in interface PeerMap
id
- The id that defines the metric
public Comparator<PeerAddress> createPeerComparator()
createPeerComparator
in interface PeerMap
public Collection<PeerAddress> getAll()
PeerMap
getAll
in interface PeerMap
public void addAddressFilter(InetAddress address)
addAddressFilter
in interface PeerMap
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |