Author: toad
Date: 2008-03-01 23:13:55 +0000 (Sat, 01 Mar 2008)
New Revision: 18308

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
   trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
   trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
Log:
Track bytes used by Update Over Mandatory.

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2008-03-01 23:11:34 UTC (rev 18307)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2008-03-01 23:13:55 UTC (rev 18308)
@@ -812,6 +812,7 @@
                        activityList.addChild("li", l10n("swapOutput", "total", 
SizeUtil.formatSize(node.nodeStats.getSwappingTotalBytesSent(), true)));
                        activityList.addChild("li", l10n("authBytes", "total", 
SizeUtil.formatSize(node.nodeStats.getTotalAuthBytesSent(), true)));
                        activityList.addChild("li", l10n("resendBytes", 
"total", SizeUtil.formatSize(node.nodeStats.getResendBytesSent(), true)));
+                       activityList.addChild("li", l10n("uomBytes", "total",  
SizeUtil.formatSize(node.nodeStats.getUOMBytesSent(), true)));
                }
        }


Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-03-01 
23:11:34 UTC (rev 18307)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-03-01 
23:13:55 UTC (rev 18308)
@@ -1001,6 +1001,7 @@
 StatisticsToadlet.totalInput=Total Input: ${total} (${rate}/sec)
 StatisticsToadlet.totalOutput=Total Output: ${total} (${rate}/sec)
 StatisticsToadlet.transferringRequests=Transferring Requests: sending 
${senders}, receiving ${receivers}
+StatisticsToadlet.uomBytes=Updater Output: ${total}
 StatisticsToadlet.usedMemory=Used Java memory: ${memory}
 StatisticsToadlet.versionTitle=Node Version Information
 SymlinkerToadlet.symlinks=Symlinks in ToadletServer

Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java       2008-03-01 23:11:34 UTC 
(rev 18307)
+++ trunk/freenet/src/freenet/node/NodeStats.java       2008-03-01 23:13:55 UTC 
(rev 18308)
@@ -1161,4 +1161,13 @@
                return resendBytesSent;
        }

+       private long uomBytesSent;
+       
+       public synchronized void reportUOMBytesSent(int x) {
+               uomBytesSent += x;
+       }
+       
+       public long getUOMBytesSent() {
+               return uomBytesSent;
+       }
 }

Modified: trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java       
2008-03-01 23:11:34 UTC (rev 18307)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java       
2008-03-01 23:13:55 UTC (rev 18308)
@@ -9,6 +9,7 @@
 import freenet.config.Config;
 import freenet.config.InvalidConfigValueException;
 import freenet.config.SubConfig;
+import freenet.io.comm.ByteCounter;
 import freenet.io.comm.DMT;
 import freenet.io.comm.Message;
 import freenet.io.comm.NotConnectedException;
@@ -189,7 +190,7 @@
                        if((!hasBeenBlown) && (mainUpdater == null || 
mainUpdater.getFetchedVersion() <= 0)) return;
                }
                try {
-                       peer.sendAsync(getUOMAnnouncement(), null, 0, null);
+                       peer.sendAsync(getUOMAnnouncement(), null, 0, ctr);
                } catch (NotConnectedException e) {
                        // Sad, but ignore it
                }
@@ -887,4 +888,20 @@
                return Math.max(0, REVOCATION_FETCH_TIMEOUT - (now - 
gotJarTime));
        }

+       final ByteCounter ctr = new ByteCounter() {
+
+               public void receivedBytes(int x) {
+                       // FIXME
+               }
+
+               public void sentBytes(int x) {
+                       node.nodeStats.reportUOMBytesSent(x);
+               }
+
+               public void sentPayload(int x) {
+                       node.nodeStats.reportUOMBytesSent(x);
+               }
+               
+       };
+       
 }

Modified: trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
2008-03-01 23:11:34 UTC (rev 18307)
+++ trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
2008-03-01 23:13:55 UTC (rev 18308)
@@ -172,7 +172,7 @@
                                                public void sent() {
                                                        // Cool
                                                }
-                                       }, 0, null);
+                                       }, 0, updateManager.ctr);

                                        // The reply message will start the 
transfer. It includes the revocation URI
                                        // so we can tell if anything wierd is 
happening.
@@ -275,7 +275,7 @@
                                                }
                                        }, REQUEST_MAIN_JAR_TIMEOUT);
                                }
-                       }, 0, null);
+                       }, 0, updateManager.ctr);
                } catch (NotConnectedException e) {
                        synchronized(this) {
                                nodesAskedSendMainJar.remove(source);
@@ -494,7 +494,7 @@

                final BulkTransmitter bt;
                try {
-                       bt = new BulkTransmitter(prb, source, uid, 
updateManager.node.outputThrottle, false, null);
+                       bt = new BulkTransmitter(prb, source, uid, 
updateManager.node.outputThrottle, false, updateManager.ctr);
                } catch (DisconnectedException e) {
                        Logger.error(this, "Peer "+source+" asked us for the 
blob file for the revocation key, then disconnected: "+e, e);
                        return true;
@@ -540,7 +540,7 @@
                                        return super.toString() + 
"("+uid+":"+source.getPeer()+")";
                                }

-                       }, 0, null);
+                       }, 0, updateManager.ctr);
                } catch (NotConnectedException e) {
                        Logger.error(this, "Peer "+source+" asked us for the 
blob file for the revocation key, then disconnected when we tried to send the 
UOMSendingRevocation: "+e, e);
                        return true;
@@ -624,7 +624,7 @@
                PartiallyReceivedBulk prb = new 
PartiallyReceivedBulk(updateManager.node.getUSM(), length, 
                                Node.PACKET_SIZE, raf, false);

-               final BulkReceiver br = new BulkReceiver(prb, source, uid, 
null);
+               final BulkReceiver br = new BulkReceiver(prb, source, uid, 
updateManager.ctr);

                updateManager.node.executor.execute(new Runnable() {

@@ -867,7 +867,7 @@

                final BulkTransmitter bt;
                try {
-                       bt = new BulkTransmitter(prb, source, uid, 
updateManager.node.outputThrottle, false, null);
+                       bt = new BulkTransmitter(prb, source, uid, 
updateManager.node.outputThrottle, false, updateManager.ctr);
                } catch (DisconnectedException e) {
                        Logger.error(this, "Peer "+source+" asked us for the 
blob file for the main jar, then disconnected: "+e, e);
                        return true;
@@ -914,7 +914,7 @@
                                        return super.toString() + 
"("+uid+":"+source.getPeer()+")";
                                }

-                       }, 0, null);
+                       }, 0, updateManager.ctr);
                } catch (NotConnectedException e) {
                        Logger.error(this, "Peer "+source+" asked us for the 
blob file for the main jar, then disconnected when we tried to send the 
UOMSendingMain: "+e, e);
                        return true;
@@ -1006,7 +1006,7 @@
                PartiallyReceivedBulk prb = new 
PartiallyReceivedBulk(updateManager.node.getUSM(), length, 
                                Node.PACKET_SIZE, raf, false);

-               final BulkReceiver br = new BulkReceiver(prb, source, uid, 
null);
+               final BulkReceiver br = new BulkReceiver(prb, source, uid, 
updateManager.ctr);

                updateManager.node.executor.execute(new Runnable() {



Reply via email to