[freenet-cvs] r11686 - in trunk/freenet/src/freenet: clients/http node

toad at freenetproject.org toad at freenetproject.org
Wed Feb 7 15:53:36 UTC 2007


Author: toad
Date: 2007-02-07 15:53:35 +0000 (Wed, 07 Feb 2007)
New Revision: 11686

Modified:
   trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
   trunk/freenet/src/freenet/node/Node.java
Log:
aku at frost: Add button for Berkeley DB stats dump to wrapper.log

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2007-02-07 15:34:33 UTC (rev 11685)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2007-02-07 15:53:35 UTC (rev 11686)
@@ -128,6 +128,13 @@
 			HTMLNode threadDumpForm = ctx.addFormChild(ctx.getPageMaker().getContentNode(infobox), "/", "threadDumpForm");
 			threadDumpForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "getThreadDump", "Generate a Thread Dump" });
 		}
+
+		// BDB statistics dump 
+		if(advancedEnabled) {
+			HTMLNode JEinfobox = contentNode.addChild(ctx.getPageMaker().getInfobox("Dump Database runtime statistics to wrapper.log"));
+			HTMLNode JEStatsForm = ctx.addFormChild(ctx.getPageMaker().getContentNode(JEinfobox), "/", "JEStatsForm");
+			JEStatsForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "getJEStatsDump", "Generate a JE Dump" });
+		}
 		
 		double swaps = (double)node.getSwaps();
 		double noSwaps = (double)node.getNoSwaps();

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java	2007-02-07 15:34:33 UTC (rev 11685)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java	2007-02-07 15:53:35 UTC (rev 11686)
@@ -129,6 +129,22 @@
 			}
 			this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
 			return;
+		}else if(request.isPartSet("getJEStatsDump")) {
+			if(noPassword) {
+				redirectToRoot(ctx);
+				return;
+			}
+			HTMLNode pageNode = ctx.getPageMaker().getPageNode("Get JE Statistics");
+			HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+			HTMLNode infobox = contentNode.addChild(ctx.getPageMaker().getInfobox("Database Statistics"));
+
+			System.out.println(">>>>>>>>>>>>>>>>>>>>>>> START DATABASE STATS <<<<<<<<<<<<<<<<<<<<<<<");
+			node.JEStatsDump();
+			System.out.println(">>>>>>>>>>>>>>>>>>>>>>>  END DATABASE STATS  <<<<<<<<<<<<<<<<<<<<<<<");
+
+			ctx.getPageMaker().getContentNode(infobox).addChild("#", "Runtime database statistics have been written to the wrapper logfile");
+			this.writeReply(ctx, 200, "text/html", "OK", pageNode.generate());
+			return;
 		}else if (request.isPartSet("addbookmark")) {
 			if(noPassword) {
 				redirectToRoot(ctx);

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java	2007-02-07 15:34:33 UTC (rev 11685)
+++ trunk/freenet/src/freenet/node/Node.java	2007-02-07 15:53:35 UTC (rev 11686)
@@ -35,6 +35,7 @@
 import com.sleepycat.je.Environment;
 import com.sleepycat.je.EnvironmentConfig;
 import com.sleepycat.je.EnvironmentMutableConfig;
+import com.sleepycat.je.StatsConfig;
 
 import freenet.client.FetcherContext;
 import freenet.config.FreenetFilePersistentConfig;
@@ -274,6 +275,7 @@
 	/** The maximum size of the datastore. Kept to avoid rounding turning 5G into 5368698672 */
 	private long maxTotalDatastoreSize;
 	
+	private StatsConfig statsConf;
 	/* These are private because must be protected by synchronized(this) */
 	private final Environment storeEnvironment;
 	private final EnvironmentMutableConfig envMutableConfig;
@@ -1191,6 +1193,9 @@
 			throw new NodeInitException(EXIT_STORE_OTHER, e.getMessage());			
 		}
 
+		statsConf = new StatsConfig();
+		statsConf.setClear(true);
+
 		storeShutdownHook = new SemiOrderedShutdownHook();
 		Runtime.getRuntime().addShutdownHook(storeShutdownHook);
 		
@@ -3475,4 +3480,13 @@
 	public int getPortNumber() {
 		return portNumber;
 	}
+
+	public void JEStatsDump() {
+		try { 
+			System.out.println(storeEnvironment.getStats(statsConf));
+		}
+		catch(DatabaseException e) {
+			System.out.println("Failed to get stats from JE environment: " + e);
+		}
+	}
 }




More information about the cvs mailing list