On Saturday 02 August 2008 03:46, Daniel Cheng wrote:
> On Sat, Aug 2, 2008 at 9:10 AM, Matthew Toseland
> <toad at amphibian.dyndns.org> wrote:
> > On Thursday 17 July 2008 14:38, j16sdiz at freenetproject.org wrote:
> >> Author: j16sdiz
> >> Date: 2008-07-17 13:38:25 +0000 (Thu, 17 Jul 2008)
> >> New Revision: 21168
> >>
> >> Modified:
> >>
> > 
branches/saltedhashstore/freenet/src/freenet/l10n/freenet.l10n.en.properties
> >>    branches/saltedhashstore/freenet/src/freenet/node/Node.java
> >>
> > 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
> >> Log:
> >> show user alert when rebuilding filter / resizing
> >
> > Please use a callback. The below is a rather messy layering violation.
> >
> 
> What kind of callback? Any example?

Hmmm, I see what you mean. Nevermind, just make sure it's possible to 
construct the datastore without the Node.
> 
> >>
> >> Modified:
> > 
branches/saltedhashstore/freenet/src/freenet/l10n/freenet.l10n.en.properties
> >> ===================================================================
> >> ---
> > 
branches/saltedhashstore/freenet/src/freenet/l10n/freenet.l10n.en.properties
> > 2008-07-17 13:38:00 UTC (rev 21167)
> >> +++
> > 
branches/saltedhashstore/freenet/src/freenet/l10n/freenet.l10n.en.properties
> > 2008-07-17 13:38:25 UTC (rev 21168)
> >> @@ -895,6 +895,11 @@
> >>  PproxyToadlet.unloadPluginWithName=Are you sure you wish to unload 
${name}?
> >>  PproxyToadlet.unloadPurge=Remove plugin from cache
> >>  PproxyToadlet.versionTitle=Version
> >> +SaltedHashFreenetStore.shortResizeProgress=Datastore(${name}) resize in
> > progress: ${processed}/${total}
> >> +SaltedHashFreenetStore.shortRebuildProgress=Datastore(${name}) 
maintenance
> > in progress: ${processed}/${total}
> >> +SaltedHashFreenetStore.longResizeProgress=Datastore(${name}) resize in
> > progress: ${processed}/${total}. The node may be a little bit slower then
> > usual during the process. Avoid restarting the node during this.
> >> +SaltedHashFreenetStore.longRebuildProgress=Datastore(${name}) 
maintenance
> > in progress: ${processed}/${total}. The node may be a little bit slower 
then
> > usual during the process. Avoid restarting the node during this.
> >> +SaltedHashFreenetStore.cleanerAlertTitle=Datastore maintenance task 
running
> >>  QueueToadlet.DUinProgress=Directory uploads in progress (${size})
> >>  QueueToadlet.DinProgress=Downloads in progress (${size})
> >>  QueueToadlet.UinProgress=Uploads in progress (${size})
> >>
> >> Modified: branches/saltedhashstore/freenet/src/freenet/node/Node.java
> >> ===================================================================
> >> --- branches/saltedhashstore/freenet/src/freenet/node/Node.java       
2008-07-17
> > 13:38:00 UTC (rev 21167)
> >> +++ branches/saltedhashstore/freenet/src/freenet/node/Node.java       
2008-07-17
> > 13:38:25 UTC (rev 21168)
> >> @@ -1354,34 +1354,32 @@
> >>                               System.out.println("Initializing CHK 
Datastore (" + maxStoreKeys + "
> > keys)");
> >>                               chkDatastore = new CHKStore();
> >>                               SaltedHashFreenetStore chkDataFS =
> > SaltedHashFreenetStore.construct(storeDir, "CHK-store",
> >> -                                     chkDatastore, random, maxStoreKeys, 
0x10000000, shutdownHook);
> >> +                                     chkDatastore, this, maxStoreKeys, 
0x10000000, shutdownHook);
> >>                               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, 
0x10000000, shutdownHook);
> >> -
> >> +                                     chkDatacache, this, maxCacheKeys, 
0x10000000, shutdownHook);
> >>                               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, 0x10000000,
> > shutdownHook);
> >> +                                     pubKeyDatastore, this, 
maxStoreKeys, 0x10000000, shutdownHook);
> >>                               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, 0x10000000,
> > shutdownHook);
> >> -
> >> +                                     pubKeyDatacache, this, 
maxCacheKeys, 0x10000000, shutdownHook);
> >>                               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, 
0x10000000, shutdownHook);
> >> +                                     sskDatastore, this, maxStoreKeys, 
0x10000000, shutdownHook);
> >>                               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, 
0x10000000, shutdownHook);
> >> +                                     sskDatacache, this, maxCacheKeys, 
0x10000000, shutdownHook);
> >>
> >>                               File migrationFile = new 
File(storeDir, "migrated");
> >>                               if (!migrationFile.exists()) {
> >>
> >> Modified:
> > 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
> >> ===================================================================
> >> ---
> > 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
> > 2008-07-17 13:38:00 UTC (rev 21167)
> >> +++
> > 
branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
> > 2008-07-17 13:38:25 UTC (rev 21168)
> >> @@ -14,7 +14,6 @@
> >>  import java.util.List;
> >>  import java.util.ListIterator;
> >>  import java.util.Map;
> >> -import java.util.Random;
> >>  import java.util.SortedSet;
> >>  import java.util.TreeMap;
> >>  import java.util.TreeSet;
> >> @@ -29,13 +28,17 @@
> >>  import org.tanukisoftware.wrapper.WrapperManager;
> >>
> >>  import freenet.keys.KeyVerifyException;
> >> +import freenet.l10n.L10n;
> >> +import freenet.node.Node;
> >>  import freenet.node.SemiOrderedShutdownHook;
> >> +import freenet.node.useralerts.UserAlert;
> >>  import freenet.store.FreenetStore;
> >>  import freenet.store.KeyCollisionException;
> >>  import freenet.store.StorableBlock;
> >>  import freenet.store.StoreCallback;
> >>  import freenet.support.BloomFilter;
> >>  import freenet.support.Fields;
> >> +import freenet.support.HTMLNode;
> >>  import freenet.support.HexUtil;
> >>  import freenet.support.Logger;
> >>  import freenet.support.io.FileUtil;
> >> @@ -70,18 +73,21 @@
> >>       private final int routeKeyLength;
> >>       private final int fullKeyLength;
> >>       private final int dataBlockLength;
> >> -     private final Random random;
> >> +     private final Node node;
> >> +
> >>       private long storeSize;
> >>       private int generation;
> >>       private int flags;
> >>
> >> -     public static SaltedHashFreenetStore construct(File baseDir, String 
name,
> > StoreCallback callback, Random random,
> >> -             long maxKeys, int bloomFilterSize, SemiOrderedShutdownHook
> > shutdownHook) throws IOException {
> >> -             return new SaltedHashFreenetStore(baseDir, name, callback, 
random,
> > maxKeys, bloomFilterSize, shutdownHook);
> >> +     public static SaltedHashFreenetStore construct(File baseDir, String 
name,
> > StoreCallback callback, Node node,
> >> +             long maxKeys, int bloomFilterSize, SemiOrderedShutdownHook
> > shutdownHook)
> >> +             throws IOException {
> >> +             return new SaltedHashFreenetStore(baseDir, name, callback, 
node, maxKeys,
> > bloomFilterSize, shutdownHook);
> >>       }
> >>
> >> -     private SaltedHashFreenetStore(File baseDir, String name, 
StoreCallback
> > callback, Random random, long maxKeys,
> >> -             int bloomFilterSize, SemiOrderedShutdownHook shutdownHook) 
throws
> > IOException {
> >> +     private SaltedHashFreenetStore(File baseDir, String name, 
StoreCallback
> > callback, Node node, long maxKeys,
> >> +             int bloomFilterSize, SemiOrderedShutdownHook shutdownHook)
> >> +             throws IOException {
> >>               logMINOR = Logger.shouldLog(Logger.MINOR, this);
> >>               logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
> >>
> >> @@ -95,7 +101,7 @@
> >>               fullKeyLength = callback.fullKeyLength();
> >>               dataBlockLength = callback.dataLength();
> >>
> >> -             this.random = random;
> >> +             this.node = node;
> >>               storeSize = maxKeys;
> >>               this.bloomFilterSize = bloomFilterSize;
> >>
> >> @@ -454,7 +460,7 @@
> >>
> >>               private ByteBuffer toMetaDataBuffer() {
> >>                       ByteBuffer out = 
ByteBuffer.allocate(METADATA_LENGTH);
> >> -                     cipherManager.encrypt(this, random);
> >> +                     cipherManager.encrypt(this, node.random);
> >>
> >>                       out.put(getDigestedRoutingKey());
> >>                       out.put(dataEncryptIV);
> >> @@ -661,7 +667,7 @@
> >>        * </ul>
> >>        */
> >>       private void writeEntry(Entry entry, long offset) throws 
IOException {
> >> -             cipherManager.encrypt(entry, random);
> >> +             cipherManager.encrypt(entry, node.random);
> >>
> >>               ByteBuffer bf = entry.toMetaDataBuffer();
> >>               do {
> >> @@ -759,7 +765,7 @@
> >>               if (!configFile.exists()) {
> >>                       // create new
> >>                       byte[] newsalt = new byte[0x10];
> >> -                     random.nextBytes(newsalt);
> >> +                     node.random.nextBytes(newsalt);
> >>                       cipherManager = new CipherManager(newsalt);
> >>
> >>                       writeConfigFile();
> >> @@ -852,6 +858,9 @@
> >>                * How often the clean should run
> >>                */
> >>               private static final int CLEANER_PERIOD = 5 * 60 * 1000; // 
5 minutes
> >> +
> >> +             private volatile boolean isRebuilding;
> >> +             private volatile boolean isResizing;
> >>
> >>               public Cleaner() {
> >>                       super("Store-" + name + "-Cleaner", 
NativeThread.LOW_PRIORITY, false);
> >> @@ -862,10 +871,88 @@
> >>               @Override
> >>               public void run() {
> >>                       super.run();
> >> +
> >>                       try {
> >> +                             while (node.clientCore == null) {
> >> +                                     Thread.sleep(1000);
> >> +                             }
> >>                               Thread.sleep((int)(CLEANER_PERIOD / 2 + 
CLEANER_PERIOD *
> > Math.random()));
> >>                       } catch (InterruptedException e){}
> >> +
> >> +                     node.clientCore.alerts.register(new UserAlert() {
> >> +                             public String anchor() {
> >> +                                     return "store-cleaner-" + name;
> >> +                             }
> >>
> >> +                             public String dismissButtonText() {
> >> +                                     return 
L10n.getString("UserAlert.hide");
> >> +                             }
> >> +
> >> +                             public HTMLNode getHTMLText() {
> >> +                                     return new HTMLNode("#", 
getText());
> >> +                             }
> >> +
> >> +                             public short getPriorityClass() {
> >> +                                     return UserAlert.ERROR;
> >> +                             }
> >> +
> >> +                             public String getShortText() {
> >> +                                     if (isResizing)
> >> +                                             return
> > L10n.getString("SaltedHashFreenetStore.shortResizeProgress", //
> >> +                                             new String[] 
{ "name", "processed", "total" },//
> >> +                                                     new String[] { 
name, (entriesTotal - entriesLeft) + "",
> > entriesTotal + "" });
> >> +                                     else
> >> +                                             return
> > L10n.getString("SaltedHashFreenetStore.shortRebuildProgress", //
> >> +                                                     new String[] 
{ "name", "processed", "total" },//
> >> +                                                     new String[] { 
name, (entriesTotal - entriesLeft) + "",
> > entriesTotal + "" });
> >> +                             }
> >> +
> >> +                             public String getText() {
> >> +                                     if (isResizing)
> >> +                                             return 
L10n.getString("SaltedHashFreenetStore.longResizeProgress", //
> >> +                                                     new String[] 
{ "name", "processed", "total" },//
> >> +                                                     new String[] { 
name, (entriesTotal - entriesLeft) + "",
> > entriesTotal + "" });
> >> +                                     else
> >> +                                             return
> > L10n.getString("SaltedHashFreenetStore.longRebuildProgress", //
> >> +                                                     new String[] 
{ "name", "processed", "total" },//
> >> +                                                     new String[] { 
name, (entriesTotal - entriesLeft) + "",
> > entriesTotal + "" });
> >> +                             }
> >> +
> >> +                             public String getTitle() {
> >> +                                     return 
L10n.getString("SaltedHashFreenetStore.cleanerAlertTitle", //
> >> +                                             new String[] { "name" }, //
> >> +                                             new String[] { name });
> >> +                             }
> >> +
> >> +                             public Object getUserIdentifier() {
> >> +                                     return null;
> >> +                             }
> >> +
> >> +                             public boolean isValid() {
> >> +                                     return isRebuilding || isResizing;
> >> +                             }
> >> +
> >> +                             public void isValid(boolean validity) {
> >> +                                     // Ignore
> >> +                             }
> >> +
> >> +                             public void onDismiss() {
> >> +                                     // Ignore
> >> +                             }
> >> +
> >> +                             public boolean shouldUnregisterOnDismiss() 
{
> >> +                                     return true;
> >> +                             }
> >> +
> >> +                             public boolean userCanDismiss() {
> >> +                                     return true;
> >> +                             }
> >> +
> >> +                             public boolean isEventNotification() {
> >> +                                     return false;
> >> +                             }
> >> +                     });
> >> +
> >>                       int loop = 0;
> >>                       while (!shutdown) {
> >>                               loop++;
> >> @@ -882,8 +969,10 @@
> >>
> >>                                       if (_prevStoreSize != 0 && 
cleanerGlobalLock.tryLock()) {
> >>                                               try {
> >> +                                                     isResizing = true;
> >>                                                       
resizeStore(_prevStoreSize, true);
> >>                                               } finally {
> >> +                                                     isResizing = false;
> >>                                                       
cleanerGlobalLock.unlock();
> >>                                               }
> >>                                       }
> >> @@ -897,8 +986,10 @@
> >>                                       }
> >>                                       if (_rebuildBloom && prevStoreSize 
== 0 &&
> > cleanerGlobalLock.tryLock()) {
> >>                                               try {
> >> +                                                     isRebuilding = 
true;
> >>                                                       rebuildBloom(true);
> >>                                               } finally {
> >> +                                                     isRebuilding = 
false;
> >>                                                       
cleanerGlobalLock.unlock();
> >>                                               }
> >>                                       }
> >>
> >> _______________________________________________
> >> cvs mailing list
> >> cvs at freenetproject.org
> >> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> >>
> >>
> >
> > _______________________________________________
> > Devl mailing list
> > Devl at freenetproject.org
> > http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
> >
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080802/e058c5be/attachment.pgp>

Reply via email to