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

nextgens at freenetproject.org nextgens at freenetproject.org
Fri Feb 15 09:34:00 UTC 2008


Author: nextgens
Date: 2008-02-15 09:34:00 +0000 (Fri, 15 Feb 2008)
New Revision: 17932

Modified:
   trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/NodeStats.java
Log:
Add more stats on /stats (threadcounts by priority)

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2008-02-15 09:17:00 UTC (rev 17931)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java	2008-02-15 09:34:00 UTC (rev 17932)
@@ -290,6 +290,10 @@
 			HTMLNode unclaimedFIFOMessageCountsInfobox = nextTableCell.addChild("div", "class", "infobox");
 			drawUnclaimedFIFOMessageCountsBox(unclaimedFIFOMessageCountsInfobox);
 
+						
+			HTMLNode threadsPriorityInfobox = nextTableCell.addChild("div", "class", "infobox");
+			drawThreadPriorityStatsBox(threadsPriorityInfobox);
+			
 			nextTableCell = overviewTableRow.addChild("td");
 
 			// thread usage box
@@ -382,7 +386,26 @@
 		jvmStatsList.addChild("li", l10n("osArch", "arch", System.getProperty("os.arch")));
 		
 	}
+	
+	private void drawThreadPriorityStatsBox(HTMLNode node) {
+		
+		node.addChild("div", "class", "infobox-header", l10n("threadsByPriority"));
+		HTMLNode threadsInfoboxContent = node.addChild("div", "class", "infobox-content");
+		int[] activeThreadsByPriority = stats.getActiveThreadsByPriority();
+		
+		HTMLNode threadsByPriorityTable = threadsInfoboxContent.addChild("table", "border", "0");
+		HTMLNode row = threadsByPriorityTable.addChild("tr");
 
+		row.addChild("th", l10n("Priority"));
+		row.addChild("th", l10n("Amount"));		
+		
+		for(int i=0; i<activeThreadsByPriority.length; i++) {
+			row = threadsByPriorityTable.addChild("tr");
+			row.addChild("th", String.valueOf(i));
+			row.addChild("th", String.valueOf(activeThreadsByPriority[i]));		
+		}
+	}
+
 	private void drawStoreSizeBox(HTMLNode storeSizeInfobox, long nodeUptimeSeconds) {
 		
 		storeSizeInfobox.addChild("div", "class", "infobox-header", "Datastore");

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties	2008-02-15 09:17:00 UTC (rev 17931)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties	2008-02-15 09:34:00 UTC (rev 17932)
@@ -983,6 +983,9 @@
 StatisticsToadlet.statisticGatheringTitle=Statistics Gathering
 StatisticsToadlet.threadDumpButton=Generate a Thread Dump
 StatisticsToadlet.threads=Running threads: ${running}/${max}
+StatisticsToadlet.threadsByPriority=Threads by priority
+StatisticsToadlet.priority=Priority
+StatisticsToadlet.amount=Amount
 StatisticsToadlet.totalInput=Total Input: ${total} (${rate}/sec)
 StatisticsToadlet.totalOutput=Total Output: ${total} (${rate}/sec)
 StatisticsToadlet.transferringRequests=Transferring Requests: sending ${senders}, receiving ${receivers}

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java	2008-02-15 09:17:00 UTC (rev 17931)
+++ trunk/freenet/src/freenet/node/NodeStats.java	2008-02-15 09:34:00 UTC (rev 17932)
@@ -22,6 +22,7 @@
 import freenet.support.api.BooleanCallback;
 import freenet.support.api.IntCallback;
 import freenet.support.api.LongCallback;
+import freenet.support.io.NativeThread;
 import freenet.support.math.DecayingKeyspaceAverage;
 import freenet.support.math.RunningAverage;
 import freenet.support.math.TimeDecayingRunningAverage;
@@ -163,6 +164,7 @@
 	
 	// ThreadCounting stuffs
 	public final ThreadGroup rootThreadGroup;
+	private int[] activeThreadsByPriorities = new int[NativeThread.JAVA_PRIO_RANGE];
 	private int threadLimit;
 	
 	// Free heap memory threshold stuffs
@@ -774,12 +776,16 @@
 
 	public int getActiveThreadCount() {
 		int waitingThreads = 0;
-		int[] toCount = node.executor.waitingThreads();
-		for(int i=0; i<toCount.length; i++)
-			waitingThreads += toCount[i];
+		activeThreadsByPriorities = node.executor.waitingThreads();
+		for(int i=0; i<activeThreadsByPriorities.length; i++)
+			waitingThreads += activeThreadsByPriorities[i];
 		
 		return rootThreadGroup.activeCount() - waitingThreads;
 	}
+	
+	public int[] getActiveThreadsByPriority() {
+		return activeThreadsByPriorities;
+	}
 
 	public int getThreadLimit() {
 		return threadLimit;




More information about the cvs mailing list