Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv12267/src/freenet/node/rt
Modified Files:
Tag: ngrouting
NGRouting.java TreeRouting.java
Added Files:
Tag: ngrouting
TerminatableRouting.java
Log Message:
terminate() the route explicitly in states/. DO NOT terminate automatically in
transferFailed, because it usually isn't fatal (fixes nasty bug introduced yesterday
that caused RNFs). Add an ABC for NG-/Table- Routing, including most of the
terminate() logic.
--- NEW FILE: TerminatableRouting.java ---
package freenet.node.rt;
import freenet.Core;
import freenet.support.Logger;
/**
* Base class for NGRouting and TreeRouting
*/
abstract class TerminatableRouting implements Routing {
boolean terminated = false;
public void terminate() {
terminate(false);
}
public void terminate(boolean success) {
if(terminated) return;
terminated = true;
reallyTerminate(success);
}
protected void reallyTerminate(boolean success) {
Core.diagnostics.occurrenceBinomial("requestSuccessRatio", 1,
success ? 1 : 0);
}
protected void finalize() {
if(!terminated) {
Core.logger.log(this, "Did not terminate "+this,
Logger.NORMAL);
}
}
}
Index: NGRouting.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/Attic/NGRouting.java,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -r1.1.2.13 -r1.1.2.14
--- NGRouting.java 28 Aug 2003 02:10:10 -0000 1.1.2.13
+++ NGRouting.java 28 Aug 2003 17:38:03 -0000 1.1.2.14
@@ -12,7 +12,7 @@
* Iterates over a provided NodeEstimator[]
* @author amphibian
*/
-class NGRouting implements Routing {
+class NGRouting extends TerminatableRouting {
final NGRoutingTable ngrt;
final Estimate list[];
NodeEstimator last;
@@ -28,7 +28,6 @@
Node node;
boolean hasSearchFailed = false;
long origStartTime;
- boolean logged = false;
NGRouting(NGRoutingTable ngrt, Estimate[] list, int maxSteps, Key k,
boolean doDesperate, Node n) {
@@ -153,7 +152,7 @@
public void transferFailed(long time, int htl, long size,
long transferTime) {
last.transferFailed(key, System.currentTimeMillis() - lastTime, size);
- terminate(false);
+ // transferFailed is usually not terminal
}
public void transferSucceeded(long searchTime, int htl, long size,
@@ -179,18 +178,13 @@
terminate(true);
}
- public void terminate() {
- terminate(false);
- }
-
- public void terminate(boolean success) {
+ protected void reallyTerminate(boolean success) {
+ super.reallyTerminate(success);
desperate = true;
count = maxSteps+1;
at = list.length;
long t = System.currentTimeMillis()-origStartTime;
ngrt.globalEstimator.reportTime(key, t);
- Core.diagnostics.occurrenceBinomial("requestSuccessRatio", 1,
- success ? 1 : 0);
}
public void dataNotFound(int htl) {
Index: TreeRouting.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/TreeRouting.java,v
retrieving revision 1.21.2.13
retrieving revision 1.21.2.14
diff -u -r1.21.2.13 -r1.21.2.14
--- TreeRouting.java 28 Aug 2003 02:10:10 -0000 1.21.2.13
+++ TreeRouting.java 28 Aug 2003 17:38:04 -0000 1.21.2.14
@@ -16,7 +16,7 @@
* if its RoutingMemory can pass the isRoutable() test.
* @author tavin
*/
-class TreeRouting implements Routing {
+class TreeRouting extends TerminatableRouting {
protected final Hashtable steps = new Hashtable();
@@ -254,7 +254,7 @@
public void transferFailed(long time, int htl, long size, long etime) {
rt.transferFailed(mem);
- terminate(false);
+ // Not usually terminal
};
public void transferSucceeded(long time, int htl, long size, long etime) {
@@ -280,15 +280,10 @@
// We don't care
}
- public void terminate() {
- terminate(false);
- }
-
- public void terminate(boolean success) {
+ protected void reallyTerminate(boolean success) {
+ super.reallyTerminate(success);
desperate = true;
stepCount = node.maxRoutingSteps+1;
- Core.diagnostics.occurrenceBinomial("requestSuccessRatio", 1,
- success ? 1 : 0);
}
}
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs