Author: toad
Date: 2006-09-02 17:26:48 +0000 (Sat, 02 Sep 2006)
New Revision: 10362
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
trunk/freenet/src/freenet/io/comm/DummyPeerContext.java
trunk/freenet/src/freenet/io/comm/IOStatisticCollector.java
trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
trunk/freenet/src/freenet/node/FNPPacketMangler.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/PeerNodeStatus.java
Log:
Track total in/out bytes for each PeerNode, show on Darknet page in advanced
mode.
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-09-02 17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-09-02 17:26:48 UTC (rev 10362)
@@ -325,6 +325,10 @@
peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title",
"style" }, new String[] { "How long since the node was connected or last seen",
"border-bottom: 1px dotted; cursor: help;" }, "Connected\u00a0/\u00a0Idle");
peerTableHeaderRow.addChild("th").addChild("span", new String[] { "title",
"style" }, new String[] { "A private note concerning this peer",
"border-bottom: 1px dotted; cursor: help;" }, "Private Note");
+ if(advancedEnabled) {
+ peerTableHeaderRow.addChild("th",
"Total\u00a0Traffic\u00a0(in/out)");
+ }
+
for (int peerIndex = 0, peerCount =
peerNodeStatuses.length; peerIndex < peerCount; peerIndex++) {
PeerNodeStatus peerNodeStatus =
peerNodeStatuses[peerIndex];
HTMLNode peerRow =
peerTable.addChild("tr");
@@ -396,6 +400,8 @@
// private darknet node comment note
column
peerRow.addChild("td", "class",
"peer-private-darknet-comment-note").addChild("input", new String[] { "type",
"name", "size", "maxlength", "value" }, new String[] { "text",
"peerPrivateNote_" + peerNodeStatus.hashCode(), "16", "250",
peerNodeStatus.getPrivateDarknetCommentNote() });
+ peerRow.addChild("td", "class",
"peer-idle" /* FIXME */).addChild("#",
SizeUtil.formatSize(peerNodeStatus.getTotalInputBytes())+"/"+SizeUtil.formatSize(peerNodeStatus.getTotalOutputBytes()));
+
if
(path.endsWith("displaymessagetypes.html")) {
HTMLNode messageCountRow =
peerTable.addChild("tr", "class", "message-status");
messageCountRow.addChild("td",
"colspan", "2");
Modified: trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
2006-09-02 17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/clients/http/filter/CSSTokenizerFilter.java
2006-09-02 17:26:48 UTC (rev 10362)
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.3.5 on 01/09/06 22:59 */
+/* The following code was generated by JFlex 1.3.5 on 02/09/06 17:20 */
package freenet.clients.http.filter;
import java.io.*;
@@ -11,7 +11,7 @@
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.3.5
- * on 01/09/06 22:59 from the specification file
+ * on 02/09/06 17:20 from the specification file
* <tt>file:/usr/src/cvs/eclipse-workspace/Freenet
0.7/src/freenet/clients/http/filter/CSSTokenizerFilter.jflex</tt>
*/
class CSSTokenizerFilter {
Modified: trunk/freenet/src/freenet/io/comm/DummyPeerContext.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/DummyPeerContext.java 2006-09-02
17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/io/comm/DummyPeerContext.java 2006-09-02
17:26:48 UTC (rev 10362)
@@ -29,4 +29,8 @@
public boolean isConnected() {
return false;
}
+
+ public void reportOutgoingBytes(int length) {
+ // Ignore
+ }
}
Modified: trunk/freenet/src/freenet/io/comm/IOStatisticCollector.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/IOStatisticCollector.java 2006-09-02
17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/io/comm/IOStatisticCollector.java 2006-09-02
17:26:48 UTC (rev 10362)
@@ -51,8 +51,10 @@
targets.put(key, entry);
}
entry.addData((inbytes>0)?inbytes:0, (outbytes>0)?outbytes:0);
- totalbytesout += (outbytes>0)?outbytes:0;
- totalbytesin += (inbytes>0)?inbytes:0;
+ synchronized(this) {
+ totalbytesout += (outbytes>0)?outbytes:0;
+ totalbytesin += (inbytes>0)?inbytes:0;
+ }
}
public static void dumpInfo() {
@@ -71,8 +73,10 @@
private long[] _getTotalIO() {
long ret[] = new long[2];
- ret[0] = totalbytesout;
- ret[1] = totalbytesin;
+ synchronized(this) {
+ ret[0] = totalbytesout;
+ ret[1] = totalbytesin;
+ }
return ret;
}
Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2006-09-02
17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2006-09-02
17:26:48 UTC (rev 10362)
@@ -192,7 +192,6 @@
DatagramPacket packet = getPacket();
// Check for timedout _filters
removeTimedOutFilters();
- // Check for matched _filters
if (packet != null) {
long startTime = System.currentTimeMillis();
Peer peer = new Peer(packet.getAddress(),
packet.getPort());
@@ -566,6 +565,7 @@
// TODO: keep?
IOStatisticCollector.addInfo(packet.getAddress() + ":" +
packet.getPort(),
0, packet.getLength());
+
try {
_sock.send(packet);
} catch (IOException e) {
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-09-02
17:01:50 UTC (rev 10361)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-09-02
17:26:48 UTC (rev 10362)
@@ -185,6 +185,7 @@
if(Arrays.equals(realHash, hash)) {
// Got one
processDecryptedAuth(payload, opn, peer);
+ opn.reportIncomingBytes(length);
return true;
} else {
if(logMINOR) Logger.minor(this, "Incorrect hash in tryProcessAuth
for "+peer+" (length="+dataLength+"): \nreal
hash="+HexUtil.bytesToHex(realHash)+"\n bad hash="+HexUtil.bytesToHex(hash));
@@ -398,6 +399,7 @@
private void sendPacket(byte[] data, Peer replyTo, PeerNode pn, int
alreadyReportedBytes) throws LocalAddressException {
usm.sendPacket(data, replyTo, pn.allowLocalAddresses());
+ pn.reportOutgoingBytes(data.length);
node.outputThrottle.forceGrab(data.length - alreadyReportedBytes);
}
@@ -631,6 +633,7 @@
// Lots more to do yet!
processDecryptedData(plaintext, seqNumber, tracker, length -
plaintext.length);
+ tracker.pn.reportIncomingBytes(length);
return true;
}
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-09-02 17:01:50 UTC
(rev 10361)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-09-02 17:26:48 UTC
(rev 10362)
@@ -286,7 +286,13 @@
/** Queued-to-send N2NTM extra peer data file numbers */
private Vector queuedToSendN2NTMExtraPeerDataFileNumbers;
+
+ /** Total low-level input bytes */
+ private long totalBytesIn;
+ /** Total low-level output bytes */
+ private long totalBytesOut;
+
private static boolean logMINOR;
/**
@@ -2826,4 +2832,20 @@
public synchronized boolean noContactDetails() {
return handshakeIPs == null || handshakeIPs.length == 0;
}
+
+ public synchronized void reportIncomingBytes(int length) {
+ totalBytesIn += length;
+ }
+
+ public synchronized void reportOutgoingBytes(int length) {
+ totalBytesOut += length;
+ }
+
+ public synchronized long getTotalInputBytes() {
+ return totalBytesIn;
+ }
+
+ public synchronized long getTotalOutputBytes() {
+ return totalBytesOut;
+ }
}
Modified: trunk/freenet/src/freenet/node/PeerNodeStatus.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNodeStatus.java 2006-09-02 17:01:50 UTC
(rev 10361)
+++ trunk/freenet/src/freenet/node/PeerNodeStatus.java 2006-09-02 17:26:48 UTC
(rev 10362)
@@ -74,6 +74,10 @@
private final double pReject;
private final String privateDarknetCommentNote;
+
+ private long totalBytesIn;
+
+ private long totalBytesOut;
public PeerNodeStatus(PeerNode peerNode) {
this.name = peerNode.getName();
@@ -106,6 +110,8 @@
this.hashCode = peerNode.hashCode;
this.pReject = peerNode.getPRejected();
this.privateDarknetCommentNote =
peerNode.getPrivateDarknetCommentNote();
+ this.totalBytesIn = peerNode.getTotalInputBytes();
+ this.totalBytesOut = peerNode.getTotalOutputBytes();
}
/**
@@ -315,4 +321,12 @@
public String getPrivateDarknetCommentNote() {
return privateDarknetCommentNote;
}
+
+ public long getTotalInputBytes() {
+ return totalBytesIn;
+ }
+
+ public long getTotalOutputBytes() {
+ return totalBytesOut;
+ }
}