|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.router.networkdb.kademlia.PeerSelector
public class PeerSelector
Field Summary | |
---|---|
protected RouterContext |
_context
|
protected Log |
_log
|
Constructor Summary | |
---|---|
PeerSelector(RouterContext ctx)
|
Method Summary | |
---|---|
static java.math.BigInteger |
getDistance(Hash targetKey,
Hash routerInQuestion)
private void removeFailingPeers(Set peerHashes) { List failing = null; for (Iterator iter = peerHashes.iterator(); iter.hasNext(); ) { Hash cur = (Hash)iter.next(); if (_context.profileOrganizer().isFailing(cur)) { if (_log.shouldLog(Log.DEBUG)) _log.debug("Peer " + cur.toBase64() + " is failing, don't include them in the peer selection"); if (failing == null) failing = new ArrayList(4); failing.add(cur); } else if (_context.profileOrganizer().peerSendsBadReplies(cur)) { if (true) { _log.warn("Peer " + cur.toBase64() + " sends us bad replies (but we still query them)"); } else { if (failing == null) failing = new ArrayList(4); failing.add(cur); if (_log.shouldLog(Log.WARN)) { PeerProfile profile = _context.profileOrganizer().getProfile(cur); if (profile != null) { RateStat invalidReplyRateStat = profile.getDBHistory().getInvalidReplyRate(); Rate invalidReplyRate = invalidReplyRateStat.getRate(60*60*1000l); _log.warn("Peer " + cur.toBase64() + " sends us bad replies: current hour: " + invalidReplyRate.getCurrentEventCount() + " and last hour: " + invalidReplyRate.getLastEventCount() + ":\n" + invalidReplyRate.toString()); } } } } } if (failing != null) peerHashes.removeAll(failing); } |
java.util.List<Hash> |
selectMostReliablePeers(Hash key,
int numClosest,
java.util.Set<Hash> alreadyChecked,
KBucketSet kbuckets)
Search through the kbucket set to find the most reliable peers close to the given key, skipping all of the ones already checked |
java.util.List<Hash> |
selectNearest(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Generic KBucket filtering to find the hashes close to a key, regardless of other considerations. |
java.util.List<Hash> |
selectNearestExplicit(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Ignore KBucket ordering and do the XOR explicitly per key. |
java.util.List<Hash> |
selectNearestExplicitThin(Hash key,
int maxNumRouters,
java.util.Set<Hash> peersToIgnore,
KBucketSet kbuckets)
Ignore KBucket ordering and do the XOR explicitly per key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Log _log
protected RouterContext _context
Constructor Detail |
---|
public PeerSelector(RouterContext ctx)
Method Detail |
---|
public java.util.List<Hash> selectMostReliablePeers(Hash key, int numClosest, java.util.Set<Hash> alreadyChecked, KBucketSet kbuckets)
public java.util.List<Hash> selectNearestExplicit(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
public java.util.List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
public static java.math.BigInteger getDistance(Hash targetKey, Hash routerInQuestion)
public java.util.List<Hash> selectNearest(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |