Author: juiceman
Date: 2007-05-20 21:51:09 +0000 (Sun, 20 May 2007)
New Revision: 13285

Modified:
   trunk/freenet/src/freenet/client/async/USKManager.java
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/NodeClientCore.java
Log:
Implement a config option for USKFetchers.  Resolves a //Fixme

Modified: trunk/freenet/src/freenet/client/async/USKManager.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKManager.java      2007-05-20 
21:44:34 UTC (rev 13284)
+++ trunk/freenet/src/freenet/client/async/USKManager.java      2007-05-20 
21:51:09 UTC (rev 13285)
@@ -32,8 +32,6 @@
        /** Backgrounded USKFetchers by USK. */
        final HashMap backgroundFetchersByClearUSK;

-       // FIXME make this configurable
-       static final int MAX_BACKGROUND_FETCHERS = 64;
        final LRUQueue temporaryBackgroundFetchersLRU;

        /** USKChecker's by USK. Deleted immediately on completion. */
@@ -103,7 +101,7 @@
                                backgroundFetchersByClearUSK.put(clear, f);
                        }
                        temporaryBackgroundFetchersLRU.push(clear);
-                       while(temporaryBackgroundFetchersLRU.size() > 
MAX_BACKGROUND_FETCHERS) {
+                       while(temporaryBackgroundFetchersLRU.size() > 
NodeClientCore.maxBackgroundUSKFetchers) {
                                USK del = (USK) 
temporaryBackgroundFetchersLRU.pop();
                                USKFetcher fetcher = (USKFetcher) 
backgroundFetchersByClearUSK.get(del.clearCopy());
                                if(!fetcher.hasSubscribers()) {

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-05-20 
21:44:34 UTC (rev 13284)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2007-05-20 
21:51:09 UTC (rev 13285)
@@ -493,6 +493,8 @@
 NodeClientCore.ignoreTooManyPathComponentsLong=If true, the node won't 
generate TOO_MANY_PATH_COMPONENTS errors when a URI is fed to it which has 
extra, meaningless subdirs (/blah/blah) on the end beyond what is needed to 
fetch the key (for example, old CHKs will often have filenames stuck on the end 
which weren't part of the original insert; this is obsolete because we can now 
include the filename, and it is confusing to be able to add arbitrary strings 
to a URI, and it makes them hard to compare). Only enable this option if you 
need it for compatibility with older apps; it will be removed soon.
 NodeClientCore.lazyResume=Complete loading of persistent requests after 
startup? (Uses more memory)
 NodeClientCore.lazyResumeLong=The node can load persistent queued requests 
during startup, or it can read the data into memory and then complete the 
request resuming process after the node has started up. Shorter start-up times, 
but uses more memory.
+NodeClientCore.maxUSKFetchers=Maximum number of allowed USK fetchers
+NodeClientCore.maxUSKFetchersLong=Maximum number of allowed USK fetchers
 NodeClientCore.movingTempDirOnTheFlyNotSupported=Moving temp directory on the 
fly not supported at present
 NodeClientCore.persistentTempDir=Persistent temp files directory
 NodeClientCore.persistentTempDirLong=Name of directory to put persistent temp 
files in

Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java  2007-05-20 21:44:34 UTC 
(rev 13284)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java  2007-05-20 21:51:09 UTC 
(rev 13285)
@@ -47,6 +47,7 @@
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.BooleanCallback;
+import freenet.support.api.IntCallback;
 import freenet.support.api.BucketFactory;
 import freenet.support.api.StringArrCallback;
 import freenet.support.api.StringCallback;
@@ -102,6 +103,8 @@
        private boolean lazyResume;
        protected final Persister persister;

+       public static int maxBackgroundUSKFetchers;
+       
        // Client stuff that needs to be configged - FIXME
        static final int MAX_ARCHIVE_HANDLERS = 200; // don't take up much 
RAM... FIXME
        static final long MAX_CACHED_ARCHIVE_DATA = 32*1024*1024; // make a 
fixed fraction of the store by default? FIXME
@@ -308,6 +311,21 @@

                lazyResume = nodeConfig.getBoolean("lazyResume");

+               nodeConfig.register("maxBackgroundUSKFetchers", "64", 
sortOrder++, true, false, "NodeClientCore.maxUSKFetchers",
+                               "NodeClientCore.maxUSKFetchersLong", new 
IntCallback() {
+                                       public int get() {
+                                               return maxBackgroundUSKFetchers;
+                                       }
+                                       public void set(int uskFetch) throws 
InvalidConfigValueException {
+                                               if(uskFetch <= 0) throw new 
InvalidConfigValueException(l10n("uskFetchersMustBeGreaterThanZero"));
+                                                       
maxBackgroundUSKFetchers = uskFetch;
+                                               }
+                                       }
+               );
+               
+               maxBackgroundUSKFetchers = 
nodeConfig.getInt("maxBackgroundUSKFetchers");
+               
+               
                // FIXME remove and remove related code when we can just block 
them.
                // REDFLAG normally we wouldn't use static variables to carry 
important non-final data, but in this
                // case it's temporary code which will be removed before 0.7.0.
@@ -1013,6 +1031,10 @@
                return new GenericReadFilterCallback(uri, cb);
        }

+       public int maxBackgroundUSKFetchers() {
+               return maxBackgroundUSKFetchers;
+       }
+       
        public boolean lazyResume() {
                return lazyResume;
        }


Reply via email to