Changeset c901010d


Ignore:
Timestamp:
Nov 7, 2015 2:56:59 AM (5 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
f5bf4ec
Parents:
9f0f1f5
Message:

Make parameters of NegativeLookupCache? configurable

Location:
router/java/src/net/i2p/router/networkdb/kademlia
Files:
2 edited

Legend:

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

    r9f0f1f5 rc901010d  
    275275//        _exploreKeys = new HashSet(64);
    276276        _dbDir = dbDir;
    277         _negativeCache = new NegativeLookupCache();
     277        _negativeCache = new NegativeLookupCache(_context);
    278278       
    279279        createHandlers();
  • router/java/src/net/i2p/router/networkdb/kademlia/NegativeLookupCache.java

    r9f0f1f5 rc901010d  
    55import net.i2p.data.Destination;
    66import net.i2p.data.Hash;
     7import net.i2p.router.RouterContext;
    78import net.i2p.util.LHMCache;
    89import net.i2p.util.ObjectCounter;
     
    1819    private final ObjectCounter<Hash> counter;
    1920    private final Map<Hash, Destination> badDests;
    20 
     21    private final int _maxFails;
     22   
    2123    private static final int MAX_FAILS = 3;
    2224    private static final int MAX_BAD_DESTS = 128;
    2325    private static final long CLEAN_TIME = 2*60*1000;
    2426
    25     public NegativeLookupCache() {
     27    public NegativeLookupCache(RouterContext context) {
    2628        this.counter = new ObjectCounter<Hash>();
    2729        this.badDests = new LHMCache<Hash, Destination>(MAX_BAD_DESTS);
    28         SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
     30        this._maxFails = context.getProperty("netdb.negativeCache.maxFails",MAX_FAILS);
     31        final long cleanTime = context.getProperty("netdb.negativeCache.cleanupInterval", CLEAN_TIME);
     32        SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), cleanTime);
    2933    }
    3034
     
    3438
    3539    public boolean isCached(Hash h) {
    36         if (counter.count(h) >= MAX_FAILS)
     40        if (counter.count(h) >= _maxFails)
    3741            return true;
    3842        synchronized(badDests) {
Note: See TracChangeset for help on using the changeset viewer.