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

Modified Files:
        NGRoutingTable.java 
Log Message:
6177: change discard order: if not connected, incorporate the number of consecutive 
failures, this takes precedence over lastSuccess. Should prevent us dropping new nodes 
when all nodes in the RT had a success aeons ago but aren't currently connectible.


Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NGRoutingTable.java 30 Aug 2003 23:16:52 -0000      1.2
+++ NGRoutingTable.java 6 Sep 2003 17:35:27 -0000       1.3
@@ -309,20 +309,29 @@
        class MyDiscardValue implements Comparable {
                final long lastSuccess;
                final long lastAccess;
+               final int consecutiveConnectionFailures; // zero if connected
                
                public String toString() {
                        return "NGRT.MyDiscardValue: lastSuccess="+lastSuccess+
-                               ", lastAccess="+lastAccess;
+                               ", lastAccess="+lastAccess+", connFailures="+
+                               consecutiveConnectionFailures;
                }
                
-               MyDiscardValue(long success, long access) {
+               MyDiscardValue(long success, long access, int connFailures) {
                        lastSuccess = success;
                        lastAccess = access;
+                       consecutiveConnectionFailures = connFailures;
                }
                
                public int compareTo(Object c) {
                        MyDiscardValue o = (MyDiscardValue)c;
                        // Upside down, like Ticker, because this is on a Heap
+                       // Higher = more failures = worse
+                       if(consecutiveConnectionFailures < 
+                          o.consecutiveConnectionFailures) return -1;
+                       if(consecutiveConnectionFailures > 
+                          o.consecutiveConnectionFailures) return 1;
+                       // Higher = more recent = better
                        if(lastSuccess < o.lastSuccess) return 1;
                        if(lastSuccess > o.lastSuccess) return -1;
                        if(lastAccess < o.lastAccess) return 1;
@@ -340,6 +349,7 @@
        
        protected final Comparable getDiscardValue(RoutingMemory mem) {
                NodeEstimator ne;
+               MyDiscardValue ret;
                try {
                        ne = (NodeEstimator) mem.getProperty(NGKEY);
                } catch (DataObjectUnloadedException e) {
@@ -352,10 +362,20 @@
                        }
                        if(ne != null) mem.setProperty(NGKEY, ne);
                }
-               if(ne != null)
-                       return new MyDiscardValue(ne.lastSuccessTime(), 
ne.lastAccessedTime());
-               else
-                       return new MyDiscardValue(-1, -1);
+               if(ne != null) {
+                       int x = 0;
+                       Identity i = ne.ref.getIdentity();
+                       if(!(countInboundConnections(i) > 0 ||
+                                countOutboundConnections(i) > 0)) {
+                               x = ne.consecutiveFailedConnects(); // should be >1
+                               // But will be 0 for new nodes. Which is what we want.
+                       }
+                       ret = new MyDiscardValue(ne.lastSuccessTime(), 
ne.lastAccessedTime(), x);
+               } else
+                       ret = new MyDiscardValue(-1, -1, 0);
+               Core.logger.log(this, "Returning "+ret,
+                                               Logger.DEBUG);
+               return ret;
        }
        
        public TimeEstimator getGlobalEstimator() {

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

Reply via email to