Author: batosai
Date: 2008-08-31 17:50:40 +0000 (Sun, 31 Aug 2008)
New Revision: 22285

Modified:
   trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Directly fetch next edition at startup for already fetched identities. 
This should lower the load on the node at plugin startup.

Modified: trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-31 17:02:36 UTC 
(rev 22284)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityFetcher.java 2008-08-31 17:50:40 UTC 
(rev 22285)
@@ -7,6 +7,7 @@
 package plugins.WoT;

 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Iterator;

 import com.db4o.ObjectContainer;
@@ -43,8 +44,16 @@

        public void fetch(Identity identity) {

+               fetch(identity, false);
+       }
+       
+       public void fetch(Identity identity, boolean nextEdition) {
+               
                try {
-                       fetch(identity.getRequestURI());
+                       if(nextEdition && !identity.getLastChange().equals(new 
Date(0)))
+                               
fetch(identity.getRequestURI().setSuggestedEdition(identity.getRequestURI().getSuggestedEdition()
 + 1));
+                       else
+                               fetch(identity.getRequestURI());
                } catch (FetchException e) {
                        Logger.error(this, "Request restart failed: "+e, e);
                }

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-31 17:02:36 UTC 
(rev 22284)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-31 17:50:40 UTC 
(rev 22285)
@@ -63,13 +63,14 @@

                Logger.debug(this, "Start");

+               // Init
                this.pr = pr;
                db = Db4o.openFile("WoT.db4o");
                wot = new WoT(db);
                client = pr.getHLSimpleClient();
-
                web = new WebInterface(pr, db, client, SELF_URI, wot);

+               // Create the seed Identity if it doesn't exist
                try {
                        seed = wot.getIdentityByURI(seedURI);
                } catch (UnknownIdentityException e) {
@@ -86,15 +87,17 @@
                        return;
                }

-               
+               // Start the inserter thread
                inserter = new IdentityInserter(wot, db, client);
                pr.getNode().executor.execute(inserter, "WoTinserter");

+               // Create the fetcher
                fetcher = new IdentityFetcher(db, wot, client);

+               // Try to fetch all known identities
                ObjectSet<Identity> identities = wot.getAllIdentities();
                while (identities.hasNext()) {
-                       fetcher.fetch(identities.next());
+                       fetcher.fetch(identities.next(), true);
                }
        }



Reply via email to