[freenet-cvs] r11747 - in trunk/freenet/src/freenet/node: . fcp

toad at freenetproject.org toad at freenetproject.org
Sat Feb 10 18:05:13 UTC 2007


Author: toad
Date: 2007-02-10 18:05:13 +0000 (Sat, 10 Feb 2007)
New Revision: 11747

Modified:
   trunk/freenet/src/freenet/node/NodeClientCore.java
   trunk/freenet/src/freenet/node/fcp/ClientRequest.java
Log:
New config option lazyResume / "Complete loading of persistent requests after startup?"

Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java	2007-02-10 17:56:07 UTC (rev 11746)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java	2007-02-10 18:05:13 UTC (rev 11747)
@@ -88,6 +88,10 @@
 	public final BackgroundBlockEncoder backgroundBlockEncoder;
 	/** If true, allow extra path components at the end of URIs */
 	public boolean ignoreTooManyPathComponents;
+	/** If true, requests are resumed lazily i.e. startup does not block waiting for them. */
+	private boolean lazyResume;
+	/** Has the startup process reached the point of resuming requests yet? If this is true, lazyResume can safely be modified. */
+	private boolean startedResume;
 	
 	// Client stuff that needs to be configged - FIXME
 	static final int MAX_ARCHIVE_HANDLERS = 200; // don't take up much RAM... FIXME
@@ -207,16 +211,36 @@
 					}
 
 					public void set(boolean val) throws InvalidConfigValueException {
-						ignoreTooManyPathComponents = val;
+						synchronized(NodeClientCore.this) {
+							ignoreTooManyPathComponents = val;
+						}
 					}
 			
 		});
 		
 		ignoreTooManyPathComponents = nodeConfig.getBoolean("ignoreTooManyPathComponents");
 		
+		nodeConfig.register("lazyResume", true, sortOrder++, true, false, "Complete loading of persistent requests after startup? (Uses more memory)",
+				"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.", new BooleanCallback() {
+
+					public boolean get() {
+						return lazyResume;
+					}
+
+					public void set(boolean val) throws InvalidConfigValueException {
+						synchronized(NodeClientCore.this) {
+							if(!startedResume)
+								throw new InvalidConfigValueException("Cannot be set until node has started up");
+							lazyResume = val;
+						}
+					}
+					
+		});
+		
+		lazyResume = nodeConfig.getBoolean("lazyResume");
+		
 	}
-	
-	
 
 	public void start(Config config) throws NodeInitException {
 		
@@ -255,7 +279,15 @@
 			public void run() {
 				System.out.println("Resuming persistent requests");
 				Logger.normal(this, "Resuming persistent requests");
-//				fcpServer.finishStart();
+				if(lazyResume) {
+					synchronized(NodeClientCore.this) {
+						startedResume = true;
+					}
+					fcpServer.finishStart();
+				} else
+					synchronized(NodeClientCore.this) {
+						startedResume = true;
+					}
 				persistentTempBucketFactory.completedInit();
 				System.out.println("Completed startup: All persistent requests resumed or restarted");
 				Logger.normal(this, "Completed startup: All persistent requests resumed or restarted");
@@ -796,4 +828,8 @@
 		if(logMINOR) Logger.minor(this, "Creating filter callback: "+uri+", "+cb);
 		return new GenericReadFilterCallback(uri, cb);
 	}
+	
+	public boolean lazyResume() {
+		return lazyResume;
+	}
 }

Modified: trunk/freenet/src/freenet/node/fcp/ClientRequest.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientRequest.java	2007-02-10 17:56:07 UTC (rev 11746)
+++ trunk/freenet/src/freenet/node/fcp/ClientRequest.java	2007-02-10 18:05:13 UTC (rev 11747)
@@ -157,20 +157,21 @@
 			Logger.minor(ClientRequest.class, rt.maxMemory()-rt.freeMemory()+" in use loading request "+clientName+" "+fs.get("Identifier"));
 		try {
 			String type = fs.get("Type");
+			boolean lazyResume = server.core.lazyResume();
 			if(type.equals("GET")) {
 				ClientGet cg = new ClientGet(fs, client);
-				client.register(cg, true);
-				cg.start();
+				client.register(cg, lazyResume);
+				if(!lazyResume) cg.start();
 				return cg;
 			} else if(type.equals("PUT")) {
 				ClientPut cp = new ClientPut(fs, client);
-				client.register(cp, true);
-				cp.start();
+				client.register(cp, lazyResume);
+				if(!lazyResume) cp.start();
 				return cp;
 			} else if(type.equals("PUTDIR")) {
 				ClientPutDir cp = new ClientPutDir(fs, client);
-				client.register(cp, true);
-				cp.start();
+				client.register(cp, lazyResume);
+				if(!lazyResume) cp.start();
 				return cp;
 			} else {
 				Logger.error(ClientRequest.class, "Unrecognized type: "+type);




More information about the cvs mailing list