Author: toad
Date: 2006-08-11 00:15:09 +0000 (Fri, 11 Aug 2006)
New Revision: 10037
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/PeerNodeStatus.java
Log:
Collect a new stat: probability of locally rejecting a request (or timing out)
for each node.
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-10 22:40:48 UTC (rev 10036)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-11 00:15:09 UTC (rev 10037)
@@ -280,6 +280,8 @@
if (advancedEnabled) {
peerTableHeaderRow.addChild("th", "Location");
peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title",
"style" }, new String[] { "Temporarily disconnected. Other node busy? Wait
time(s) remaining/total", "border-bottom: 1px dotted; cursor: help;" },
"Backoff");
+
+
peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title",
"style" }, new String[] { "Probability of the node rejecting a request due to
overload or causing a timeout.", "border-bottom: 1px dotted; cursor: help;" },
"Overload Probability");
}
peerTableHeaderRow.addChild("th").addChild("span", new
String[] { "title", "style" }, new String[] { "How long since the node
connected or was last seen", "border-bottom: 1px dotted; cursor: help;" },
"Connected\u00a0/\u00a0Idle");
@@ -336,6 +338,9 @@
}
backoffCell.addChild("#", " " +
String.valueOf(backoff / 1000) + "/" +
String.valueOf(peerNodeStatus.getRoutingBackoffLength() / 1000));
backoffCell.addChild("#",
(peerNodeStatus.getLastBackoffReason() == null) ? "" : ("/" +
(peerNodeStatus.getLastBackoffReason())));
+
+ HTMLNode pRejectCell =
peerRow.addChild("td", "class", "peer-backoff"); // FIXME
+ pRejectCell.addChild("#",
fix1.format(peerNodeStatus.getPReject()));
}
// idle column
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-08-10 22:40:48 UTC
(rev 10036)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-08-11 00:15:09 UTC
(rev 10037)
@@ -42,6 +42,7 @@
import freenet.support.Logger;
import freenet.support.SimpleFieldSet;
import freenet.support.WouldBlockException;
+import freenet.support.math.BootstrappingDecayingRunningAverage;
import freenet.support.math.RunningAverage;
import freenet.support.math.SimpleRunningAverage;
import freenet.support.math.TimeDecayingRunningAverage;
@@ -259,6 +260,9 @@
/** True if we want to allow LAN/localhost addresses. */
private boolean allowLocalAddresses;
+ /** Average proportion of requests which are rejected or timed out */
+ private TimeDecayingRunningAverage pRejected;
+
/**
* Create a PeerNode from a SimpleFieldSet containing a
* node reference for one. This must contain the following
@@ -400,8 +404,10 @@
pingAverage =
new TimeDecayingRunningAverage(1, 60000 /* should be
significantly longer than a typical transfer */, 0, Long.MAX_VALUE);
+ // TDRA for probability of rejection
+ pRejected =
+ new TimeDecayingRunningAverage(0, 60000, 0.0, 1.0);
-
// ARK stuff.
parseARK(fs, true);
@@ -1875,7 +1881,8 @@
* Back off this node for a while.
*/
public void localRejectedOverload(String reason) {
- Logger.minor(this, "Local rejected overload on "+this);
+ pRejected.report(1.0);
+ Logger.minor(this, "Local rejected overload on "+this+" :
pRejected="+pRejected.currentValue());
long now = System.currentTimeMillis();
Peer peer = getPeer();
reportBackoffStatus(now);
@@ -1906,7 +1913,8 @@
* Reset routing backoff.
*/
public void successNotOverload() {
- Logger.minor(this, "Success not overload on "+this);
+ pRejected.report(0.0);
+ Logger.minor(this, "Success not overload on "+this+" :
pRejected="+pRejected.currentValue());
Peer peer = getPeer();
long now = System.currentTimeMillis();
reportBackoffStatus(now);
@@ -1929,6 +1937,14 @@
final LRUHashtable pingsSentTimes = new LRUHashtable();
long pingNumber;
final RunningAverage pingAverage;
+
+ /**
+ * @return The probability of a request sent to this peer being
rejected (locally)
+ * due to overload, or timing out after being accepted.
+ */
+ public double getPRejected() {
+ return pRejected.currentValue();
+ }
public void sendPing() {
long pingNo;
Modified: trunk/freenet/src/freenet/node/PeerNodeStatus.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNodeStatus.java 2006-08-10 22:40:48 UTC
(rev 10036)
+++ trunk/freenet/src/freenet/node/PeerNodeStatus.java 2006-08-11 00:15:09 UTC
(rev 10037)
@@ -66,6 +66,8 @@
private Map localMessagesSent;
private final int hashCode;
+
+ private final double pReject;
public PeerNodeStatus(PeerNode peerNode) {
this.name = peerNode.getName();
@@ -94,6 +96,7 @@
this.localMessagesReceived = new
Hashtable(peerNode.getLocalNodeReceivedMessagesFromStatistic());
this.localMessagesSent = new
Hashtable(peerNode.getLocalNodeSentMessagesToStatistic());
this.hashCode = peerNode.hashCode;
+ this.pReject = peerNode.getPRejected();
}
/**
@@ -278,4 +281,8 @@
public int hashCode() {
return hashCode;
}
+
+ public double getPReject() {
+ return pReject;
+ }
}