Author: toad
Date: 2006-05-16 19:59:38 +0000 (Tue, 16 May 2006)
New Revision: 8716
Modified:
trunk/freenet/src/freenet/node/ARKFetcher.java
trunk/freenet/src/freenet/node/Version.java
Log:
711: Exponential backoff for ARK fetches.
Modified: trunk/freenet/src/freenet/node/ARKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/node/ARKFetcher.java 2006-05-16 19:52:59 UTC
(rev 8715)
+++ trunk/freenet/src/freenet/node/ARKFetcher.java 2006-05-16 19:59:38 UTC
(rev 8716)
@@ -5,7 +5,6 @@
import freenet.client.FetchException;
import freenet.client.FetchResult;
-import freenet.client.FetcherContext;
import freenet.client.InserterException;
import freenet.client.async.BaseClientPutter;
import freenet.client.async.ClientCallback;
@@ -26,6 +25,9 @@
private ClientGetter getter;
private FreenetURI fetchingURI;
private boolean shouldRun = false;
+ private static final int MAX_BACKOFF = 60*60*1000;
+ private static final int MIN_BACKOFF = 5*1000;
+ private int backoff = MIN_BACKOFF;
public ARKFetcher(PeerNode peer, Node node) {
this.peer = peer;
@@ -71,6 +73,7 @@
*/
public synchronized void stop() {
// Stop fetch
+ backoff = MIN_BACKOFF;
Logger.minor(this, "Cancelling ARK fetch for "+peer);
shouldRun = false;
if(getter != null)
@@ -80,6 +83,7 @@
public void onSuccess(FetchResult result, ClientGetter state) {
Logger.minor(this, "Fetched ARK for "+peer, new
Exception("debug"));
// Fetcher context specifies an upper bound on size.
+ backoff = MIN_BACKOFF;
ArrayBucket bucket = (ArrayBucket) result.asBucket();
byte[] data = bucket.toByteArray();
String ref;
@@ -110,9 +114,11 @@
start();
return;
}
+ backoff += backoff;
+ if(backoff > MAX_BACKOFF) backoff = MAX_BACKOFF;
// We may be on the PacketSender thread.
// FIXME should this be exponential backoff?
- node.ps.queueTimedJob(new FastRunnable() { public void run() {
start(); }}, 20000L);
+ node.ps.queueTimedJob(new FastRunnable() { public void run() {
start(); }}, backoff);
}
public void onSuccess(BaseClientPutter state) {
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-05-16 19:52:59 UTC (rev
8715)
+++ trunk/freenet/src/freenet/node/Version.java 2006-05-16 19:59:38 UTC (rev
8716)
@@ -18,7 +18,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 710;
+ private static final int buildNumber = 711;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 591;