Changeset 573ac35


Ignore:
Timestamp:
Nov 11, 2009 8:24:59 PM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
6c00bb2
Parents:
5b139f9
Message:

ff ranking tweaks so they arent all bad

File:
1 edited

Legend:

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

    r5b139f9 r573ac35  
    8686   
    8787    /**
     88     *  Sort the floodfills. The challenge here is to keep the good ones
     89     *  at the front and the bad ones at the back. If they are all good or bad,
     90     *  searches and stores won't work well.
     91     *
    8892     *  @return all floodfills not shitlisted foreverx
    8993     *  @param key the routing key
     
    9195     *  Sorted by closest to the key if > maxNumRouters, otherwise not
    9296     *  The list is in 3 groups - sorted by routing key within each group.
    93      *  Group 1: No store or lookup failure in last 15 minutes
    94      *  Group 2: No store or lookup failure in last 3 minutes
     97     *  Group 1: No store or lookup failure in a long time
     98     *  Group 2: No store or lookup failure in a little while or
     99     *           success newer than failure
    95100     *  Group 3: All others
    96101     */
     
    99104    }
    100105
    101     /** 1.5 * PublishLocalRouterInfoJob.PUBLISH_DELAY */
    102     private static final int NO_FAIL_STORE_OK = 30*60*1000;
     106    /** .75 * PublishLocalRouterInfoJob.PUBLISH_DELAY */
     107    private static final int NO_FAIL_STORE_OK = 15*60*1000;
    103108    private static final int NO_FAIL_STORE_GOOD = NO_FAIL_STORE_OK * 2;
     109    /** this must be longer than the max streaming timeout (60s) */
    104110    private static final int NO_FAIL_LOOKUP_OK = 5*60*1000;
    105111    private static final int NO_FAIL_LOOKUP_GOOD = NO_FAIL_LOOKUP_OK * 3;
     112    private static final int MAX_GOOD_RESP_TIME = 5*1000;
    106113
    107114    public List<Hash> selectFloodfillParticipants(Hash key, int howMany, Set<Hash> toIgnore, KBucketSet kbuckets) {
     
    111118
    112119        List<Hash> rv = new ArrayList(howMany);
    113         List<Hash> okff = new ArrayList(howMany);
    114         List<Hash> badff = new ArrayList(howMany);
     120        List<Hash> okff = new ArrayList(ffs.size());
     121        List<Hash> badff = new ArrayList(ffs.size());
    115122        int found = 0;
    116123        long now = _context.clock().now();
     
    126133                badff.add(entry);
    127134                if (_log.shouldLog(Log.DEBUG))
    128                     _log.debug("Skipping, published a while ago: " + entry);
     135                    _log.debug("Old: " + entry);
    129136            } else {
    130137                PeerProfile prof = _context.profileOrganizer().getProfile(entry);
    131138                if (prof != null && prof.getDBHistory() != null
     139                    && ((int) prof.getDbResponseTime().getRate(10*60*1000).getAverageValue()) < MAX_GOOD_RESP_TIME
    132140                    && prof.getDBHistory().getLastStoreFailed() < now - NO_FAIL_STORE_GOOD
    133141                    && prof.getDBHistory().getLastLookupFailed() < now - NO_FAIL_LOOKUP_GOOD) {
     
    138146                    found++;
    139147                } else if (prof != null && prof.getDBHistory() != null
    140                            && prof.getDBHistory().getLastStoreFailed() < now - NO_FAIL_STORE_OK
    141                            && prof.getDBHistory().getLastLookupFailed() < now - NO_FAIL_LOOKUP_OK) {
     148                           && (prof.getDBHistory().getLastStoreFailed() <= prof.getDBHistory().getLastStoreSuccessful()
     149                               || prof.getDBHistory().getLastLookupFailed() <= prof.getDBHistory().getLastLookupSuccessful()
     150                               || (prof.getDBHistory().getLastStoreFailed() < now - NO_FAIL_STORE_OK
     151                                   && prof.getDBHistory().getLastLookupFailed() < now - NO_FAIL_LOOKUP_OK))) {
    142152                    if (_log.shouldLog(Log.DEBUG))
    143153                        _log.debug("OK: " + entry);
     
    150160            }
    151161        }
    152         if (_log.shouldLog(Log.DEBUG))
    153             _log.debug("Good: " + rv + " OK: " + okff + " Bad: " + badff);
     162        if (_log.shouldLog(Log.INFO))
     163            _log.info("Good: " + rv + " OK: " + okff + " Bad: " + badff);
    154164
    155165        // Put the ok floodfills after the good floodfills
Note: See TracChangeset for help on using the changeset viewer.