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

Modified Files:
        NGRoutingTable.java FilterRoutingTable.java 
        StandardNodeStats.java StandardNodeEstimator.java 
        RoutingTable.java CPAlgoRoutingTable.java 
Log Message:
6349:
Major debugging on NGRouting recent changes.
Add diagnostic startedRequestHTL, use it to make the maintenance requests use typical 
HTLs and therefore not introduce bias.
Transients should not accept requests; include a flag that they are transient in their 
references, and don't put transients into the routing table.
Reinstate probabilistic referencing in NGRouting - under strict conditions (40 working 
non-backed off nodes out of 50). New param: minRTNodesPRef. Move shouldReference to RT.
Accept out of band references if less than 40 out of 50 nodes in RT and not backed off.
Add NGRT.countUnbackedOffNodes()
Fix pessimistic estimators initializing pDNF to min pDNF rather than max pDNF if no 
key to start from.
Increase estimators Version to 3 to avoid pollution by estimators intted to 0.0 pDNF 
because of that bug.
Initialize pSearchFailed pessimistically to 1.0.
Logging.

Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -w -r1.47 -r1.48
--- NGRoutingTable.java 22 Nov 2003 02:47:51 -0000      1.47
+++ NGRoutingTable.java 22 Nov 2003 17:56:01 -0000      1.48
@@ -19,6 +19,7 @@
 import freenet.Identity;
 import freenet.Key;
 import freenet.Version;
+import freenet.message.StoreData;
 import freenet.node.Main;
 import freenet.node.Node;
 import freenet.node.NodeReference;
@@ -151,10 +152,13 @@
                     if(!Version.checkGoodVersion(ref.getVersion(), true)) {
                         Core.logger.log(this, "Rejecting reference "+ref+
                                         " - too old ("+ref.getVersion()+
-                                        ") in loadEstimators", 
-                                        new Exception("debug"), Logger.NORMAL);
+                                        ") in loadEstimators", Logger.NORMAL);
                         continue;
                     }
+                    if(ref.isTransient()) {
+                       Core.logger.log(this, "Rejecting reference "+ref+
+                                       " - transient!", Logger.NORMAL);
+                    }
                     ne = factory.create(mem, ref, e, false);
                 } catch (IOException ex) {
                     Core.logger.log(this, "Caught "+ex+" deserializing a 
NodeEstimator for "+mem, ex, Logger.ERROR);
@@ -172,7 +176,8 @@
     
     public boolean wantUnkeyedReference(NodeReference ref) {
         Identity id = ref.getIdentity();
-        if(estimators.size() >= (maxNodes*4/5)) return false;
+        if(ref.isTransient()) return false;
+        if(countUnbackedOffNodes() >= (maxNodes*4/5)) return false;
         if(estimators.get(id) != null) return false;
         if(ref.noPhysical()) return false;
         if(!Version.checkGoodVersion(ref.getVersion(), true)) return false;
@@ -185,7 +190,8 @@
         Core.logger.log(this, "updateReference("+nr+")", Logger.DEBUG);
         if(mem != null) {
             NodeEstimator e = (NodeEstimator)(estimators.get(i));
-            if(nr.supersedes(mem.getNodeReference())) {
+            if(nr.supersedes(mem.getNodeReference()) &&
+                       (!nr.isTransient())) {
                 ((DataObjectRoutingMemory)mem).noderef = nr;
                 if(e == null)
                     Core.logger.log(this, "Got "+mem+" but not estimator!",
@@ -214,6 +220,7 @@
     public synchronized void reference(Key k, NodeReference nr, FieldSet estimator) {
         Identity i = nr.getIdentity();
         if(i == null) return;
+        if(nr.isTransient()) return;
         if(i.equals(Main.id)) return;
         // Not just in FilterRT: serialization and updateRef - FIXME
         RoutingMemory mem = routingStore.getNode(i);
@@ -645,4 +652,51 @@
                return hl;
        }
 
+       /* (non-Javadoc)
+        * @see 
freenet.node.rt.RoutingTable#shouldReference(freenet.node.NodeReference, 
freenet.message.StoreData)
+        */
+       public boolean shouldReference(NodeReference nr, StoreData sd) {
+               if(nr == null) {
+                       Core.logger.log(this, "shouldReference returning false because 
"+
+                                          "null ref", Logger.DEBUG);
+                       return false;
+               }
+               int x = countUnbackedOffNodes();
+               Core.logger.log(this, Integer.toString(x)+ " elements in RoutingTable",
+                               Logger.DEBUG);
+               if(x < (maxNodes * (double)Node.minRTNodesPRef)) {
+                       Core.logger.log(this, "shouldReference because RT less than 
required size",
+                                          Logger.DEBUG);
+                       return true;
+               } else {
+                       if(sd == null) {
+                               Core.logger.log(this, "shouldReference because null 
StoreData",
+                                                  Logger.DEBUG);
+                               return true;
+                       } else {
+                               if(sd.shouldCache(Core.getRandSource(), 
Node.cacheProbPerHop)) {
+                                       Core.logger.log(this, "shouldReference 
returning true because "+
+                                                          "sd.shouldCache says so for 
"+sd, Logger.DEBUG);
+                                       return true;
+                               } else {
+                                       Core.logger.log(this, "shouldReference 
returning false because "+
+                                                          "sd.shouldCache says so for 
"+sd, Logger.DEBUG);
+                                       return false;
+                               }
+                       }
+               }
+       }
+
+       /**
+        * @return the number of nodes in the routing table, excluding those currently 
backed off
+        */
+       public synchronized int countUnbackedOffNodes() {
+               Enumeration e = estimators.elements();
+               int count = 0;
+               while (e.hasMoreElements()) {
+                       NodeEstimator ne = (NodeEstimator)e.nextElement();
+                       if(!ne.isBackedOff()) count++; 
+               }
+               return count;
+       }
 }

Index: FilterRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/FilterRoutingTable.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- FilterRoutingTable.java     21 Nov 2003 21:12:43 -0000      1.11
+++ FilterRoutingTable.java     22 Nov 2003 17:56:01 -0000      1.12
@@ -3,6 +3,7 @@
 import freenet.FieldSet;
 import freenet.Key;
 import freenet.Identity;
+import freenet.message.StoreData;
 import freenet.node.NodeReference;
 
 /**
@@ -95,6 +96,14 @@
         */
        public FieldSet estimatorToFieldSet(Identity identity) {
                return rt.estimatorToFieldSet(identity);
+       }
+
+       /* (non-Javadoc)
+        * @see 
freenet.node.rt.RoutingTable#shouldReference(freenet.node.NodeReference, 
freenet.message.StoreData)
+        */
+       public boolean shouldReference(NodeReference nr, StoreData sd) {
+               if(blocks(nr.getIdentity())) return false;
+               return rt.shouldReference(nr, sd);
        }
 }
 

Index: StandardNodeStats.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/StandardNodeStats.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- StandardNodeStats.java      22 Nov 2003 02:47:51 -0000      1.1
+++ StandardNodeStats.java      22 Nov 2003 17:56:01 -0000      1.2
@@ -43,6 +43,7 @@
                st.maxPTransferFailed = 1.0;
                st.maxPDNF = 1.0;
                st.minPDNF = 0.99;
+               st.maxPSearchFailed = 1.0;
                st.maxConnectFailTime = 1800*1000;
                st.maxConnectSuccessTime = 1800*1000; // 30 mins
                st.maxTransferFailedTime = 7200*1000; // 2 hours

Index: StandardNodeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/StandardNodeEstimator.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -w -r1.49 -r1.50
--- StandardNodeEstimator.java  22 Nov 2003 02:47:51 -0000      1.49
+++ StandardNodeEstimator.java  22 Nov 2003 17:56:01 -0000      1.50
@@ -103,7 +103,7 @@
        
        public FieldSet toFieldSet() {
                FieldSet fs = new FieldSet();
-               fs.put("Version", "2");
+               fs.put("Version", "3");
                fs.put("rpConnectFailed", rpConnectFailed.toFieldSet());
                fs.put("rpTransferFailed", rpTransferFailed.toFieldSet());
                fs.put("rpSearchFailed", rpSearchFailed.toFieldSet());
@@ -210,7 +210,7 @@
                                if(v == null) throw new EstimatorFormatException("no 
Version");
                                try {
                                        int version = Fields.hexToInt(v);
-                                       if(version != 2) 
+                                       if(version != 3) 
                                                throw new 
EstimatorFormatException("Unsupported version "+version, false);
                                } catch (NumberFormatException ex) {
                                        EstimatorFormatException ee = new 
EstimatorFormatException("Odd version: "+v+" ("+ex+")");
@@ -249,11 +249,10 @@
                        rtTransferFailed = raf.create(stats.maxTransferFailedTime);
                        rtSearchFailed = raf.create(stats.maxSearchFailedTime);
                        // Now the RTEs
-                       // Peak is pLegitDNF, trough is 0.0
                        if(k == null) {
                                Core.logger.log(this, "Creating node estimators from 
"+k,
                                                Logger.DEBUG);
-                               epDNFGivenNotSearchFailed = 
rtef.createProbability(stats.minPDNF); 
+                               epDNFGivenNotSearchFailed = 
rtef.createProbability(stats.maxPDNF); 
                                etSuccessSearch = 
rtef.createTime(stats.maxSuccessSearchTime);
                                Core.logger.log(this, "createInitTransfer("+
                                                stats.minTransferRate/1000+")", 
Logger.DEBUG);
@@ -316,8 +315,7 @@
 //             double pNotConnectFailedOrSearchFailed =
 //                     (1 - pConnectFailed) * (1- pSearchFailed);
                estimate += /*pNotConnectFailedOrSearchFailed * */
-                       Math.max(0,(pDNF - pLegitDNF)) * (tDNF + 
-requestFailTime);
+                       Math.max(0,(pDNF - pLegitDNF)) * (tDNF + requestFailTime);
                // Success
                double pSuccess = /*pNotConnectFailedOrSearchFailed * */
                        (1 - pDNF);
@@ -352,7 +350,7 @@
                        e = (long)estimate;
                }
                lastEstimate = e;
-               if(Math.abs(e) > 31 * 24L * 3600L * 1000L) {
+               if(Math.abs(e) > (long)(Math.pow(10,11))) {
                        // Some of these will have the initial pessimistic estimators!
                        // It can be well below 0, because of new nodes with pDNF << 
pLegitDNF
                        Core.logger.log(this, "Unreasonable estimate: "+e+" for "+

Index: RoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/RoutingTable.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- RoutingTable.java   21 Nov 2003 21:12:43 -0000      1.11
+++ RoutingTable.java   22 Nov 2003 17:56:01 -0000      1.12
@@ -3,6 +3,7 @@
 import freenet.FieldSet;
 import freenet.Key;
 import freenet.Identity;
+import freenet.message.StoreData;
 import freenet.node.NodeReference;
 
 /**
@@ -123,6 +124,13 @@
         * @param identity the identity of the node
         */
        FieldSet estimatorToFieldSet(Identity identity);
+
+       /**
+        * @param nr
+        * @param sd
+        * @return
+        */
+       boolean shouldReference(NodeReference nr, StoreData sd);
 }
 
 

Index: CPAlgoRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/CPAlgoRoutingTable.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -w -r1.61 -r1.62
--- CPAlgoRoutingTable.java     13 Nov 2003 02:16:58 -0000      1.61
+++ CPAlgoRoutingTable.java     22 Nov 2003 17:56:01 -0000      1.62
@@ -17,6 +17,7 @@
 import freenet.client.AutoBackoffNodeRequester;
 import freenet.client.FreenetURI;
 import freenet.client.InternalClient;
+import freenet.message.StoreData;
 import freenet.node.BadReferenceException;
 import freenet.node.Node;
 import freenet.node.NodeReference;
@@ -1044,6 +1045,41 @@
 
        public FieldSet estimatorToFieldSet(Identity identity) {
                return null;
+       }
+
+       /* (non-Javadoc)
+        * @see 
freenet.node.rt.RoutingTable#shouldReference(freenet.node.NodeReference, 
freenet.message.StoreData)
+        */
+       public boolean shouldReference(NodeReference nr, StoreData sd) {
+               if(nr == null) {
+                       Core.logger.log(this, "shouldReference returning false because 
"+
+                                          "null ref", Logger.DEBUG);
+                       return false;
+               }
+               int x = getKeyCount();
+               Core.logger.log(this, Integer.toString(x)+ " elements in 
RoutingTable", 
+                                  Logger.DEBUG);
+               if(x < (maxRefsPerNode * maxNodes * (double)Node.minRTFullPRef)) {
+                       Core.logger.log(this, "shouldReference because RT less than 
required size",
+                                          Logger.DEBUG);
+                       return true;
+               } else {
+                       if(sd == null) {
+                               Core.logger.log(this, "shouldReference because null 
StoreData",
+                                                  Logger.DEBUG);
+                               return true;
+                       } else {
+                               if(sd.shouldCache(Core.getRandSource(), 
Node.cacheProbPerHop)) {
+                                       Core.logger.log(this, "shouldReference 
returning true because "+
+                                                          "sd.shouldCache says so for 
"+sd, Logger.DEBUG);
+                                       return true;
+                               } else {
+                                       Core.logger.log(this, "shouldReference 
returning false because "+
+                                                          "sd.shouldCache says so for 
"+sd, Logger.DEBUG);
+                                       return false;
+                               }
+                       }
+               }
        };
 }
 

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

Reply via email to