Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv14597/src/freenet/node/rt

Modified Files:
        FilterRoutingTable.java NodeEstimator.java RoutingTable.java 
        NGRouting.java NGRoutingTable.java StandardNodeEstimator.java 
        TreeRoutingTable.java 
Log Message:
6347:
Contact the least experienced node every 30 seconds (customizable), and send it a 
request for a recently requested key. Remove it from the store first. Thus new nodes 
will gain experience even if their estimators are pessimistic. Stage 2 will be making 
initial estimators pessimistic. Will implement soon.

Index: FilterRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/FilterRoutingTable.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- FilterRoutingTable.java     13 Nov 2003 02:16:58 -0000      1.10
+++ FilterRoutingTable.java     21 Nov 2003 21:12:43 -0000      1.11
@@ -66,8 +66,8 @@
     }
     
     public final Routing route(Key k, int htl, long size, boolean force,
-                              boolean isInsert) {
-        return rt.route(k, htl, size, force, isInsert);
+                              boolean isInsert, boolean orderByInexperience) {
+        return rt.route(k, htl, size, force, isInsert, orderByInexperience);
     }
     
     public final RoutingStore getRoutingStore() {

Index: NodeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NodeEstimator.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -r1.20 -r1.21
--- NodeEstimator.java  18 Nov 2003 14:32:21 -0000      1.20
+++ NodeEstimator.java  21 Nov 2003 21:12:43 -0000      1.21
@@ -32,6 +32,11 @@
        abstract public long createdTime();
        abstract public long lastEstimate();
        
+       /**
+        * @return the number of times this node has been accessed for routing
+        */
+       abstract public long routeAccesses();
+       
     public RoutingMemory memory() {
                return mem;
     }

Index: RoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/RoutingTable.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- RoutingTable.java   13 Nov 2003 02:16:58 -0000      1.10
+++ RoutingTable.java   21 Nov 2003 21:12:43 -0000      1.11
@@ -63,10 +63,12 @@
      * @param htl   the hops to live of the message we are about to send
      * @param size  the size of the file we are trying to obtain or send
      * @param force whether to try to contact backed off nodes
+     * @param routeToNewestNodeOnly if true, don't route normally,
+     * route to the node with the least usage so far
      * @return      the generated Routing object
      */
     Routing route(Key k, int htl, long size, boolean force,
-                 boolean isInsert);
+                 boolean isInsert, boolean routeToNewestNodeOnly);
     
     /**
      * NOTE:  It is important to hold the sync-lock

Index: NGRouting.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRouting.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- NGRouting.java      18 Nov 2003 13:36:50 -0000      1.30
+++ NGRouting.java      21 Nov 2003 21:12:43 -0000      1.31
@@ -192,6 +192,7 @@
         stdFileSize = node.dir.used() / node.dir.countKeys();
     else stdFileSize = 131072;
     long normalizedTime = searchTime + (transferTime*stdFileSize/size);
+    if(lastEstimate.searchSuccessTime > 0) {
     // searchSuccessTime is valid anyway
     Core.diagnostics.occurrenceContinuous("normalizedSuccessTime", 
                           normalizedTime);
@@ -202,14 +203,17 @@
             diffSearchTime);
     Core.diagnostics.occurrenceContinuous("absDiffSearchSuccessTime",
             Math.abs(diffSearchTime));
+    }
     double rate;
     if(size > 16384 /* must be multi-segment */ 
         && transferTime > 10 /* sanity check */) {
         rate = ((double)size * 1000) / ((double)transferTime);
+        if(lastEstimate.transferRate > 0) {
         double diffRate = rate - (lastEstimate.transferRate*1000);
         Core.diagnostics.occurrenceContinuous("diffTransferRate", diffRate);
         Core.diagnostics.occurrenceContinuous("absDiffTransferRate",
                 Math.abs(diffRate));
+        }
         Core.diagnostics.occurrenceContinuous("successTransferRate", rate);
         ngrt.reportRate(rate);
     } else {

Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -w -r1.45 -r1.46
--- NGRoutingTable.java 18 Nov 2003 14:32:21 -0000      1.45
+++ NGRoutingTable.java 21 Nov 2003 21:12:43 -0000      1.46
@@ -343,7 +343,8 @@
     
     public Routing route(Key k, int htl, long size, 
                                       boolean force, 
-                                      boolean isInsert) {
+                                      boolean isInsert,
+                                                                         boolean 
orderByInexperience) {
         updateDNFProbabilities();
         Vector v = new Vector(maxNodes);
         Enumeration e;
@@ -359,9 +360,12 @@
         int i=0;
         while(e.hasMoreElements()) {
             NodeEstimator ne = (NodeEstimator)(e.nextElement());
-            Estimate es = ne.longEstimate(k, htl, size, global, pLegitDNF);
-            long estimate = ne.estimate(k, htl, size,
-                    global, pLegitDNF);
+            Estimate es;
+            if(orderByInexperience) {
+               es = new Estimate(ne, ne.routeAccesses(), -1, -1);
+            } else {
+               es = ne.longEstimate(k, htl, size, global, pLegitDNF);
+            }
             estimates[i] = es;
             i++;
         }

Index: StandardNodeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/StandardNodeEstimator.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -w -r1.47 -r1.48
--- StandardNodeEstimator.java  19 Nov 2003 19:13:56 -0000      1.47
+++ StandardNodeEstimator.java  21 Nov 2003 21:12:43 -0000      1.48
@@ -46,6 +46,7 @@
        long lastConnectTime = -1;
        long lastConnectTryTime = -1;
        long lastAccessedTime = -1;
+       long routeAccesses = 0; // excludes connections
        long lastSuccessTime = -1;
        final long createdTime;
        int connectTries = 0;
@@ -125,6 +126,11 @@
                long ct;
                try {
                        ct = dis.readLong();
+                       try {
+                               routeAccesses = dis.readLong();
+                       } catch (IOException e) {
+                               routeAccesses = 0;
+                       }
                } catch (IOException e) {
                        ct = System.currentTimeMillis();
                }
@@ -355,8 +361,9 @@
                                                new Exception("debug"), Logger.DEBUG);
                long now = System.currentTimeMillis();
                lastAccessedTime = now;
-               // Exponential backoff
                synchronized(this) {
+                       routeAccesses++;
+                       // Exponential backoff
                        if(enteredBackoffTime + currentBackoffPeriod > now) {
                                // Ignore, already backed off
                                if(logDEBUG)
@@ -395,6 +402,9 @@
                                                size+" bytes) on "+ref, new 
Exception("debug"), 
                                                Logger.DEBUG);
                lastAccessedTime = lastPartialSuccessTime = System.currentTimeMillis();
+               synchronized(this) {
+                       routeAccesses++;
+               }
        }
        
        public void dataNotFound(Key key, long searchTime, int htl) {
@@ -408,6 +418,9 @@
                if(logDEBUG) Core.logger.log(this, "Data Not Found in "+searchTime+"ms 
on "+ref,
                                                new Exception("debug"), Logger.DEBUG);
                lastAccessedTime = lastPartialSuccessTime = System.currentTimeMillis();
+               synchronized(this) {
+                       routeAccesses++;
+               }
        }
        
        public void transferSucceeded(Key key, long searchTime, int htl,
@@ -418,6 +431,7 @@
                                        ","+htl+","+rate+") on "+this, Logger.DEBUG);
                synchronized(this) {
                        successes++;
+                       routeAccesses++;
                }
                lastSuccessTime = lastPartialSuccessTime = lastAccessedTime = 
                        System.currentTimeMillis();
@@ -447,7 +461,7 @@
                        etSuccessSearch.getDataLength() +
                        etTransferRate.getDataLength() + 
                        epDNFGivenNotSearchFailed.getDataLength() +
-                       etDNF.getDataLength() + 4 + 8 + 8 + 8;
+                       etDNF.getDataLength() + 4 + 8 + 8 + 8 + 8;
        }
        
        public long lastConnectTime() {
@@ -504,6 +518,7 @@
                out.writeLong(lastSuccessTime);
                out.writeLong(lastAccessedTime);
                out.writeLong(createdTime);
+               out.writeLong(routeAccesses);
        }
        
        private final static String[] REF_PROPERTIES =
@@ -992,5 +1007,12 @@
                if(end < now)
                        return 0;
                return (int)(end - now);
+       }
+
+       /* (non-Javadoc)
+        * @see freenet.node.rt.NodeEstimator#routeAccesses()
+        */
+       public long routeAccesses() {
+               return routeAccesses;
        }
 }

Index: TreeRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/TreeRoutingTable.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- TreeRoutingTable.java       13 Nov 2003 02:16:58 -0000      1.30
+++ TreeRoutingTable.java       21 Nov 2003 21:12:43 -0000      1.31
@@ -107,12 +107,16 @@
     }
     
     public synchronized Routing route(Key k, int htl, long size) {
-       return route(k, htl, size, false, false);
+       return route(k, htl, size, false, false, false);
     }
     
+    /**
+     * @see freenet.node.rt.RoutingTable#route(freenet.Key, int, long, boolean, 
boolean, boolean)
+     * Does not use htl, size, orderByInexperience 
+     */
     public synchronized Routing route(Key k, int htl, long size, 
                                      boolean doDesperate,
-                                     boolean isInsert) {
+                                     boolean isInsert, boolean orderByInexperience) {
        long x = -1;
        
        boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to