Author: j16sdiz
Date: 2008-07-29 12:01:32 +0000 (Tue, 29 Jul 2008)
New Revision: 21470

Modified:
   
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
Log:
if bloom filter missing/size mismatch, rebuild it before continue

Modified: 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
===================================================================
--- 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
   2008-07-29 11:51:55 UTC (rev 21469)
+++ 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
   2008-07-29 12:01:32 UTC (rev 21470)
@@ -118,10 +118,6 @@

                File bloomFile = new File(this.baseDir, name + ".bloom");
                bloomFilter = new BinaryBloomFilter(bloomFile, bloomFilterSize, 
bloomFilterK);
-               if (bloomFilter.needRebuild() && !newStore) {
-                       flags |= FLAG_REBUILD_BLOOM;
-                       checkBloom = false;
-               }

                if ((flags & FLAG_DIRTY) != 0)
                        System.err.println("Datastore(" + name + ") is dirty.");
@@ -141,6 +137,7 @@
                shutdownHook.addEarlyJob(new Thread(new ShutdownDB()));

                cleanerThread = new Cleaner();
+
                // finish all resizing before continue
                if (prevStoreSize != 0 && cleanerGlobalLock.tryLock()) {
                        System.out.println("Resizing datastore (" + name + ")");
@@ -150,6 +147,20 @@
                                cleanerGlobalLock.unlock();
                        }
                        writeConfigFile();
+               } else if (bloomFilter.needRebuild() && !newStore) {
+                       // Bloom filter resized?
+                       flags |= FLAG_REBUILD_BLOOM;
+                       checkBloom = false;
+
+                       if (cleanerGlobalLock.tryLock()) {
+                               System.out.println("Bloom filter for datastore 
(" + name + ") missing/mismatch, rebuilding.");
+                               try {
+                                       cleanerThread.rebuildBloom(false);
+                               } finally {
+                                       cleanerGlobalLock.unlock();
+                               }
+                               writeConfigFile();
+                       }
                }

                cleanerThread.start();


Reply via email to