Author: j16sdiz
Date: 2008-10-03 13:24:02 +0000 (Fri, 03 Oct 2008)
New Revision: 22926

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
Log:
Option for resizing store on node start
(someone know better English than mine, please fix the l10n message)

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-10-03 
09:15:14 UTC (rev 22925)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-10-03 
13:24:02 UTC (rev 22926)
@@ -713,6 +713,8 @@
 Node.storeMaxMemTooHigh=Giving more than 80% of your ram to BDB is probably 
not what you want to do!
 Node.storePreallocate=Preallocate space for datastore
 Node.storePreallocateLong=Preallocate space for datastore
+Node.storeSaltHashResizeOnStart=Resize store on node start (salt-hash only)
+Node.storeSaltHashResizeOnStartLong=Resize store on node start (salt-hash 
only). If this is true, the node would complete the resize before starting up 
other services.
 Node.storeSize=Store size in bytes
 Node.storeSizeLong=Store size in bytes
 Node.storeType=Store type (LEAVE THIS ALONE)

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-10-03 09:15:14 UTC (rev 
22925)
+++ trunk/freenet/src/freenet/node/Node.java    2008-10-03 13:24:02 UTC (rev 
22926)
@@ -307,6 +307,7 @@
        private final String storeType;
        private int storeBloomFilterSize;
        private final boolean storeBloomFilterCounting;
+       private boolean storeSaltHashResizeOnStart;

        /** The number of bytes per key total in all the different datastores. 
All the datastores
         * are always the same size in number of keys. */
@@ -1572,6 +1573,20 @@

                storeBloomFilterCounting = 
nodeConfig.getBoolean("storeBloomFilterCounting");

+               nodeConfig.register("storeSaltHashResizeOnStart", true, 
sortOrder++, true, false,
+                               "Node.storeSaltHashResizeOnStart", 
"Node.storeSaltHashResizeOnStartLong", new BooleanCallback() {
+                       @Override
+                       public Boolean get() {
+                               return storeSaltHashResizeOnStart;
+                       }
+
+                       @Override
+                       public void set(Boolean val) throws 
InvalidConfigValueException, NodeNeedRestartException {
+                               storeSaltHashResizeOnStart = val;
+                       }
+               });
+               storeSaltHashResizeOnStart = 
nodeConfig.getBoolean("storeSaltHashResizeOnStart");
+
                nodeConfig.register("storeDir", "datastore", sortOrder++, true, 
true, "Node.storeDirectory", "Node.storeDirectoryLong", 
                                new StringCallback() {
                                        @Override
@@ -1792,32 +1807,32 @@
                        System.out.println("Initializing CHK Datastore (" + 
maxStoreKeys + " keys)");
                        chkDatastore = new CHKStore();
                        SaltedHashFreenetStore chkDataFS = 
SaltedHashFreenetStore.construct(storeDir, "CHK-store", chkDatastore,
-                               random, maxStoreKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               random, maxStoreKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);
                        Logger.normal(this, "Initializing CHK Datacache");
                        System.out.println("Initializing CHK Datacache (" + 
maxCacheKeys + ':' + maxCacheKeys + " keys)");
                        chkDatacache = new CHKStore();
                        SaltedHashFreenetStore chkCacheFS = 
SaltedHashFreenetStore.construct(storeDir, "CHK-cache", chkDatacache,
-                               random, maxCacheKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               random, maxCacheKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);
                        Logger.normal(this, "Initializing pubKey Datastore");
                        System.out.println("Initializing pubKey Datastore");
                        pubKeyDatastore = new PubkeyStore();
                        SaltedHashFreenetStore pubkeyDataFS = 
SaltedHashFreenetStore.construct(storeDir, "PUBKEY-store",
-                               pubKeyDatastore, random, maxStoreKeys, 
bloomFilterSizeInM, storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               pubKeyDatastore, random, maxStoreKeys, 
bloomFilterSizeInM, storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);
                        Logger.normal(this, "Initializing pubKey Datacache");
                        System.out.println("Initializing pubKey Datacache (" + 
maxCacheKeys + " keys)");
                        pubKeyDatacache = new PubkeyStore();
                        SaltedHashFreenetStore pubkeyCacheFS = 
SaltedHashFreenetStore.construct(storeDir, "PUBKEY-cache",
-                               pubKeyDatacache, random, maxCacheKeys, 
bloomFilterSizeInM, storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               pubKeyDatacache, random, maxCacheKeys, 
bloomFilterSizeInM, storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);
                        Logger.normal(this, "Initializing SSK Datastore");
                        System.out.println("Initializing SSK Datastore");
                        sskDatastore = new SSKStore(this);
                        SaltedHashFreenetStore sskDataFS = 
SaltedHashFreenetStore.construct(storeDir, "SSK-store", sskDatastore,
-                               random, maxStoreKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               random, maxStoreKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);
                        Logger.normal(this, "Initializing SSK Datacache");
                        System.out.println("Initializing SSK Datacache (" + 
maxCacheKeys + " keys)");
                        sskDatacache = new SSKStore(this);
                        SaltedHashFreenetStore sskCacheFS = 
SaltedHashFreenetStore.construct(storeDir, "SSK-cache", sskDatacache,
-                               random, maxCacheKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate);
+                               random, maxCacheKeys, bloomFilterSizeInM, 
storeBloomFilterCounting, shutdownHook, storePreallocate, 
storeSaltHashResizeOnStart);

                        File migrationFile = new File(storeDir, "migrated");
                        if (!migrationFile.exists()) {

Modified: trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java      
2008-10-03 09:15:14 UTC (rev 22925)
+++ trunk/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java      
2008-10-03 13:24:02 UTC (rev 22926)
@@ -84,14 +84,14 @@
        private boolean preallocate = true;

        public static SaltedHashFreenetStore construct(File baseDir, String 
name, StoreCallback callback, Random random,
-               long maxKeys, int bloomFilterSize, boolean bloomCounting, 
SemiOrderedShutdownHook shutdownHook, boolean preallocate)
+               long maxKeys, int bloomFilterSize, boolean bloomCounting, 
SemiOrderedShutdownHook shutdownHook, boolean preallocate, boolean 
resizeOnStart)
                throws IOException {
                return new SaltedHashFreenetStore(baseDir, name, callback, 
random, maxKeys, bloomFilterSize, bloomCounting,
-                       shutdownHook, preallocate);
+                       shutdownHook, preallocate, resizeOnStart);
        }

        private SaltedHashFreenetStore(File baseDir, String name, StoreCallback 
callback, Random random, long maxKeys,
-               int bloomFilterSize, boolean bloomCounting, 
SemiOrderedShutdownHook shutdownHook, boolean preallocate) throws IOException {
+               int bloomFilterSize, boolean bloomCounting, 
SemiOrderedShutdownHook shutdownHook, boolean preallocate, boolean 
resizeOnStart) throws IOException {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                logDEBUG = Logger.shouldLog(Logger.DEBUG, this);

@@ -146,7 +146,7 @@
                cleanerStatusUserAlert = new 
CleanerStatusUserAlert(cleanerThread);

                // finish all resizing before continue
-               if (prevStoreSize != 0 && cleanerGlobalLock.tryLock()) {
+               if (resizeOnStart && prevStoreSize != 0 && 
cleanerGlobalLock.tryLock()) {
                        System.out.println("Resizing datastore (" + name + ")");
                        try {
                                cleanerThread.resizeStore(prevStoreSize, false);
@@ -154,7 +154,8 @@
                                cleanerGlobalLock.unlock();
                        }
                        writeConfigFile();
-               } else if (bloomFilter.needRebuild() && !newStore) {
+               } 
+               if (bloomFilter.needRebuild() && !newStore) {
                        // Bloom filter resized?
                        flags |= FLAG_REBUILD_BLOOM;
                        checkBloom = false;


Reply via email to