Author: nextgens
Date: 2008-07-26 23:46:53 +0000 (Sat, 26 Jul 2008)
New Revision: 21431
Modified:
trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
trunk/freenet/src/freenet/node/NodeClientCore.java
trunk/freenet/src/freenet/node/NodeStats.java
trunk/freenet/src/freenet/node/RequestStarterGroup.java
Log:
Add some stats regarding outgoing requests
maybe I should merge it with the locally originating requests histogram
Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2008-07-26 22:44:42 UTC (rev 21430)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2008-07-26 23:46:53 UTC (rev 21431)
@@ -341,7 +341,7 @@
nextTableCell = overviewTableRow.addChild("td");
int[] outgoingLocalRequestCountArray = new int[1];
- int[] outgoingLocalRequestLocation =
stats.getOutgoingRequestLocation(outgoingLocalRequestCountArray);
+ int[] outgoingLocalRequestLocation =
stats.getOutgoingLocalRequestLocation(outgoingLocalRequestCountArray);
int outgoingLocalRequestsCount =
outgoingLocalRequestCountArray[0];
if(outgoingLocalRequestsCount > 0) {
@@ -350,6 +350,19 @@
HTMLNode nodeSpecialisationTable =
nodeSpecialisationInfobox.addChild("div", "class",
"infobox-content").addChild("table");
addSpecialisation(nodeSpecialisationTable,
myLocation, outgoingLocalRequestsCount, outgoingLocalRequestLocation);
}
+
+ overviewTableRow = overviewTable.addChild("tr");
+ nextTableCell = overviewTableRow.addChild("td",
"class", "first");
+ int[] outgoingRequestCountArray = new int[1];
+ int[] outgoingRequestLocation =
stats.getOutgoingRequestLocation(outgoingRequestCountArray);
+ int outgoingRequestsCount =
outgoingRequestCountArray[0];
+
+ if(outgoingLocalRequestsCount > 0) {
+ HTMLNode nodeSpecialisationInfobox =
nextTableCell.addChild("div", "class", "infobox");
+ nodeSpecialisationInfobox.addChild("div",
"class", "infobox-header", "Outgoing\u00a0Request\u00a0Distribution");
+ HTMLNode nodeSpecialisationTable =
nodeSpecialisationInfobox.addChild("div", "class",
"infobox-content").addChild("table");
+ addSpecialisation(nodeSpecialisationTable,
myLocation, outgoingRequestsCount, outgoingRequestLocation);
+ }
}
this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2008-07-26 22:44:42 UTC
(rev 21430)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2008-07-26 23:46:53 UTC
(rev 21431)
@@ -554,7 +554,7 @@
(status ==
RequestSender.GET_OFFER_VERIFY_FAILURE))) {
long rtt = System.currentTimeMillis() -
startTime;
if(!rejectedOverload)
-
requestStarters.requestCompleted(false, false);
+
requestStarters.requestCompleted(false, false, key.getNodeKey());
// Count towards RTT even if got a
RejectedOverload - but not if timed out.
requestStarters.chkRequestThrottle.successfulCompletion(rtt);
}
@@ -671,7 +671,7 @@
long rtt = System.currentTimeMillis() -
startTime;
if(!rejectedOverload)
-
requestStarters.requestCompleted(true, false);
+
requestStarters.requestCompleted(true, false, key.getNodeKey());
// Count towards RTT even if got a
RejectedOverload - but not if timed out.
requestStarters.sskRequestThrottle.successfulCompletion(rtt);
}
@@ -794,7 +794,7 @@
// RejectedOverload requests count towards RTT
(timed out ones don't).
requestStarters.chkInsertThrottle.successfulCompletion(len);
- requestStarters.requestCompleted(false, true);
+ requestStarters.requestCompleted(false, true,
block.getKey());
}
}
@@ -903,7 +903,7 @@
// It worked!
long endTime = System.currentTimeMillis();
long rtt = endTime - startTime;
- requestStarters.requestCompleted(true, true);
+ requestStarters.requestCompleted(true, true,
block.getKey());
requestStarters.sskInsertThrottle.successfulCompletion(rtt);
}
}
Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java 2008-07-26 22:44:42 UTC
(rev 21430)
+++ trunk/freenet/src/freenet/node/NodeStats.java 2008-07-26 23:46:53 UTC
(rev 21431)
@@ -56,9 +56,11 @@
/** Locations of incoming requests */
private final int[] incomingRequestsByLoc = new int[10];
private int incomingRequestsAccounted = 0;
- /** Locations of outoing requests */
+ /** Locations of outgoing requests */
private final int[] outgoingLocalRequestByLoc = new int[10];
private int outgoingLocalRequestsAccounted = 0;
+ private final int[] outgoingRequestByLoc = new int[10];
+ private int outgoingRequestsAccounted = 0;
private final Node node;
private MemoryChecker myMemoryChecker;
@@ -1703,7 +1705,7 @@
}
}
- public int[] getOutgoingRequestLocation(int[] retval) {
+ public int[] getOutgoingLocalRequestLocation(int[] retval) {
int[] result = new int[outgoingLocalRequestByLoc.length];
synchronized(outgoingLocalRequestByLoc) {
System.arraycopy(outgoingLocalRequestByLoc, 0, result,
0, outgoingLocalRequestByLoc.length);
@@ -1712,4 +1714,23 @@
return result;
}
+
+ public void reportOutgoingRequestLocation(double loc) {
+ assert((loc > 0) && (loc < 1.0));
+
+ synchronized(outgoingRequestByLoc) {
+
outgoingRequestByLoc[(int)Math.floor(loc*outgoingRequestByLoc.length)]++;
+ outgoingRequestsAccounted++;
+ }
+ }
+
+ public int[] getOutgoingRequestLocation(int[] retval) {
+ int[] result = new int[outgoingRequestByLoc.length];
+ synchronized(outgoingRequestByLoc) {
+ System.arraycopy(outgoingRequestByLoc, 0, result, 0,
outgoingRequestByLoc.length);
+ retval[0] = outgoingRequestsAccounted;
+ }
+
+ return result;
+ }
}
Modified: trunk/freenet/src/freenet/node/RequestStarterGroup.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestStarterGroup.java 2008-07-26
22:44:42 UTC (rev 21430)
+++ trunk/freenet/src/freenet/node/RequestStarterGroup.java 2008-07-26
23:46:53 UTC (rev 21431)
@@ -7,6 +7,7 @@
import freenet.config.Config;
import freenet.config.SubConfig;
import freenet.crypt.RandomSource;
+import freenet.keys.Key;
import freenet.support.Logger;
import freenet.support.SimpleFieldSet;
import freenet.support.TimeUtil;
@@ -34,9 +35,10 @@
public final ClientRequestScheduler sskFetchScheduler;
public final ClientRequestScheduler sskPutScheduler;
+ private final NodeStats stats;
RequestStarterGroup(Node node, NodeClientCore core, int portNumber,
RandomSource random, Config config, SimpleFieldSet fs) {
SubConfig schedulerConfig = new SubConfig("node.scheduler",
config);
- NodeStats stats = core.nodeStats;
+ this.stats = core.nodeStats;
throttleWindow = new ThrottleWindowManager(2.0, fs == null ?
null : fs.subset("ThrottleWindow"), node);
throttleWindowCHK = new ThrottleWindowManager(2.0, fs == null ?
null : fs.subset("ThrottleWindowCHK"), node);
@@ -139,10 +141,11 @@
return sskInsertThrottle;
}
- public void requestCompleted(boolean isSSK, boolean isInsert) {
+ public void requestCompleted(boolean isSSK, boolean isInsert, Key key) {
throttleWindow.requestCompleted();
(isSSK ? throttleWindowSSK :
throttleWindowCHK).requestCompleted();
(isInsert ? throttleWindowInsert :
throttleWindowRequest).requestCompleted();
+ stats.reportOutgoingRequestLocation(key.toNormalizedDouble());
}
public void rejectedOverload(boolean isSSK, boolean isInsert) {