| 
||||||||||
| 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.  | 
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()
 | 
 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 map| Method Detail | 
|---|
public void addPeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
addPeerMapChangeListener in interface PeerMappublic void removePeerMapChangeListener(PeerMapChangeListener peerMapChangeListener)
removePeerMapChangeListener in interface PeerMappublic void addPeerOfflineListener(PeerStatusListener peerListener)
addPeerOfflineListener in interface PeerMappublic void removePeerOfflineListener(PeerStatusListener peerListener)
removePeerOfflineListener in interface PeerMappublic Statistics getStatistics()
getStatistics in interface PeerMappublic int size()
size in interface PeerMappublic Number160 self()
PeerMap
self in interface PeerMap
public boolean peerFound(PeerAddress remotePeer,
                         PeerAddress referrer)
PeerMap
peerFound in interface PeerMapremotePeer - The node that should be added
public boolean peerOffline(PeerAddress remotePeer,
                           boolean force)
PeerMap
peerOffline in interface PeerMapremotePeer - The node that should be removed
public Collection<PeerAddress> peersForMaintenance()
peersForMaintenance in interface PeerMappublic boolean isPeerRemovedTemporarly(PeerAddress remotePeer)
PeerMap
isPeerRemovedTemporarly in interface PeerMapremotePeer - 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 PeerMapid - 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 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 key
public int isCloser(Number160 id,
                    Number160 rn,
                    Number160 rn2)
PeerMap
isCloser in interface PeerMapid - The key to search forrn - The first keyrn2 - The second key
public 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 id
public String toString()
toString in class Objectpublic static Comparator<PeerAddress> createComparator(Number160 id)
public Comparator<PeerAddress> createPeerComparator(Number160 id)
PeerMap
createPeerComparator in interface PeerMapid - The id that defines the metric
public Comparator<PeerAddress> createPeerComparator()
createPeerComparator in interface PeerMappublic Collection<PeerAddress> getAll()
PeerMap
getAll in interface PeerMappublic void addAddressFilter(InetAddress address)
addAddressFilter in interface PeerMap
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||