Author: zothar
Date: 2006-05-21 03:47:10 +0000 (Sun, 21 May 2006)
New Revision: 8811

Modified:
   trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
   trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
   trunk/freenet/src/freenet/node/ARKFetcher.java
   trunk/freenet/src/freenet/node/KeyTracker.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
- Highlight too old and too new versions on /darknet/ page
- Feedback/debugging tools for devs:
  * ARK fetch requests count added to Welcome Toadlet
  * Some ugly hack stats added to /darknet/ page:
    + Current per-packet bandwidth limiting delay time
    + Node average ping time
    + Per-Peer average ping time
- Changed handshake send interval for too old and too new peers
- Added Peer name to "No IP addresses" message
- A couple of other logging tweaks


Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java       
2006-05-21 02:09:40 UTC (rev 8810)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java       
2006-05-21 03:47:10 UTC (rev 8811)
@@ -94,6 +94,10 @@
                buf.append("</div>\n");
                buf.append("<div class=\"infobox-content\">\n");
                buf.append("<form action=\".\" method=\"post\" 
enctype=\"multipart/form-data\">\n");
+               int bwlimitDelayTime = (int) node.getBwlimitDelayTime();
+               int nodeAveragePingTime = (int) node.getNodeAveragePingTime();
+               buf.append("bwlimitDelayTime: "+bwlimitDelayTime+"ms<br>\n");
+               buf.append("nodeAveragePingTime: 
"+nodeAveragePingTime+"ms<br>\n");
                StringBuffer buf2 = new StringBuffer(1024);
                buf2.append("<table class=\"darknet_connections\">\n");
                buf2.append("<tr><th>Status</th><th>Name</th><th><span 
title=\"Address:Port\" style=\"border-bottom:1px 
dotted;cursor:help;\">Address</span></th><th>Version</th><th>Location</th><th><span
 title=\"Temporarily disconnected. Other node busy? Wait time(s) 
remaining/total\" style=\"border-bottom:1px 
dotted;cursor:help;\">Backoff</span></th><th><span title=\"Number of minutes 
since the node was last seen in this session\" style=\"border-bottom:1px 
dotted;cursor:help;\">Idle</span></th><th></th></tr>\n");
@@ -149,11 +153,21 @@
                                if( backoffReason != null ) {
                                        lastBackoffReasonOutputString = 
"/"+backoffReason;
                                }
+                               String avgPingTimeString = "";
+                               if(pn.isConnected())
+                                       avgPingTimeString = " ("+(int) 
pn.averagePingTime()+"ms)";
+                               String VersionPrefixString = "";
+                               String VersionSuffixString = "";
+                               if(pn.publicInvalidVersion() || 
pn.publicReverseInvalidVersion()) {
+                                       VersionPrefixString = "<span 
class=\"peer_version_problem\">";
+                                       VersionSuffixString = "</span>";
+                               }
+                               
                                row[0] = pn;
                                row[1] = status;
                                row[2] = HTMLEncoder.encode(pn.getName());
-                               row[3] = pn.getDetectedPeer() != null ? 
HTMLEncoder.encode(pn.getDetectedPeer().toString()) : "(address unknown)";
-                               row[4] = HTMLEncoder.encode(pn.getVersion());
+                               row[3] = ( pn.getDetectedPeer() != null ? 
HTMLEncoder.encode(pn.getDetectedPeer().toString()) : "(address unknown)" ) + 
avgPingTimeString;
+                               row[4] = 
VersionPrefixString+HTMLEncoder.encode(pn.getVersion())+VersionSuffixString;
                                row[5] = new 
Double(pn.getLocation().getValue());
                                row[6] = backoff/1000 + "/" + 
pn.getRoutingBackoffLength()/1000+lastBackoffReasonOutputString;
                                if (idle == -1) row[7] = " ";

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-05-21 
02:09:40 UTC (rev 8810)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-05-21 
03:47:10 UTC (rev 8811)
@@ -411,6 +411,7 @@
                                + "<li>Inserts: 
"+this.node.getNumInserts()+"</li>\n"
                                + "<li>Requests: 
"+this.node.getNumRequests()+"</li>\n"
                                + "<li>Transferring Requests: 
"+this.node.getNumTransferringRequests()+"</li>\n"
+                               + "<li>ARK Fetch Requests: 
"+this.node.getNumARKFetchers()+"</li>\n"
                                + "</ul>\n");
                buf.append("</div>\n");
                buf.append("</div>\n");

Modified: 
trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css   
2006-05-21 02:09:40 UTC (rev 8810)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css   
2006-05-21 03:47:10 UTC (rev 8811)
@@ -287,6 +287,10 @@
        color: #d0d0d0;
 }

+table.darknet_connections span.peer_version_problem {
+       color: #d07070;
+}
+
 tr.messagetypes {
        text-align: center;
 }

Modified: trunk/freenet/src/freenet/node/ARKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/node/ARKFetcher.java      2006-05-21 02:09:40 UTC 
(rev 8810)
+++ trunk/freenet/src/freenet/node/ARKFetcher.java      2006-05-21 03:47:10 UTC 
(rev 8811)
@@ -28,10 +28,13 @@
        private static final int MAX_BACKOFF = 60*60*1000;
        private static final int MIN_BACKOFF = 5*1000;
        private int backoff = MIN_BACKOFF;
+       private String identity;
+       private boolean isFetching = false;

        public ARKFetcher(PeerNode peer, Node node) {
                this.peer = peer;
                this.node = node;
+               this.identity = peer.getIdentityString();
        }

        /**
@@ -63,6 +66,10 @@
                if(cg != null)
                        try {
                                cg.start();
+                               if(!isFetching) {
+                                       node.addARKFetcher(identity,this);
+                                       isFetching = true;
+                               }
                        } catch (FetchException e) {
                                onFailure(e, cg);
                        }
@@ -76,6 +83,10 @@
                backoff = MIN_BACKOFF;
                Logger.minor(this, "Cancelling ARK fetch for "+peer);
                shouldRun = false;
+               if(isFetching) {
+                       node.removeARKFetcher(identity,this);
+                       isFetching = false;
+               }
                if(getter != null)
                        getter.cancel();
        }
@@ -84,6 +95,10 @@
                Logger.minor(this, "Fetched ARK for "+peer, new 
Exception("debug"));
                // Fetcher context specifies an upper bound on size.
                backoff = MIN_BACKOFF;
+               if(isFetching) {
+                       node.removeARKFetcher(identity,this);
+                       isFetching = false;
+               }
                ArrayBucket bucket = (ArrayBucket) result.asBucket();
                byte[] data = bucket.toByteArray();
                String ref;
@@ -105,6 +120,10 @@

        public void onFailure(FetchException e, ClientGetter state) {
                Logger.minor(this, "Failed to fetch ARK for "+peer+" : "+e, e);
+               if(isFetching) {
+                       node.removeARKFetcher(identity,this);
+                       isFetching = false;
+               }
                // If it's a redirect, follow the redirect and update the ARK.
                // If it's any other error, wait a while then retry.
                getter = null;
@@ -116,6 +135,7 @@
                }
                backoff += backoff;
                if(backoff > MAX_BACKOFF) backoff = MAX_BACKOFF;
+               Logger.minor(this, "Failed to fetch ARK for "+peer+", now 
backing off ARK fetches for "+(int) (backoff / 1000)+" seconds");
                // We may be on the PacketSender thread.
                // FIXME should this be exponential backoff?
                node.ps.queueTimedJob(new FastRunnable() { public void run() { 
start(); }}, backoff);

Modified: trunk/freenet/src/freenet/node/KeyTracker.java
===================================================================
--- trunk/freenet/src/freenet/node/KeyTracker.java      2006-05-21 02:09:40 UTC 
(rev 8810)
+++ trunk/freenet/src/freenet/node/KeyTracker.java      2006-05-21 03:47:10 UTC 
(rev 8811)
@@ -538,7 +538,7 @@
         QueuedAckRequest qr = 
(QueuedAckRequest)ackRequestQueue.removeByKey(new Integer(seqNo));
        if(qr != null) qr.onAcked();
        else
-               Logger.normal(this, "Removing ack request twice? Null on 
"+seqNo+" from "+pn.getPeer()+" ("+new 
Double(pn.pingAverage.currentValue()).intValue()+"ms ping average)");
+               Logger.normal(this, "Removing ack request twice? Null on 
"+seqNo+" from "+pn.getPeer()+" ("+(int) pn.pingAverage.currentValue()+"ms ping 
average)");
     }

     /**

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-05-21 02:09:40 UTC (rev 
8810)
+++ trunk/freenet/src/freenet/node/Node.java    2006-05-21 03:47:10 UTC (rev 
8811)
@@ -389,8 +389,8 @@
     public static final int RANDOMIZED_TIME_BETWEEN_HANDSHAKE_SENDS = 
HANDSHAKE_TIMEOUT;
     public static final int MIN_TIME_BETWEEN_VERSION_PROBES = 
HANDSHAKE_TIMEOUT*4;
     public static final int RANDOMIZED_TIME_BETWEEN_VERSION_PROBES = 
HANDSHAKE_TIMEOUT*2; // 20-30 secs
-    public static final int MIN_TIME_BETWEEN_VERSION_SENDS = 
HANDSHAKE_TIMEOUT*9;
-    public static final int RANDOMIZED_TIME_BETWEEN_VERSION_SENDS = 
HANDSHAKE_TIMEOUT*2; // 45-55 secs
+    public static final int MIN_TIME_BETWEEN_VERSION_SENDS = 
HANDSHAKE_TIMEOUT*5;
+    public static final int RANDOMIZED_TIME_BETWEEN_VERSION_SENDS = 
HANDSHAKE_TIMEOUT*2; // 25-35 secs
     // If we don't receive any packets at all in this period, from any node, 
tell the user
     public static final long ALARM_TIME = 60*1000;
     /** Sub-max ping time. If ping is greater than this, we reject some 
requests. */
@@ -457,7 +457,9 @@
     /** My ARK sequence number */
     private long myARKNumber;
     /** FetcherContext for ARKs */
-       public final FetcherContext arkFetcherContext;
+    public final FetcherContext arkFetcherContext;
+    /** ARKFetcher's currently running, by identity */
+    private final HashMap arkFetchers;

     private final HashSet runningUIDs;

@@ -841,6 +843,7 @@
         requestSenders = new HashMap();
         transferringRequestSenders = new HashMap();
         insertSenders = new HashMap();
+        arkFetchers = new HashMap();
         runningUIDs = new HashSet();
         ps = new PacketSender(this);
         // FIXME maybe these should persist? They need to be private though, 
so after the node/peers split. (bug 51).
@@ -2623,4 +2626,38 @@
                }
                return false;
        }
+    
+    public double getBwlimitDelayTime() {
+       return this.throttledPacketSendAverage.currentValue();
+    }
+    
+    public double getNodeAveragePingTime() {
+       return nodePinger.averagePingTime();
+    }
+
+    /**
+     * Add a ARKFetcher to the map
+     */
+    public synchronized void addARKFetcher(String identity, ARKFetcher 
fetcher) {
+       Logger.minor(this, "addARKFetcher(): adding ARK Fetcher for "+identity);
+       arkFetchers.put(identity, fetcher);
+    }
+    
+    /**
+     * How many ARK Fetchers are currently requesting ARKs?
+     */
+    public int getNumARKFetchers() {
+               return arkFetchers.size();
+    }
+
+    /**
+     * Remove a ARKFetcher from the map
+     */
+    public synchronized void removeARKFetcher(String identity, ARKFetcher 
fetcher) {
+       Logger.minor(this, "removeARKFetcher(): removing ARK Fetcher for 
"+identity);
+       ARKFetcher af = (ARKFetcher) arkFetchers.remove(identity);
+       if(af != fetcher) {
+               Logger.error(this, "Removed "+af+" should be "+fetcher+" for 
"+identity+" in removeARKFetcher");
+       }
+    }
 }

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2006-05-21 02:09:40 UTC 
(rev 8810)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2006-05-21 03:47:10 UTC 
(rev 8811)
@@ -271,7 +271,7 @@
                 throw new FSParseException(e1);
         }
         if(nominalPeer.isEmpty()) {
-               Logger.normal(this, "No IP addresses found for identity 
'"+Base64.encode(identity)+"', possibly at location 
'"+Double.toString(currentLocation.getValue())+"'");
+               Logger.normal(this, "No IP addresses found for identity 
'"+Base64.encode(identity)+"', possibly at location 
'"+Double.toString(currentLocation.getValue())+"' with name '"+myName+"'");
                detectedPeer = null;
         } else
                detectedPeer=(Peer) nominalPeer.firstElement();
@@ -996,6 +996,14 @@
     private synchronized boolean reverseInvalidVersion() {
         return bogusNoderef || 
(!Version.checkArbitraryGoodVersion(Version.getVersionString(),lastGoodVersion));
     }
+    
+    public synchronized boolean publicInvalidVersion() {
+        return !Version.checkGoodVersion(version);
+    }
+    
+    public synchronized boolean publicReverseInvalidVersion() {
+        return 
!Version.checkArbitraryGoodVersion(Version.getVersionString(),lastGoodVersion);
+    }

     /**
      * Process a new nodereference, in compressed form.
@@ -1547,5 +1555,10 @@
                        Logger.error(this, "Data was: \n"+fs.toString());
                }
        }
+
+
+       public String getIdentityString() {
+       return Base64.encode(identity);
+    }
 }



Reply via email to