Changeset 1061e86


Ignore:
Timestamp:
Jul 26, 2011 1:30:54 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b0c2012
Parents:
164b0e54
Message:
  • NetDB:
    • Explore even more aggressively at startup
    • Increase SingleSearchJob? timeout
    • Increase time at startup for processing DSRM
    • Cleanups, final, javadoc, concurrent
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r164b0e54 r1061e86  
     12011-07-26 zzz
     2  * NetDB:
     3    - Explore even more aggressively at startup
     4    - Increase SingleSearchJob timeout
     5    - Increase time at startup for processing DSRM
     6    - Cleanups, final, javadoc, concurrent
     7  * OutNetMessage: Cleanups
     8  * Tunnels: Change another log error to a warn
     9  * Watchdog: Improve the way it calls for a thread dump
     10
    1112011-07-22 kytv
    212  * Add a 64bit wrapper to OSX. With 0.8.7 came a fat Mac wrapper with i386 and PPC.
  • router/java/src/net/i2p/router/RouterVersion.java

    r164b0e54 r1061e86  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 14;
     21    public final static long BUILD = 15;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java

    r164b0e54 r1061e86  
    2626 * validate(), which is a sliding expriation based on netdb size.
    2727 *
     28 * @deprecated unused - see comments in KNDF
    2829 */
    2930class ExpireRoutersJob extends JobImpl {
  • router/java/src/net/i2p/router/networkdb/kademlia/ExploreKeySelectorJob.java

    r164b0e54 r1061e86  
    2323 * per bucket)
    2424 *
     25 * @deprecated unused, see comments in KNDF
    2526 */
    2627class ExploreKeySelectorJob extends JobImpl {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlyLookupMatchJob.java

    r164b0e54 r1061e86  
    1313
    1414class FloodOnlyLookupMatchJob extends JobImpl implements ReplyJob {
    15     private Log _log;
    16     private FloodOnlySearchJob _search;
     15    private final Log _log;
     16    private final FloodOnlySearchJob _search;
    1717    private DatabaseSearchReplyMessage _dsrm;
     18
    1819    public FloodOnlyLookupMatchJob(RouterContext ctx, FloodOnlySearchJob job) {
    1920        super(ctx);
    2021        _log = ctx.logManager().getLog(getClass());
    2122        _search = job;
    22         _dsrm = null;
    2323    }
     24
    2425    public void runJob() {
    2526        if ( (getContext().netDb().lookupLeaseSetLocally(_search.getKey()) != null) ||
     
    4546        }
    4647    }
     48
    4749    public String getName() { return "NetDb flood search (phase 1) match"; }
     50
    4851    public void setMessage(I2NPMessage message) {
    4952        if (message instanceof DatabaseSearchReplyMessage) {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlyLookupSelector.java

    r164b0e54 r1061e86  
    99
    1010class FloodOnlyLookupSelector implements MessageSelector {
    11     private RouterContext _context;
    12     private FloodOnlySearchJob _search;
     11    private final RouterContext _context;
     12    private final FloodOnlySearchJob _search;
    1313    private boolean _matchFound;
    14     private Log _log;
     14    private final Log _log;
     15
    1516    public FloodOnlyLookupSelector(RouterContext ctx, FloodOnlySearchJob search) {
    1617        _context = ctx;
    1718        _search = search;
    1819        _log = ctx.logManager().getLog(getClass());
    19         _matchFound = false;
    2020    }
     21
    2122    public boolean continueMatching() {
    2223        return _search.getLookupsRemaining() > 0 && !_matchFound && _context.clock().now() < getExpiration();
    2324    }
     25
    2426    public long getExpiration() { return (_matchFound ? -1 : _search.getExpiration()); }
     27
    2528    public boolean isMatch(I2NPMessage message) {
    2629        if (message == null) return false;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlyLookupTimeoutJob.java

    r164b0e54 r1061e86  
    66
    77class FloodOnlyLookupTimeoutJob extends JobImpl {
    8     private FloodSearchJob _search;
    9     private Log _log;
     8    private final FloodSearchJob _search;
     9    private final Log _log;
     10
    1011    public FloodOnlyLookupTimeoutJob(RouterContext ctx, FloodOnlySearchJob job) {
    1112        super(ctx);
     
    1314        _log = ctx.logManager().getLog(getClass());
    1415    }
     16
    1517    public void runJob() {
    1618        if (_log.shouldLog(Log.INFO))
     
    1820        _search.failed();
    1921    }
     22
    2023    public String getName() { return "NetDb flood search (phase 1) timeout"; }
    2124}
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java

    r164b0e54 r1061e86  
    3939class FloodOnlySearchJob extends FloodSearchJob {
    4040    private volatile boolean _dead;
    41     private long _created;
     41    private final long _created;
    4242    private boolean _shouldProcessDSRM;
    4343    private final HashSet<Hash> _unheardFrom;
    4444   
    4545    private final List<OutNetMessage> _out;
    46     protected MessageSelector _replySelector;
    47     protected ReplyJob _onReply;
    48     protected Job _onTimeout;
     46    protected final MessageSelector _replySelector;
     47    protected final ReplyJob _onReply;
     48    protected final Job _onTimeout;
    4949
    5050    public FloodOnlySearchJob(RouterContext ctx, FloodfillNetworkDatabaseFacade facade, Hash key, Job onFind, Job onFailed, int timeoutMs, boolean isLease) {
     
    6262        _onTimeout = new FloodOnlyLookupTimeoutJob(getContext(), this);
    6363        _created = System.currentTimeMillis();
    64         _shouldProcessDSRM = false;
    6564    }
    6665
     
    9190        // so this includes the first few minutes of uptime)
    9291        _shouldProcessDSRM = floodfillPeers.size() < MIN_FOR_NO_DSRM ||
    93                              getContext().routingKeyGenerator().getLastChanged() > getContext().clock().now() - 30*60*1000;
     92                             getContext().routingKeyGenerator().getLastChanged() > getContext().clock().now() - 60*60*1000;
    9493
    9594        if (floodfillPeers.isEmpty()) {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodSearchJob.java

    r164b0e54 r1061e86  
    3131public class FloodSearchJob extends JobImpl {
    3232    protected Log _log;
    33     protected FloodfillNetworkDatabaseFacade _facade;
    34     protected Hash _key;
     33    protected final FloodfillNetworkDatabaseFacade _facade;
     34    protected final Hash _key;
    3535    protected final List<Job> _onFind;
    3636    protected final List<Job> _onFailed;
     
    3838    protected int _timeoutMs;
    3939    protected long _origExpiration;
    40     protected boolean _isLease;
     40    protected final boolean _isLease;
    4141    protected volatile int _lookupsRemaining;
    4242    protected volatile boolean _dead;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r164b0e54 r1061e86  
    4545        super(context);
    4646        _activeFloodQueries = new HashMap();
    47          _floodfillEnabled = false;
    4847         _verifiesInProgress = new ConcurrentHashSet(8);
    4948        _alwaysQuery = _context.getProperty("netDb.alwaysQuery");
     
    407406   
    408407    private class DropLookupFailedJob extends JobImpl {
    409         private Hash _peer;
    410         private RouterInfo _info;
     408        private final Hash _peer;
     409        private final RouterInfo _info;
    411410   
    412411        public DropLookupFailedJob(RouterContext ctx, Hash peer, RouterInfo info) {
     
    420419        }
    421420    }
     421
    422422    private class DropLookupFoundJob extends JobImpl {
    423         private Hash _peer;
    424         private RouterInfo _info;
     423        private final Hash _peer;
     424        private final RouterInfo _info;
    425425   
    426426        public DropLookupFoundJob(RouterContext ctx, Hash peer, RouterInfo info) {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillStoreJob.java

    r164b0e54 r1061e86  
    2626 */
    2727class FloodfillStoreJob extends StoreJob {   
    28     private FloodfillNetworkDatabaseFacade _facade;
     28    private final FloodfillNetworkDatabaseFacade _facade;
     29
    2930    /**
    3031     * Send a data structure to the floodfills
     
    4647    @Override
    4748    protected int getParallelization() { return 1; }
     49
    4850    @Override
    4951    protected int getRedundancy() { return 1; }
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    r164b0e54 r1061e86  
    2626 */
    2727public class FloodfillVerifyStoreJob extends JobImpl {
    28     private Log _log;
    29     private Hash _key;
     28    private final Log _log;
     29    private final Hash _key;
    3030    private Hash _target;
    31     private Hash _sentTo;
    32     private FloodfillNetworkDatabaseFacade _facade;
     31    private final Hash _sentTo;
     32    private final FloodfillNetworkDatabaseFacade _facade;
    3333    private long _expiration;
    3434    private long _sendTime;
    3535    private long _published;
    36     private boolean _isRouterInfo;
     36    private final boolean _isRouterInfo;
    3737    private MessageWrapper.WrappedMessage _wrappedMessage;
    3838    private final Set<Hash> _ignore;
     
    6565        getContext().statManager().createRateStat("netDb.floodfillVerifyTimeout", "How long a floodfill verify takes when it times out", "NetworkDatabase", new long[] { 60*60*1000 });
    6666    }
     67
    6768    public String getName() { return "Verify netdb store"; }
    6869
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r164b0e54 r1061e86  
    4444import net.i2p.router.networkdb.PublishLocalRouterInfoJob;
    4545import net.i2p.router.peermanager.PeerProfile;
     46import net.i2p.util.ConcurrentHashSet;
    4647import net.i2p.util.Log;
    4748
     
    5657    /** where the data store is pushing the data */
    5758    private String _dbDir;
    58     private final Set<Hash> _exploreKeys = new HashSet(64); // set of Hash objects that we should search on (to fill up a bucket, not to get data)
     59    // set of Hash objects that we should search on (to fill up a bucket, not to get data)
     60    private final Set<Hash> _exploreKeys = new ConcurrentHashSet(64);
    5961    private boolean _initialized;
    6062    /** Clock independent time of when we started up */
     
    168170    }
    169171   
     172    /** @return unmodifiable set */
    170173    public Set<Hash> getExploreKeys() {
    171         if (!_initialized) return null;
    172         synchronized (_exploreKeys) {
    173             return new HashSet(_exploreKeys);
    174         }
    175     }
    176    
    177     public void removeFromExploreKeys(Set toRemove) {
     174        if (!_initialized)
     175            return Collections.EMPTY_SET;
     176        return Collections.unmodifiableSet(_exploreKeys);
     177    }
     178   
     179    public void removeFromExploreKeys(Set<Hash> toRemove) {
    178180        if (!_initialized) return;
    179         synchronized (_exploreKeys) {
    180             _exploreKeys.removeAll(toRemove);
    181             _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
    182         }
    183     }
    184     public void queueForExploration(Set keys) {
     181        _exploreKeys.removeAll(toRemove);
     182        _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
     183    }
     184
     185    public void queueForExploration(Set<Hash> keys) {
    185186        if (!_initialized) return;
    186         synchronized (_exploreKeys) {
    187             _exploreKeys.addAll(keys);
    188             _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
    189         }
     187        _exploreKeys.addAll(keys);
     188        _context.statManager().addRateData("netDb.exploreKeySet", _exploreKeys.size(), 0);
    190189    }
    191190   
     
    216215            _enforceNetId = DEFAULT_ENFORCE_NETID;
    217216        _ds.restart();
    218         synchronized (_exploreKeys) { _exploreKeys.clear(); }
     217        _exploreKeys.clear();
    219218
    220219        _initialized = true;
     
    475474                    fail(key);
    476475                    // this was an interesting key, so either refetch it or simply explore with it
    477                     synchronized (_exploreKeys) {
    478                         _exploreKeys.add(key);
    479                     }
     476                    _exploreKeys.add(key);
    480477                    return null;
    481478                }
     
    710707     *
    711708     * TODO this is called several times, only check the key and signature once
     709     *
     710     * @return reason why the entry is not valid, or null if it is valid
    712711     */
    713712    String validate(Hash key, RouterInfo routerInfo) throws IllegalArgumentException {
  • router/java/src/net/i2p/router/networkdb/kademlia/SingleLookupJob.java

    r164b0e54 r1061e86  
    2121 */
    2222class SingleLookupJob extends JobImpl {
    23     private Log _log;
    24     private DatabaseSearchReplyMessage _dsrm;
     23    private final Log _log;
     24    private final DatabaseSearchReplyMessage _dsrm;
     25
    2526    public SingleLookupJob(RouterContext ctx, DatabaseSearchReplyMessage dsrm) {
    2627        super(ctx);
     
    2829        _dsrm = dsrm;
    2930    }
     31
    3032    public void runJob() {
    3133        Hash from = _dsrm.getFromHash();
     
    4446        }
    4547    }
     48
    4649    public String getName() { return "NetDb process DSRM"; }
    4750}
  • router/java/src/net/i2p/router/networkdb/kademlia/SingleSearchJob.java

    r164b0e54 r1061e86  
    1515 */
    1616class SingleSearchJob extends FloodOnlySearchJob {
    17     Hash _to;
    18     OutNetMessage _onm;
     17    private final Hash _to;
     18    private OutNetMessage _onm;
     19
     20    private static final int TIMEOUT = 8*1000;
     21
    1922    public SingleSearchJob(RouterContext ctx, Hash key, Hash to) {
    2023        // warning, null FloodfillNetworkDatabaseFacade ...
    2124        // define our own failed() and success() below so _facade isn't used.
    22         super(ctx, null, key, null, null, 5*1000, false);
     25        super(ctx, null, key, null, null, TIMEOUT, false);
    2326        _to = to;
    2427    }
     28
    2529    @Override
    2630    public String getName() { return "NetDb search key from DSRM"; }
     31
    2732    @Override
    2833    public boolean shouldProcessDSRM() { return false; } // don't loop
     34
    2935    @Override
    3036    public void runJob() {
     
    4753        _lookupsRemaining = 1;
    4854    }
     55
    4956    @Override
    5057    void failed() {
    5158        getContext().messageRegistry().unregisterPending(_onm);
    5259    }
     60
    5361    @Override
    5462    void success() {}
  • router/java/src/net/i2p/router/networkdb/kademlia/StartExplorersJob.java

    r164b0e54 r1061e86  
    5454            int num = MAX_PER_RUN;
    5555            if (_facade.getDataStore().size() < LOW_ROUTERS)
    56                 num *= 2;
     56                num *= 3;
     57            if (getContext().router().getUptime() < STARTUP_TIME)
     58                num *= 3;
    5759            Set<Hash> toExplore = selectKeysToExplore(num);
    5860            if (_log.shouldLog(Log.DEBUG))
Note: See TracChangeset for help on using the changeset viewer.