Changeset 04a5968


Ignore:
Timestamp:
Dec 19, 2013 12:23:29 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
38c02b44
Parents:
ee1ed1bb
Message:

NetDB: Fixes for ExpireRoutersJob?

  • Don't expire if too few routers
  • Don't expire if net is disconnected
  • Don't run in VMCommSystem
Location:
router/java/src/net/i2p/router/networkdb/kademlia
Files:
2 edited

Legend:

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

    ree1ed1bb r04a5968  
    1414import net.i2p.data.Hash;
    1515import net.i2p.data.RouterInfo;
     16import net.i2p.router.CommSystemFacade;
    1617import net.i2p.router.JobImpl;
    1718import net.i2p.router.RouterContext;
     
    4344
    4445    public void runJob() {
    45         int removed = expireKeys();
    46         if (_log.shouldLog(Log.INFO))
    47             _log.info("Routers expired: " + removed);
     46        if (getContext().commSystem().getReachabilityStatus() != CommSystemFacade.STATUS_DISCONNECTED) {
     47            int removed = expireKeys();
     48            if (_log.shouldLog(Log.INFO))
     49                _log.info("Routers expired: " + removed);
     50        }
    4851        requeue(RERUN_DELAY_MS);
    4952    }
     
    6063        Set<Hash> keys = _facade.getAllRouters();
    6164        keys.remove(getContext().routerHash());
     65        if (keys.size() < 150)
     66            return 0;
    6267        int removed = 0;
    6368        for (Hash key : keys) {
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    ree1ed1bb r04a5968  
    276276        //// expire some routers
    277277        // Don't run until after RefreshRoutersJob has run, and after validate() will return invalid for old routers.
    278         Job erj = new ExpireRoutersJob(_context, this);
    279         erj.getTiming().setStartAfter(_context.clock().now() + ROUTER_INFO_EXPIRATION_FLOODFILL + 10*60*1000);
    280         _context.jobQueue().addJob(erj);
     278        if (!_context.commSystem().isDummy()) {
     279            Job erj = new ExpireRoutersJob(_context, this);
     280            erj.getTiming().setStartAfter(_context.clock().now() + ROUTER_INFO_EXPIRATION_FLOODFILL + 10*60*1000);
     281            _context.jobQueue().addJob(erj);
     282        }
    281283       
    282284        if (!QUIET) {
Note: See TracChangeset for help on using the changeset viewer.