Author: ljn1981
Date: 2006-09-28 13:10:30 +0000 (Thu, 28 Sep 2006)
New Revision: 10536

Modified:
   trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
   trunk/freenet/src/freenet/node/LocationManager.java
   trunk/freenet/src/freenet/node/Node.java
Log:
More location and swap things for the statistics page.
 * locChangeSession
 * locChangePerSwap
 * locChangePerMinute
 * swapsPerMinute
 * noSwapsPerMinute
 * swapsPerNoSwaps

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2006-09-28 01:04:40 UTC (rev 10535)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2006-09-28 13:10:30 UTC (rev 10536)
@@ -266,11 +266,28 @@
                                int swapsRejectedRateLimit = 
node.getSwapsRejectedRateLimit();
                                int swapsRejectedLoop = 
node.getSwapsRejectedLoop();
                                int swapsRejectedRecognizedID = 
node.getSwapsRejectedRecognizedID();
+                               double locChangeSession = 
node.getLocationChangeSession();

                                HTMLNode locationSwapInfobox = 
nextTableCell.addChild("div", "class", "infobox");
                                locationSwapInfobox.addChild("div", "class", 
"infobox-header", "Location swaps");
                                HTMLNode locationSwapInfoboxContent = 
locationSwapInfobox.addChild("div", "class", "infobox-content");
                                HTMLNode locationSwapList = 
locationSwapInfoboxContent.addChild("ul");
+                               locationSwapList.addChild("li", 
"locChangeSession:\u00a0" + locChangeSession);
+                               if (swaps > 0) {
+                                       locationSwapList.addChild("li", 
"locChangePerSwap:\u00a0" + (locChangeSession/swaps));
+                               }
+                               if (nodeUptimeSeconds >= 60) {
+                                       locationSwapList.addChild("li", 
"locChangePerMinute:\u00a0" + (locChangeSession/(nodeUptimeSeconds/60)));
+                               }
+                               if ((swaps > 0) && (nodeUptimeSeconds >= 60)) {
+                                       locationSwapList.addChild("li", 
"swapsPerMinute:\u00a0" + (double)(swaps/(double)(nodeUptimeSeconds/60)));
+                               }
+                               if ((noSwaps > 0) && (nodeUptimeSeconds >= 60)) 
{
+                                       locationSwapList.addChild("li", 
"noSwapsPerMinute:\u00a0" + (double)(noSwaps/(double)(nodeUptimeSeconds/60)));
+                               }
+                               if ((swaps > 0) && (noSwaps > 0)) {
+                                       locationSwapList.addChild("li", 
"swapsPerNoSwaps:\u00a0" + (double)(swaps/noSwaps));
+                               }
                                locationSwapList.addChild("li", "swaps:\u00a0" 
+ swaps);
                                locationSwapList.addChild("li", 
"noSwaps:\u00a0" + noSwaps);
                                locationSwapList.addChild("li", 
"startedSwaps:\u00a0" + startedSwaps);

Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2006-09-28 01:04:40 UTC 
(rev 10535)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2006-09-28 13:10:30 UTC 
(rev 10536)
@@ -63,6 +63,7 @@
     }

     Location loc;
+    double locChangeSession = 0.0;

     /**
      * @return The current Location of this node.
@@ -77,6 +78,14 @@
     public void setLocation(Location l) {
         this.loc = l;
     }
+    
+    public void updateLocationChangeSession(double l) {
+               if (l < this.loc.getValue()) {
+                       this.locChangeSession -= (this.loc.getValue() - l);
+               } else {
+                       this.locChangeSession += (l - this.loc.getValue());
+               }
+    }

     /**
      * Start a thread to send FNPSwapRequests every second when
@@ -298,6 +307,7 @@
             if(shouldSwap(myLoc, friendLocs, hisLoc, hisFriendLocs, random ^ 
hisRandom)) {
                 timeLastSuccessfullySwapped = System.currentTimeMillis();
                 // Swap
+                updateLocationChangeSession(hisLoc);
                 loc.setValue(hisLoc);
                 if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <-> 
"+hisLoc+" - "+uid);
                 swaps++;
@@ -469,6 +479,7 @@
                 if(shouldSwap(myLoc, friendLocs, hisLoc, hisFriendLocs, random 
^ hisRandom)) {
                     timeLastSuccessfullySwapped = System.currentTimeMillis();
                     // Swap
+                    updateLocationChangeSession(hisLoc);
                     loc.setValue(hisLoc);
                     if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <-> 
"+hisLoc+" - "+uid);
                     swaps++;

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-09-28 01:04:40 UTC (rev 
10535)
+++ trunk/freenet/src/freenet/node/Node.java    2006-09-28 13:10:30 UTC (rev 
10536)
@@ -2872,6 +2872,10 @@
                return lm.loc.getValue();
        }

+       public double getLocationChangeSession() {
+               return lm.locChangeSession;
+       }
+       
        public boolean isAdvancedDarknetEnabled() {
                return clientCore.isAdvancedDarknetEnabled();
        }


Reply via email to