Changeset 4f836a2


Ignore:
Timestamp:
Jan 5, 2009 3:21:00 PM (12 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
831f09c
Parents:
8faeaaa
Message:
  • ExploreJob/SearchJob? - fix brokenness:
    • Give each search a minimum of time even at the end
    • Fix ExploreJob? exclude peer list
    • Always add floodfills to exclude peer list
    • Don't queue keys for exploration or run ExploreJob? if floodfill
    • Allow floodfills to return non-floodfills in a DSRM msg so exploration works
Location:
router/java/src/net/i2p/router/networkdb/kademlia
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/networkdb/kademlia/ExploreJob.java

    r8faeaaa r4f836a2  
    2929    private PeerSelector _peerSelector;
    3030   
    31     /** how long each exploration should run for (currently a trivial 10 seconds) */
    32     private static final long MAX_EXPLORE_TIME = 10*1000;
     31    /** how long each exploration should run for
     32     *  The exploration won't "succeed" so we make it long so we query several peers */
     33    private static final long MAX_EXPLORE_TIME = 15*1000;
    3334   
    3435    /** how many of the peers closest to the key being explored do we want to explicitly say "dont send me this"? */
     
    3738    /** how many peers to explore through concurrently */
    3839    private static final int EXPLORE_BREDTH = 1;
     40
     41    /** only send the closest "dont tell me about" refs...
     42     *  Override to make this bigger because we want to include both the
     43     *  floodfills and the previously-queried peers */
     44    static final int MAX_CLOSEST = 20;
    3945   
     46    /** Override to make this shorter, since we don't sort out the
     47     *  unresponsive ff peers like we do in FloodOnlySearchJob */
     48    static final int PER_FLOODFILL_PEER_TIMEOUT = 5*1000;
     49
    4050    /**
    4151     * Create a new search for the routingKey specified
     
    6171     * guys').  but maybe we do.  dunno.  lots of implications.
    6272     *
     73     * FloodfillPeerSelector would add only the floodfill peers,
     74     * and PeerSelector doesn't include the floodfill peers,
     75     * so we add the ff peers ourselves and then use the regular PeerSelector.
     76     *
    6377     * @param replyTunnelId tunnel to receive replies through
    6478     * @param replyGateway gateway for the reply tunnel
    6579     * @param expiration when the search should stop
    6680     */
    67     protected DatabaseLookupMessage buildMessage(TunnelId replyTunnelId, RouterInfo replyGateway, long expiration) {
     81    protected DatabaseLookupMessage buildMessage(TunnelId replyTunnelId, Hash replyGateway, long expiration) {
    6882        DatabaseLookupMessage msg = new DatabaseLookupMessage(getContext(), true);
    6983        msg.setSearchKey(getState().getTarget());
    70         msg.setFrom(replyGateway.getIdentity().getHash());
     84        msg.setFrom(replyGateway);
    7185        msg.setDontIncludePeers(getState().getClosestAttempted(MAX_CLOSEST));
    7286        msg.setMessageExpiration(expiration);
     
    7488       
    7589        int available = MAX_CLOSEST - msg.getDontIncludePeers().size();
     90        if (available > 0) {
     91            List peers = ((FloodfillNetworkDatabaseFacade)_facade).getFloodfillPeers();
     92            int len = peers.size();
     93            if (len > 0)
     94                msg.getDontIncludePeers().addAll(peers.subList(0, Math.min(available, len)));
     95        }
     96       
     97        available = MAX_CLOSEST - msg.getDontIncludePeers().size();
    7698        if (available > 0) {
    7799            List peers = _peerSelector.selectNearestExplicit(getState().getTarget(), available, msg.getDontIncludePeers(), getFacade().getKBuckets());
     
    92114     */
    93115    protected DatabaseLookupMessage buildMessage(long expiration) {
    94         return buildMessage(null, getContext().router().getRouterInfo(), expiration);
     116        return buildMessage(null, getContext().router().getRouterInfo().getIdentity().getHash(), expiration);
    95117    }
    96118   
  • router/java/src/net/i2p/router/networkdb/kademlia/ExploreKeySelectorJob.java

    r8faeaaa r4f836a2  
    3838    public String getName() { return "Explore Key Selector Job"; }
    3939    public void runJob() {
     40        if (((FloodfillNetworkDatabaseFacade)_facade).floodfillEnabled()) {
     41            requeue(30*RERUN_DELAY_MS);
     42            return;
     43        }
    4044        Set toExplore = selectKeysToExplore();
    4145        _log.info("Filling the explorer pool with: " + toExplore);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r8faeaaa r4f836a2  
    175175            searchJob = (FloodSearchJob)_activeFloodQueries.get(key);
    176176            if (searchJob == null) {
    177                 if (SearchJob.onlyQueryFloodfillPeers(_context)) {
     177                //if (SearchJob.onlyQueryFloodfillPeers(_context)) {
    178178                    searchJob = new FloodOnlySearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease);
    179                 } else {
    180                     searchJob = new FloodSearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease);
    181                 }
     179                //} else {
     180                //    searchJob = new FloodSearchJob(_context, this, key, onFindJob, onFailedLookupJob, (int)timeoutMs, isLease);
     181                //}
    182182                _activeFloodQueries.put(key, searchJob);
    183183                isNew = true;
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    r8faeaaa r4f836a2  
    125125        if (isCongested(ctx))
    126126            return true;
     127        // If we are floodfill, we want the FloodfillPeerSelector (in add()) to include
     128        // non-ff peers (if required) in DatabaseSearchReplyMessage responses
     129        // so that Exploration works.
     130        // ExploreJob is disabled if we are floodfill.
     131        // The other two places this was called (one below and one in FNDF)
     132        // have been commented out.
     133        if (FloodfillNetworkDatabaseFacade.floodfillEnabled(ctx))
     134            return false;
    127135        return Boolean.valueOf(ctx.getProperty("netDb.floodfillOnly", DEFAULT_FLOODFILL_ONLY + "")).booleanValue();
    128136    }
     
    137145   
    138146    static final int PER_FLOODFILL_PEER_TIMEOUT = 10*1000;
     147    static final long MIN_TIMEOUT = 2500;
    139148   
    140149    protected int getPerPeerTimeoutMs(Hash peer) {
     
    147156       
    148157        if (now + timeout > _expiration)
    149             return (int)(_expiration - now);
     158            return (int) Math.max(_expiration - now, MIN_TIMEOUT);
    150159        else
    151160            return timeout;
     
    248257        Set attempted = _state.getAttempted();
    249258        while (sent <= 0) {
    250             boolean onlyFloodfill = onlyQueryFloodfillPeers(getContext());
     259            //boolean onlyFloodfill = onlyQueryFloodfillPeers(getContext());
     260            boolean onlyFloodfill = true;
    251261            if (_floodfillPeersExhausted && onlyFloodfill && _state.getPending().size() <= 0) {
    252262                if (_log.shouldLog(Log.WARN))
     
    422432       
    423433        if (_log.shouldLog(Log.DEBUG))
    424             _log.debug(getJobId() + ": Sending leaseSet search to " + router.getIdentity().getHash().toBase64()
     434            _log.debug(getJobId() + ": Sending search to " + router.getIdentity().getHash().toBase64()
    425435                       + " for " + msg.getSearchKey().toBase64() + " w/ replies through ["
    426436                       + msg.getFrom().toBase64() + "] via tunnel ["
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchReplyJob.java

    r8faeaaa r4f836a2  
    5858    public void runJob() {
    5959        if (_curIndex >= _msg.getNumReplies()) {
     60            if (_log.shouldLog(Log.DEBUG) && _msg.getNumReplies() == 0)
     61                _log.debug(getJobId() + ": dbSearchReply received with no routers referenced");
    6062            if (_repliesPendingVerification > 0) {
    6163                // we received new references from the peer, but still
     
    107109            }
    108110            if (_log.shouldLog(Log.DEBUG))
    109                 _log.debug(getJobId() + ": dbSearchReply received on search referencing router " + peer);
     111                _log.debug(getJobId() + ": dbSearchReply received on search referencing router " + peer +
     112                           " already known? " + (info != null));
    110113            if (shouldAdd) {
    111114                if (_searchJob.add(peer))
  • router/java/src/net/i2p/router/networkdb/kademlia/StartExplorersJob.java

    r8faeaaa r4f836a2  
    2929    /** don't explore more than 1 bucket at a time */
    3030    private static final int MAX_PER_RUN = 1;
    31     /** dont explore the network more often than once every minute */
     31    /** dont explore the network more often than this */
    3232    private static final int MIN_RERUN_DELAY_MS = 5*60*1000;
    3333    /** explore the network at least once every thirty minutes */
     
    4242    public String getName() { return "Start Explorers Job"; }
    4343    public void runJob() {
    44         Set toExplore = selectKeysToExplore();
    45         if (_log.shouldLog(Log.DEBUG))
    46             _log.debug("Keys to explore during this run: " + toExplore);
    47         _facade.removeFromExploreKeys(toExplore);
    48         for (Iterator iter = toExplore.iterator(); iter.hasNext(); ) {
    49             Hash key = (Hash)iter.next();
    50             //_log.info("Starting explorer for " + key, new Exception("Exploring!"));
    51             getContext().jobQueue().addJob(new ExploreJob(getContext(), _facade, key));
     44        if (! ((FloodfillNetworkDatabaseFacade)_facade).floodfillEnabled()) {
     45            Set toExplore = selectKeysToExplore();
     46            if (_log.shouldLog(Log.DEBUG))
     47                _log.debug("Keys to explore during this run: " + toExplore);
     48            _facade.removeFromExploreKeys(toExplore);
     49            for (Iterator iter = toExplore.iterator(); iter.hasNext(); ) {
     50                Hash key = (Hash)iter.next();
     51                getContext().jobQueue().addJob(new ExploreJob(getContext(), _facade, key));
     52            }
    5253        }
    5354        long delay = getNextRunDelay();
Note: See TracChangeset for help on using the changeset viewer.