Author: odonata
Date: 2006-06-24 23:17:41 +0000 (Sat, 24 Jun 2006)
New Revision: 9379
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/PeerManager.java
Log:
Add metrics to allow us to judge how much miss routing
backoff we are experiencing and to track the percentage of nodes
backedoff when routing. Stats are only updated in advanced mode.
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-06-24 02:28:48 UTC (rev 9378)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-06-24 23:17:41 UTC (rev 9379)
@@ -7,6 +7,7 @@
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
+import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Enumeration;
@@ -99,6 +100,10 @@
int bwlimitDelayTime = (int) node.getBwlimitDelayTime();
int nodeAveragePingTime = (int) node.getNodeAveragePingTime();
int networkSizeEstimate = (int) node.getNetworkSizeEstimate( 0
);
+ DecimalFormat fix4 = new DecimalFormat("0.0000");
+ double missRoutingDistance =
node.MissRoutingDistance.currentValue();
+ DecimalFormat fix1 = new DecimalFormat("##0.0%");
+ double backedoffPercent = node.BackedoffPercent.currentValue();
String nodeUptimeString = timeIntervalToString(( now -
node.startupTime ) / 1000);
buf.append("<table class=\"column\"><tr><td class=\"first\">");
@@ -113,6 +118,8 @@
buf.append("<li>nodeAveragePingTime: ").append(nodeAveragePingTime).append("ms</li>");
buf.append("<li>networkSizeEstimate: ").append(networkSizeEstimate).append(" nodes</li>");
buf.append("<li>nodeUptime: ").append(nodeUptimeString).append("</li>");
+
buf.append("<li>missRoutingDistance: ").append(fix4.format(missRoutingDistance)).append("</li>");
+
buf.append("<li>backedoffPercent: ").append(fix1.format(backedoffPercent)).append("</li>");
buf.append("</ul></div>");
buf.append("</div>\n");
buf.append("</td><td>");
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-06-24 02:28:48 UTC (rev
9378)
+++ trunk/freenet/src/freenet/node/Node.java 2006-06-24 23:17:41 UTC (rev
9379)
@@ -639,6 +639,10 @@
// Debugging stuff
private static final boolean USE_RAM_PUBKEYS_CACHE = true;
+
+ // various metrics
+ public RunningAverage MissRoutingDistance = new
BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 500);
+ public RunningAverage BackedoffPercent = new
BootstrappingDecayingRunningAverage(0.0, 0.0, 1.0, 500);
/**
* Read all storable settings (identity etc) from the node file.
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2006-06-24 02:28:48 UTC
(rev 9378)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2006-06-24 23:17:41 UTC
(rev 9379)
@@ -377,10 +377,29 @@
}
/**
+ * FIXME
+ * This scans the same array 4 times. It would be better to scan once and
execute 4 callbacks...
+ * For this reason the metrics are only updated if advanced mode is enabled
+ */
+ public PeerNode closerPeer(PeerNode pn, HashSet routedTo, HashSet
notIgnored, double loc, boolean ignoreSelf) {
+ PeerNode best = _closerPeer(pn, routedTo, notIgnored, loc, ignoreSelf,
false);
+ if (node.getToadletContainer().isAdvancedDarknetEnabled()) {
+ PeerNode nbo = _closerPeer(pn, routedTo, notIgnored, loc,
ignoreSelf, true);
+ node.MissRoutingDistance.report(distance(best,
nbo.getLocation().getValue()));
+ int numberOfConnected =
node.getPeerNodeStatusSize(Node.PEER_NODE_STATUS_CONNECTED);
+ int numberOfRoutingBackedOff =
node.getPeerNodeStatusSize(Node.PEER_NODE_STATUS_ROUTING_BACKED_OFF);
+ if (numberOfRoutingBackedOff + numberOfConnected > 0 ) {
+ node.BackedoffPercent.report((double)
numberOfRoutingBackedOff / (double) (numberOfRoutingBackedOff +
numberOfConnected));
+ }
+ }
+ return best;
+ }
+
+ /**
* Find the peer, if any, which is closer to the target location
* than we are, and is not included in the provided set.
*/
- public PeerNode closerPeer(PeerNode pn, HashSet routedTo, HashSet
notIgnored, double loc, boolean ignoreSelf) {
+ private PeerNode _closerPeer(PeerNode pn, HashSet routedTo, HashSet
notIgnored, double loc, boolean ignoreSelf, boolean ignoreBackedOff) {
PeerNode[] peers = connectedPeers;
// No locking necessary. We won't modify it, and if another method
does, it will copy-and-assign.
Logger.minor(this, "Choosing closest peer:
connectedPeers="+peers.length);
@@ -405,7 +424,7 @@
Logger.minor(this, "Skipping (not connected): "+p.getPeer());
continue;
}
- if(p.isRoutingBackedOff()) {
+ if((!ignoreBackedOff) && p.isRoutingBackedOff()) {
Logger.minor(this, "Skipping (routing backed off):
"+p.getPeer());
continue;
}