Author: toad
Date: 2008-04-08 11:05:18 +0000 (Tue, 08 Apr 2008)
New Revision: 19068

Modified:
   trunk/freenet/src/freenet/node/LocationManager.java
Log:
Indicate random resets and resets from duplicated location in the location 
logfile

Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2008-04-07 21:37:58 UTC 
(rev 19067)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2008-04-08 11:05:18 UTC 
(rev 19068)
@@ -180,7 +180,7 @@
                                 }
                                 if(myFlag) {
                                     setLocation(node.random.nextDouble());
-                                    announceLocChange();
+                                    announceLocChange(true, true);
                                     node.writeNodeFile();
                                 }
                             } finally {
@@ -358,7 +358,7 @@
                 setLocation(hisLoc);
                 if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <-> 
"+hisLoc+" - "+uid);
                 swaps++;
-                announceLocChange();
+                announceLocChange(false, false);
                 node.writeNodeFile();
             } else {
                if(logMINOR) Logger.minor(this, "Didn't swap: "+myLoc+" <-> 
"+hisLoc+" - "+uid);
@@ -370,7 +370,7 @@
             // Randomise our location every 2*SWAP_RESET swap attempts, 
whichever way it went.
             if(node.random.nextInt(SWAP_RESET) == 0) {
                 setLocation(node.random.nextDouble());
-                announceLocChange();
+                announceLocChange(true, false);
                 node.writeNodeFile();
             }

@@ -548,7 +548,7 @@
                     setLocation(hisLoc);
                     if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <-> 
"+hisLoc+" - "+uid);
                     swaps++;
-                    announceLocChange();
+                    announceLocChange(false, false);
                     node.writeNodeFile();
                 } else {
                        if(logMINOR) Logger.minor(this, "Didn't swap: "+myLoc+" 
<-> "+hisLoc+" - "+uid);
@@ -560,7 +560,7 @@
                 // Randomise our location every 2*SWAP_RESET swap attempts, 
whichever way it went.
                 if(node.random.nextInt(SWAP_RESET) == 0) {
                     setLocation(node.random.nextDouble());
-                    announceLocChange();
+                    announceLocChange(true, false);
                     node.writeNodeFile();
                 }

@@ -578,13 +578,13 @@
     /**
      * Tell all connected peers that our location has changed
      */
-    private void announceLocChange() {
+    private void announceLocChange(boolean randomReset, boolean 
fromDupLocation) {
         Message msg = DMT.createFNPLocChangeNotification(getLocation());
         node.peers.localBroadcast(msg, false, true, this);
-        recordLocChange();
+        recordLocChange(randomReset, fromDupLocation);
     }

-    private void recordLocChange() {
+    private void recordLocChange(final boolean randomReset, final boolean 
fromDupLocation) {
         node.executor.execute(new Runnable() {

                        public void run() {
@@ -594,7 +594,7 @@
                                FileWriter fw = null;
                                try {
                                        fw = new FileWriter(locationLog, true);
-                                       
fw.write(""+DateFormat.getDateTimeInstance().format(new Date())+" : 
"+getLocation()+'\n');
+                                       
fw.write(""+DateFormat.getDateTimeInstance().format(new Date())+" : 
"+getLocation()+(randomReset ? " (random reset"+(fromDupLocation?" from 
duplicated location" : "")+")" : "")+'\n');
                                        fw.close();
                                } catch (IOException e) {
                                        Logger.error(this, "Unable to write 
changed location to "+locationLog+" : "+e, e);


Reply via email to