net.i2p.router.networkdb.kademlia
Class FloodfillPeerSelector

java.lang.Object
  extended by net.i2p.router.networkdb.kademlia.PeerSelector
      extended by net.i2p.router.networkdb.kademlia.FloodfillPeerSelector

 class FloodfillPeerSelector
extends PeerSelector

This is where we implement semi-Kademlia with the floodfills, by selecting floodfills closest to a given key for searches and stores. Warning - most methods taking a key as an argument require the routing key, not the original key.


Field Summary
 
Fields inherited from class net.i2p.router.networkdb.kademlia.PeerSelector
_context, _log
 
Constructor Summary
FloodfillPeerSelector(RouterContext ctx)
           
 
Method Summary
(package private)  java.util.List<Hash> selectFloodfillParticipants(Hash key, int maxNumRouters, KBucketSet kbuckets)
          Sort the floodfills.
(package private)  java.util.List<Hash> selectFloodfillParticipants(Hash key, int howMany, java.util.Set<Hash> toIgnore, KBucketSet kbuckets)
          See above for description List will not include our own hash
(package private)  java.util.List<Hash> selectFloodfillParticipants(KBucketSet kbuckets)
           
(package private)  java.util.List<Hash> selectMostReliablePeers(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
          Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia.
(package private)  java.util.List<Hash> selectNearest(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
          Floodfill peers only.
(package private)  java.util.List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets)
          Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia.
(package private)  java.util.List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, java.util.Set<Hash> peersToIgnore, KBucketSet kbuckets, boolean preferConnected)
          Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia.
 
Methods inherited from class net.i2p.router.networkdb.kademlia.PeerSelector
selectNearestExplicit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloodfillPeerSelector

public FloodfillPeerSelector(RouterContext ctx)
Method Detail

selectMostReliablePeers

java.util.List<Hash> selectMostReliablePeers(Hash key,
                                             int maxNumRouters,
                                             java.util.Set<Hash> peersToIgnore,
                                             KBucketSet kbuckets)
Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia. Puts the floodfill peers that are directly connected first in the list. List will not include our own hash.

Overrides:
selectMostReliablePeers in class PeerSelector
Parameters:
peersToIgnore - can be null
Returns:
List of Hash for the peers selected

selectNearestExplicitThin

java.util.List<Hash> selectNearestExplicitThin(Hash key,
                                               int maxNumRouters,
                                               java.util.Set<Hash> peersToIgnore,
                                               KBucketSet kbuckets)
Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia. Does not prefer the floodfill peers that are directly connected. List will not include our own hash.

Overrides:
selectNearestExplicitThin in class PeerSelector
Parameters:
peersToIgnore - can be null
Returns:
List of Hash for the peers selected

selectNearestExplicitThin

java.util.List<Hash> selectNearestExplicitThin(Hash key,
                                               int maxNumRouters,
                                               java.util.Set<Hash> peersToIgnore,
                                               KBucketSet kbuckets,
                                               boolean preferConnected)
Pick out peers with the floodfill capacity set, returning them first, but then after they're complete, sort via kademlia. List will not include our own hash.

Parameters:
peersToIgnore - can be null
Returns:
List of Hash for the peers selected

selectFloodfillParticipants

java.util.List<Hash> selectFloodfillParticipants(KBucketSet kbuckets)
Returns:
all floodfills not shitlisted forever. List will not include our own hash. List is not sorted and not shuffled.

selectFloodfillParticipants

java.util.List<Hash> selectFloodfillParticipants(Hash key,
                                                 int maxNumRouters,
                                                 KBucketSet kbuckets)
Sort the floodfills. The challenge here is to keep the good ones at the front and the bad ones at the back. If they are all good or bad, searches and stores won't work well. List will not include our own hash.

Parameters:
key - the routing key
maxNumRouters - max to return Sorted by closest to the key if > maxNumRouters, otherwise not The list is in 3 groups - sorted by routing key within each group. Group 1: No store or lookup failure in a long time, and lookup fail rate no more than 1.5 * average Group 2: No store or lookup failure in a little while or success newer than failure Group 3: All others
Returns:
floodfills closest to the key that are not shitlisted forever

selectFloodfillParticipants

java.util.List<Hash> selectFloodfillParticipants(Hash key,
                                                 int howMany,
                                                 java.util.Set<Hash> toIgnore,
                                                 KBucketSet kbuckets)
See above for description List will not include our own hash

Parameters:
toIgnore - can be null

selectNearest

java.util.List<Hash> selectNearest(Hash key,
                                   int maxNumRouters,
                                   java.util.Set<Hash> peersToIgnore,
                                   KBucketSet kbuckets)
Floodfill peers only. Used only by HandleDatabaseLookupMessageJob to populate the DSRM. UNLESS peersToIgnore contains Hash.FAKE_HASH (all zeros), in which case this is an exploratory lookup, and the response should not include floodfills. List MAY INCLUDE our own router - add to peersToIgnore if you don't want

Overrides:
selectNearest in class PeerSelector
Parameters:
key - the original key (NOT the routing key)
peersToIgnore - can be null
Returns:
List of Hash for the peers selected, ordered