|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.tomp2p.peers.PeerMap
public class PeerMap
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 | |
---|---|
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. |
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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
@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 mapMethod Detail |
---|
public 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)
node
- The node that should be addedfirstHand
- 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 such
public boolean peerOffline(PeerAddress remotePeer, boolean force)
node
- The node that should be removed
public Collection<PeerAddress> peersForMaintenance()
public boolean isPeerRemovedTemporarly(PeerAddress remotePeer)
node
- The node to check
public 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)
key
- The key that should be close to the keys in the mapnumber
- The number we want to find at least
public 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 key
public int isCloser(Number160 id, Number160 rn, Number160 rn2)
key
- The key to search forkey1
- The first keykey2
- 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 Object
public static Comparator<PeerAddress> createComparator(Number160 id)
public Comparator<PeerAddress> createPeerComparator(Number160 id)
id
- The id that defines the metric
public Comparator<PeerAddress> createPeerComparator()
public List<PeerAddress> getAll()
public void addAddressFilter(InetAddress address)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |