Author: toad
Date: 2008-06-26 17:07:27 +0000 (Thu, 26 Jun 2008)
New Revision: 20758
Modified:
branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/ClientContext.java
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
branches/db4o/freenet/src/freenet/client/async/USKChecker.java
branches/db4o/freenet/src/freenet/node/SendableGet.java
Log:
Don't pass in or store the RequestScheduler.
Modified:
branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -71,7 +71,7 @@
/** Try again - returns true if we can retry
* @param sched */
- protected boolean retry(RequestScheduler sched, ObjectContainer
container, ClientContext context) {
+ protected boolean retry(ObjectContainer container, ClientContext
context) {
if(persistent) {
container.activate(this, 1);
}
@@ -85,8 +85,10 @@
long now = System.currentTimeMillis();
if(cooldownWakeupTime > now)
Logger.error(this, "Already on the
cooldown queue for "+this, new Exception("error"));
- else
- cooldownWakeupTime = sched.queueCooldown(key,
this);
+ else {
+ RequestScheduler sched =
context.getFetchScheduler(key instanceof ClientSSK);
+ cooldownWakeupTime =
sched.queueCooldown(key, this);
+ }
return true; // We will retry, just not yet.
See requeueAfterCooldown(Key).
} else {
schedule(container, context);
@@ -142,7 +144,7 @@
return true;
}
- public void onGotKey(Key key, KeyBlock block, RequestScheduler sched,
ObjectContainer container, ClientContext context) {
+ public void onGotKey(Key key, KeyBlock block, ObjectContainer
container, ClientContext context) {
if(persistent)
container.activate(this, 2);
synchronized(this) {
@@ -153,7 +155,7 @@
}
}
try {
- onSuccess(Key.createKeyBlock(this.key, block), false,
null, sched, container, context);
+ onSuccess(Key.createKeyBlock(this.key, block), false,
null, container, context);
} catch (KeyVerifyException e) {
Logger.error(this, "onGotKey("+key+","+block+") got
"+e+" for "+this, e);
// FIXME if we get rid of the direct route this must
call onFailure()
Modified: branches/db4o/freenet/src/freenet/client/async/ClientContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientContext.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/ClientContext.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -13,6 +13,7 @@
import freenet.client.InsertException;
import freenet.crypt.RandomSource;
import freenet.node.NodeClientCore;
+import freenet.node.RequestScheduler;
import freenet.node.RequestStarterGroup;
import freenet.support.Executor;
import freenet.support.api.BucketFactory;
@@ -140,5 +141,10 @@
else
return tempBucketFactory;
}
+
+ public RequestScheduler getFetchScheduler(boolean ssk) {
+ if(ssk) return sskFetchScheduler;
+ return chkFetchScheduler;
+ }
}
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -290,7 +290,7 @@
if(logMINOR)
Logger.minor(this, "Decode failed: "+e,
e);
if(!persistent)
- getter.onFailure(new
LowLevelGetException(LowLevelGetException.DECODE_FAILED), tok, this, null,
clientContext);
+ getter.onFailure(new
LowLevelGetException(LowLevelGetException.DECODE_FAILED), tok, null,
clientContext);
else {
final SendableGet g = getter;
final Object token = tok;
@@ -298,7 +298,7 @@
public void run(ObjectContainer
container, ClientContext context) {
container.activate(g,
1);
- g.onFailure(new
LowLevelGetException(LowLevelGetException.DECODE_FAILED), token,
ClientRequestScheduler.this, container, context);
+ g.onFailure(new
LowLevelGetException(LowLevelGetException.DECODE_FAILED), token, container,
context);
}
}, NativeThread.NORM_PRIORITY, false);
@@ -308,7 +308,7 @@
if(block != null) {
if(logMINOR) Logger.minor(this, "Can fulfill
"+getter+" ("+tok+") immediately from store");
if(!persistent)
- getter.onSuccess(block, true, tok,
this, null, clientContext);
+ getter.onSuccess(block, true, tok,
null, clientContext);
else {
final ClientKeyBlock b = block;
final Object t = tok;
@@ -318,12 +318,12 @@
public void
run(ObjectContainer container, ClientContext context) {
container.activate(g, 1);
- g.onSuccess(b,
true, t, ClientRequestScheduler.this, container, context);
+ g.onSuccess(b,
true, t, container, context);
}
}, NativeThread.NORM_PRIORITY,
false);
} else {
- g.onSuccess(b, true, t,
ClientRequestScheduler.this, null, clientContext);
+ g.onSuccess(b, true, t, null,
clientContext);
}
}
} else {
@@ -556,7 +556,7 @@
for(int i=0;i<transientGets.length;i++)
{
try {
if(logMINOR)
Logger.minor(this, "Calling callback for "+transientGets[i]+" for "+key);
-
transientGets[i].onGotKey(key, block, ClientRequestScheduler.this, null,
clientContext);
+
transientGets[i].onGotKey(key, block, null, clientContext);
} catch (Throwable t) {
Logger.error(this,
"Caught "+t+" running callback "+transientGets[i]+" for "+key);
}
@@ -587,7 +587,7 @@
for(int i=0;i<gets.length;i++) {
try {
if(logMINOR) Logger.minor(this,
"Calling callback for "+gets[i]+" for "+key);
- gets[i].onGotKey(key, block,
ClientRequestScheduler.this, container, context);
+ gets[i].onGotKey(key, block,
container, context);
} catch (Throwable t) {
Logger.error(this, "Caught
"+t+" running callback "+gets[i]+" for "+key);
}
@@ -706,7 +706,7 @@
public void run(ObjectContainer container,
ClientContext context) {
container.activate(get, 1);
- get.onFailure(e, keyNum,
ClientRequestScheduler.this, selectorContainer, clientContext);
+ get.onFailure(e, keyNum, selectorContainer,
clientContext);
if(get.persistent())
selectorContainer.delete((PersistentChosenRequest)req);
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -43,47 +43,47 @@
final long token;
// Translate it, then call the real onFailure
- public void onFailure(LowLevelGetException e, Object reqTokenIgnored,
RequestScheduler sched, ObjectContainer container, ClientContext context) {
+ public void onFailure(LowLevelGetException e, Object reqTokenIgnored,
ObjectContainer container, ClientContext context) {
switch(e.code) {
case LowLevelGetException.DATA_NOT_FOUND:
- onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), false, container, context);
return;
case LowLevelGetException.DATA_NOT_FOUND_IN_STORE:
- onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), false, container, context);
return;
case LowLevelGetException.RECENTLY_FAILED:
- onFailure(new
FetchException(FetchException.RECENTLY_FAILED), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.RECENTLY_FAILED), false, container, context);
return;
case LowLevelGetException.DECODE_FAILED:
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), false, container, context);
return;
case LowLevelGetException.INTERNAL_ERROR:
- onFailure(new
FetchException(FetchException.INTERNAL_ERROR), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INTERNAL_ERROR), false, container, context);
return;
case LowLevelGetException.REJECTED_OVERLOAD:
- onFailure(new
FetchException(FetchException.REJECTED_OVERLOAD), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.REJECTED_OVERLOAD), false, container, context);
return;
case LowLevelGetException.ROUTE_NOT_FOUND:
- onFailure(new
FetchException(FetchException.ROUTE_NOT_FOUND), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.ROUTE_NOT_FOUND), false, container, context);
return;
case LowLevelGetException.TRANSFER_FAILED:
- onFailure(new
FetchException(FetchException.TRANSFER_FAILED), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.TRANSFER_FAILED), false, container, context);
return;
case LowLevelGetException.VERIFY_FAILED:
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), false, container, context);
return;
case LowLevelGetException.CANCELLED:
- onFailure(new FetchException(FetchException.CANCELLED),
false, sched, container, context);
+ onFailure(new FetchException(FetchException.CANCELLED),
false, container, context);
return;
default:
Logger.error(this, "Unknown LowLevelGetException code:
"+e.code);
- onFailure(new
FetchException(FetchException.INTERNAL_ERROR), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INTERNAL_ERROR), false, container, context);
return;
}
}
// Real onFailure
- protected void onFailure(FetchException e, boolean forceFatal,
RequestScheduler sched, ObjectContainer container, ClientContext context) {
+ protected void onFailure(FetchException e, boolean forceFatal,
ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(parent, 1);
container.activate(rcb, 1);
@@ -96,7 +96,7 @@
forceFatal = true;
}
if(!(e.isFatal() || forceFatal) ) {
- if(retry(sched, container, context)) {
+ if(retry(container, context)) {
if(logMINOR) Logger.minor(this, "Retrying");
return;
}
@@ -111,7 +111,7 @@
}
/** Will be overridden by SingleFileFetcher */
- protected void onSuccess(FetchResult data, RequestScheduler sched,
ObjectContainer container, ClientContext context) {
+ protected void onSuccess(FetchResult data, ObjectContainer container,
ClientContext context) {
if(persistent) {
container.activate(parent, 1);
container.activate(rcb, 1);
@@ -119,45 +119,45 @@
unregister(false, container);
if(parent.isCancelled()) {
data.asBucket().free();
- onFailure(new FetchException(FetchException.CANCELLED),
false, sched, container, context);
+ onFailure(new FetchException(FetchException.CANCELLED),
false, container, context);
return;
}
rcb.onSuccess(data, this, container, context);
}
- public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
reqTokenIgnored, RequestScheduler sched, ObjectContainer container,
ClientContext context) {
+ public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
reqTokenIgnored, ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(parent, 1);
}
if(parent instanceof ClientGetter)
((ClientGetter)parent).addKeyToBinaryBlob(block,
container, context);
- Bucket data = extract(block, sched, container, context);
+ Bucket data = extract(block, container, context);
if(data == null) return; // failed
if(!block.isMetadata()) {
- onSuccess(new FetchResult((ClientMetadata)null, data),
sched, container, context);
+ onSuccess(new FetchResult((ClientMetadata)null, data),
container, context);
} else {
- onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), false, sched, container, context);
+ onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), false, container, context);
}
}
/** Convert a ClientKeyBlock to a Bucket. If an error occurs, report it
via onFailure
* and return null.
*/
- protected Bucket extract(ClientKeyBlock block, RequestScheduler sched,
ObjectContainer container, ClientContext context) {
+ protected Bucket extract(ClientKeyBlock block, ObjectContainer
container, ClientContext context) {
Bucket data;
try {
data =
block.decode(context.getBucketFactory(parent.persistent()),
(int)(Math.min(ctx.maxOutputLength, Integer.MAX_VALUE)), false);
} catch (KeyDecodeException e1) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Decode failure: "+e1, e1);
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e1.getMessage()), false,
sched, container, context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e1.getMessage()), false,
container, context);
return null;
} catch (TooBigException e) {
- onFailure(new FetchException(FetchException.TOO_BIG,
e), false, sched, container, context);
+ onFailure(new FetchException(FetchException.TOO_BIG,
e), false, container, context);
return null;
} catch (IOException e) {
Logger.error(this, "Could not capture data - disk
full?: "+e, e);
- onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, container, context);
return null;
}
return data;
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -59,7 +59,6 @@
private final Bucket returnBucket;
/** If true, success/failure is immediately reported to the client, and
therefore we can check TOO_MANY_PATH_COMPONENTS. */
private final boolean isFinal;
- private RequestScheduler sched;
/** Create a new SingleFileFetcher and register self.
* Called when following a redirect, or direct from ClientGet.
@@ -123,8 +122,7 @@
// Process the completed data. May result in us going to a
// splitfile, or another SingleFileFetcher, etc.
- public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, RequestScheduler sched, ObjectContainer container, ClientContext
context) {
- this.sched = sched;
+ public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(parent, 1);
container.activate(ctx, 1);
@@ -138,7 +136,7 @@
Logger.error(this, "block is null!
fromStore="+fromStore+", token="+token, new Exception("error"));
return;
}
- Bucket data = extract(block, sched, container, context);
+ Bucket data = extract(block, container, context);
if(data == null) {
if(logMINOR)
Logger.minor(this, "No data");
@@ -148,18 +146,18 @@
if(logMINOR)
Logger.minor(this, "Block "+(block.isMetadata() ? "is
metadata" : "is not metadata")+" on "+this);
if(!block.isMetadata()) {
- onSuccess(new FetchResult(clientMetadata, data), sched,
container, context);
+ onSuccess(new FetchResult(clientMetadata, data),
container, context);
} else {
if(!ctx.followRedirects) {
- onFailure(new
FetchException(FetchException.INVALID_METADATA, "Told me not to follow
redirects (splitfile block??)"), false, sched, container, context);
+ onFailure(new
FetchException(FetchException.INVALID_METADATA, "Told me not to follow
redirects (splitfile block??)"), false, container, context);
return;
}
if(parent.isCancelled()) {
- onFailure(new
FetchException(FetchException.CANCELLED), false, sched, container, context);
+ onFailure(new
FetchException(FetchException.CANCELLED), false, container, context);
return;
}
if(data.size() > ctx.maxMetadataSize) {
- onFailure(new
FetchException(FetchException.TOO_BIG_METADATA), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.TOO_BIG_METADATA), false, container, context);
return;
}
// Parse metadata
@@ -168,25 +166,24 @@
if(persistent)
container.set(this);
} catch (MetadataParseException e) {
- onFailure(new FetchException(e), false, sched,
container, context);
+ onFailure(new FetchException(e), false,
container, context);
return;
} catch (IOException e) {
// Bucket error?
- onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, container, context);
return;
}
wrapHandleMetadata(false, container, context);
}
}
- protected void onSuccess(FetchResult result, RequestScheduler sched,
ObjectContainer container, ClientContext context) {
- this.sched = sched;
+ protected void onSuccess(FetchResult result, ObjectContainer container,
ClientContext context) {
unregister(false, container);
if(parent.isCancelled()) {
if(logMINOR)
Logger.minor(this, "Parent is cancelled");
result.asBucket().free();
- onFailure(new FetchException(FetchException.CANCELLED),
false, sched, container, context);
+ onFailure(new FetchException(FetchException.CANCELLED),
false, container, context);
return;
}
if(persistent) {
@@ -203,10 +200,10 @@
long maxLen =
Math.max(ctx.maxTempLength, ctx.maxOutputLength);
data = c.decompress(data,
context.getBucketFactory(parent.persistent()), maxLen, maxLen * 4,
decompressors.isEmpty() ? returnBucket : null);
} catch (IOException e) {
- onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, container, context);
return;
} catch (CompressionOutputSizeException e) {
- onFailure(new
FetchException(FetchException.TOO_BIG, e.estimatedSize, (rcb == parent),
result.getMimeType()), false, sched, container, context);
+ onFailure(new
FetchException(FetchException.TOO_BIG, e.estimatedSize, (rcb == parent),
result.getMimeType()), false, container, context);
return;
}
}
@@ -313,22 +310,22 @@
wrapHandleMetadata(true, container, context);
} catch
(MetadataParseException e) {
// Invalid
metadata
- onFailure(new
FetchException(FetchException.INVALID_METADATA, e), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INVALID_METADATA, e), false, container, context);
return;
} catch (IOException e)
{
// Bucket error?
- onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, container, context);
return;
}
}
public void
notInArchive(ObjectContainer container, ClientContext context) {
- onFailure(new
FetchException(FetchException.INTERNAL_ERROR, "No metadata in container! Cannot
happen as ArchiveManager should synthesise some!"), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INTERNAL_ERROR, "No metadata in container! Cannot
happen as ArchiveManager should synthesise some!"), false, container, context);
}
public void
onFailed(ArchiveRestartException e, ObjectContainer container, ClientContext
context) {
-
SingleFileFetcher.this.onFailure(new FetchException(e), false, sched,
container, context);
+
SingleFileFetcher.this.onFailure(new FetchException(e), false, container,
context);
}
public void
onFailed(ArchiveFailureException e, ObjectContainer container, ClientContext
context) {
-
SingleFileFetcher.this.onFailure(new FetchException(e), false, sched,
container, context);
+
SingleFileFetcher.this.onFailure(new FetchException(e), false, container,
context);
}
}, container, context); // will result
in this function being called again
if(persistent) container.set(this);
@@ -367,7 +364,7 @@
throw new
FetchException(FetchException.BUCKET_ERROR);
}
// Return the data
- onSuccess(new
FetchResult(clientMetadata, out), sched, container, context);
+ onSuccess(new
FetchResult(clientMetadata, out), container, context);
return;
} else {
@@ -389,20 +386,20 @@
out =
data;
}
} catch (IOException e)
{
- onFailure(new
FetchException(FetchException.BUCKET_ERROR), false, sched, container, context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR), false, container, context);
return;
}
// Return the data
- onSuccess(new
FetchResult(clientMetadata, out), sched, container, context);
+ onSuccess(new
FetchResult(clientMetadata, out), container, context);
}
public void
notInArchive(ObjectContainer container, ClientContext context) {
- onFailure(new
FetchException(FetchException.NOT_IN_ARCHIVE), false, sched, container,
context);
+ onFailure(new
FetchException(FetchException.NOT_IN_ARCHIVE), false, container, context);
}
public void
onFailed(ArchiveRestartException e, ObjectContainer container, ClientContext
context) {
-
SingleFileFetcher.this.onFailure(new FetchException(e), false, sched,
container, context);
+
SingleFileFetcher.this.onFailure(new FetchException(e), false, container,
context);
}
public void
onFailed(ArchiveFailureException e, ObjectContainer container, ClientContext
context) {
-
SingleFileFetcher.this.onFailure(new FetchException(e), false, sched,
container, context);
+
SingleFileFetcher.this.onFailure(new FetchException(e), false, container,
context);
}
}, container, context);
// Will call back into this function
when it has been fetched.
@@ -625,15 +622,15 @@
try {
handleMetadata(container, context);
} catch (MetadataParseException e) {
- onFailure(new FetchException(e), false, sched,
container, context);
+ onFailure(new FetchException(e), false, container,
context);
} catch (FetchException e) {
if(notFinalizedSize)
e.setNotFinalizedSize();
- onFailure(e, false, sched, container, context);
+ onFailure(e, false, container, context);
} catch (ArchiveFailureException e) {
- onFailure(new FetchException(e), false, sched,
container, context);
+ onFailure(new FetchException(e), false, container,
context);
} catch (ArchiveRestartException e) {
- onFailure(new FetchException(e), false, sched,
container, context);
+ onFailure(new FetchException(e), false, container,
context);
}
}
@@ -673,10 +670,10 @@
try {
ah.extractToCache(result.asBucket(), actx,
element, callback, context.archiveManager, container, context);
} catch (ArchiveFailureException e) {
- SingleFileFetcher.this.onFailure(new
FetchException(e), false, sched, container, context);
+ SingleFileFetcher.this.onFailure(new
FetchException(e), false, container, context);
return;
} catch (ArchiveRestartException e) {
- SingleFileFetcher.this.onFailure(new
FetchException(e), false, sched, container, context);
+ SingleFileFetcher.this.onFailure(new
FetchException(e), false, container, context);
return;
}
if(callback != null) return;
@@ -687,7 +684,7 @@
if(persistent)
container.activate(SingleFileFetcher.this, 1);
// Force fatal as the fetcher is presumed to have made
a reasonable effort.
- SingleFileFetcher.this.onFailure(e, true, sched,
container, context);
+ SingleFileFetcher.this.onFailure(e, true, container,
context);
}
public void onBlockSetFinished(ClientGetState state,
ObjectContainer container, ClientContext context) {
@@ -726,11 +723,11 @@
try {
metadata =
Metadata.construct(result.asBucket());
} catch (MetadataParseException e) {
- SingleFileFetcher.this.onFailure(new
FetchException(FetchException.INVALID_METADATA, e), false, sched, container,
context);
+ SingleFileFetcher.this.onFailure(new
FetchException(FetchException.INVALID_METADATA, e), false, container, context);
return;
} catch (IOException e) {
// Bucket error?
- SingleFileFetcher.this.onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, sched, container,
context);
+ SingleFileFetcher.this.onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), false, container, context);
return;
}
wrapHandleMetadata(true, container, context);
@@ -740,7 +737,7 @@
if(persistent)
container.activate(SingleFileFetcher.this, 1);
// Pass it on; fetcher is assumed to have retried as
appropriate already, so this is fatal.
- SingleFileFetcher.this.onFailure(e, true, sched,
container, context);
+ SingleFileFetcher.this.onFailure(e, true, container,
context);
}
public void onBlockSetFinished(ClientGetState state,
ObjectContainer container, ClientContext context) {
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -158,14 +158,14 @@
return fatallyFailedBlocks;
}
- public void onSuccess(Bucket data, int blockNo,
SplitFileFetcherSubSegment seg, ClientKeyBlock block, ObjectContainer
container, RequestScheduler sched) {
+ public void onSuccess(Bucket data, int blockNo,
SplitFileFetcherSubSegment seg, ClientKeyBlock block, ObjectContainer
container, ClientContext context) {
if(persistent)
container.activate(this, 1);
boolean decodeNow = false;
logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this, "Fetched block "+blockNo+" on
"+seg);
if(parentFetcher.parent instanceof ClientGetter)
-
((ClientGetter)parentFetcher.parent).addKeyToBinaryBlob(block, container,
sched.getContext());
+
((ClientGetter)parentFetcher.parent).addKeyToBinaryBlob(block, container,
context);
// No need to unregister key, because it will be cleared in
tripPendingKey().
boolean dontNotify;
synchronized(this) {
@@ -209,26 +209,26 @@
}
if(persistent)
container.set(this);
- parentFetcher.parent.completedBlock(dontNotify, container,
sched.getContext());
+ parentFetcher.parent.completedBlock(dontNotify, container,
context);
seg.possiblyRemoveFromParent(container);
if(decodeNow) {
removeSubSegments(container);
- decode(container, sched.getContext(), sched);
+ decode(container, context);
}
}
- public void decode(ObjectContainer container, ClientContext context,
RequestScheduler sched) {
+ public void decode(ObjectContainer container, ClientContext context) {
if(persistent)
container.activate(this, 1);
// Now decode
if(logMINOR) Logger.minor(this, "Decoding
"+SplitFileFetcherSegment.this);
- codec = FECCodec.getCodec(splitfileType, dataKeys.length,
checkKeys.length, sched.getContext().mainExecutor);
+ codec = FECCodec.getCodec(splitfileType, dataKeys.length,
checkKeys.length, context.mainExecutor);
if(persistent)
container.set(this);
if(splitfileType != Metadata.SPLITFILE_NONREDUNDANT) {
- FECQueue queue = sched.getFECQueue();
+ FECQueue queue = context.fecQueue;
codec.addToQueue(new FECJob(codec, queue, dataBuckets,
checkBuckets, CHKBlock.DATA_LENGTH,
context.getBucketFactory(parentFetcher.parent.persistent()), this, true,
parentFetcher.parent.getPriorityClass(), parentFetcher.parent.persistent()),
queue, container);
// Now have all the data blocks (not necessarily all
the check blocks)
@@ -429,10 +429,10 @@
/** A request has failed non-fatally, so the block may be retried
* @param container */
- public void onNonFatalFailure(FetchException e, int blockNo,
SplitFileFetcherSubSegment seg, RequestScheduler sched, ObjectContainer
container) {
+ public void onNonFatalFailure(FetchException e, int blockNo,
SplitFileFetcherSubSegment seg, ObjectContainer container, ClientContext
context) {
if(persistent)
container.activate(this, 1);
- ClientContext context = sched.getContext();
+ RequestScheduler sched = context.getFetchScheduler(false);
int tries;
int maxTries = blockFetchContext.maxNonSplitfileRetries;
boolean failed = false;
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-06-26 16:52:51 UTC (rev 20757)
+++
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -198,49 +198,49 @@
// Translate it, then call the real onFailure
// FIXME refactor this out to a common method; see
SimpleSingleFileFetcher
- public void onFailure(LowLevelGetException e, Object token,
RequestScheduler sched, ObjectContainer container, ClientContext context) {
+ public void onFailure(LowLevelGetException e, Object token,
ObjectContainer container, ClientContext context) {
if(logMINOR)
Logger.minor(this, "onFailure("+e+" , "+token);
switch(e.code) {
case LowLevelGetException.DATA_NOT_FOUND:
- onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), token, container, context);
return;
case LowLevelGetException.DATA_NOT_FOUND_IN_STORE:
- onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.DATA_NOT_FOUND), token, container, context);
return;
case LowLevelGetException.RECENTLY_FAILED:
- onFailure(new
FetchException(FetchException.RECENTLY_FAILED), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.RECENTLY_FAILED), token, container, context);
return;
case LowLevelGetException.DECODE_FAILED:
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), token, container, context);
return;
case LowLevelGetException.INTERNAL_ERROR:
- onFailure(new
FetchException(FetchException.INTERNAL_ERROR), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INTERNAL_ERROR), token, container, context);
return;
case LowLevelGetException.REJECTED_OVERLOAD:
- onFailure(new
FetchException(FetchException.REJECTED_OVERLOAD), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.REJECTED_OVERLOAD), token, container, context);
return;
case LowLevelGetException.ROUTE_NOT_FOUND:
- onFailure(new
FetchException(FetchException.ROUTE_NOT_FOUND), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.ROUTE_NOT_FOUND), token, container, context);
return;
case LowLevelGetException.TRANSFER_FAILED:
- onFailure(new
FetchException(FetchException.TRANSFER_FAILED), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.TRANSFER_FAILED), token, container, context);
return;
case LowLevelGetException.VERIFY_FAILED:
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR), token, container, context);
return;
case LowLevelGetException.CANCELLED:
- onFailure(new FetchException(FetchException.CANCELLED),
token, sched, container, context);
+ onFailure(new FetchException(FetchException.CANCELLED),
token, container, context);
return;
default:
Logger.error(this, "Unknown LowLevelGetException code:
"+e.code);
- onFailure(new
FetchException(FetchException.INTERNAL_ERROR), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.INTERNAL_ERROR), token, container, context);
return;
}
}
// Real onFailure
- protected void onFailure(FetchException e, Object token,
RequestScheduler sched, ObjectContainer container, ClientContext context) {
+ protected void onFailure(FetchException e, Object token,
ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(segment, 1);
container.activate(parent, 1);
@@ -258,17 +258,17 @@
} else if(e.isFatal() || forceFatal) {
segment.onFatalFailure(e, ((Integer)token).intValue(),
this, container, context);
} else {
- segment.onNonFatalFailure(e,
((Integer)token).intValue(), this, sched, container);
+ segment.onNonFatalFailure(e,
((Integer)token).intValue(), this, container, context);
}
}
- public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, RequestScheduler sched, ObjectContainer container, ClientContext
context) {
+ public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(this, 1);
container.activate(segment, 1);
container.activate(blockNums, 1);
}
- Bucket data = extract(block, token, sched, container);
+ Bucket data = extract(block, token, container, context);
if(fromStore) {
// Normally when this method is called the block number
has already
// been removed. However if fromStore=true, it won't
have been, so
@@ -290,13 +290,13 @@
container.set(blockNums);
}
if(!block.isMetadata()) {
- onSuccess(data, fromStore, (Integer)token,
((Integer)token).intValue(), block, sched, container);
+ onSuccess(data, fromStore, (Integer)token,
((Integer)token).intValue(), block, container, context);
} else {
- onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), token, sched, container, context);
+ onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), token, container, context);
}
}
- protected void onSuccess(Bucket data, boolean fromStore, Integer token,
int blockNo, ClientKeyBlock block, RequestScheduler sched, ObjectContainer
container) {
+ protected void onSuccess(Bucket data, boolean fromStore, Integer token,
int blockNo, ClientKeyBlock block, ObjectContainer container, ClientContext
context) {
if(persistent) {
container.activate(this, 1);
container.activate(segment, 1);
@@ -304,31 +304,30 @@
}
if(parent.isCancelled()) {
data.free();
- onFailure(new FetchException(FetchException.CANCELLED),
token, sched, container, sched.getContext());
+ onFailure(new FetchException(FetchException.CANCELLED),
token, container, context);
return;
}
- segment.onSuccess(data, blockNo, this, block, container, sched);
+ segment.onSuccess(data, blockNo, this, block, container,
context);
}
/** Convert a ClientKeyBlock to a Bucket. If an error occurs, report it
via onFailure
* and return null.
*/
- protected Bucket extract(ClientKeyBlock block, Object token,
RequestScheduler sched, ObjectContainer container) {
- ClientContext context = sched.getContext();
+ protected Bucket extract(ClientKeyBlock block, Object token,
ObjectContainer container, ClientContext context) {
Bucket data;
try {
- data =
block.decode(sched.getContext().getBucketFactory(persistent),
(int)(Math.min(ctx.maxOutputLength, Integer.MAX_VALUE)), false);
+ data =
block.decode(context.getBucketFactory(persistent),
(int)(Math.min(ctx.maxOutputLength, Integer.MAX_VALUE)), false);
} catch (KeyDecodeException e1) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Decode failure: "+e1, e1);
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e1.getMessage()), token,
sched, container, context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e1.getMessage()), token,
container, context);
return null;
} catch (TooBigException e) {
- onFailure(new FetchException(FetchException.TOO_BIG,
e.getMessage()), token, sched, container, context);
+ onFailure(new FetchException(FetchException.TOO_BIG,
e.getMessage()), token, container, context);
return null;
} catch (IOException e) {
Logger.error(this, "Could not capture data - disk
full?: "+e, e);
- onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BUCKET_ERROR, e), token, container, context);
return null;
}
if(Logger.shouldLog(Logger.MINOR, this))
@@ -450,7 +449,7 @@
unregister(false, container);
}
- public void onGotKey(Key key, KeyBlock block, RequestScheduler sched,
ObjectContainer container, ClientContext context) {
+ public void onGotKey(Key key, KeyBlock block, ObjectContainer
container, ClientContext context) {
if(persistent) {
container.activate(this, 1);
container.activate(segment, 1);
@@ -482,15 +481,15 @@
try {
cb = new ClientCHKBlock((CHKBlock)block, ckey);
} catch (CHKVerifyException e) {
- onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e), token, sched, container,
context);
+ onFailure(new
FetchException(FetchException.BLOCK_DECODE_ERROR, e), token, container,
context);
return;
}
- Bucket data = extract(cb, token, sched, container);
+ Bucket data = extract(cb, token, container, context);
if(!cb.isMetadata()) {
- onSuccess(data, false, (Integer)token,
((Integer)token).intValue(), cb, sched, container);
+ onSuccess(data, false, (Integer)token,
((Integer)token).intValue(), cb, container, context);
} else {
- onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), token, sched, container, context);
+ onFailure(new
FetchException(FetchException.INVALID_METADATA, "Metadata where expected
data"), token, container, context);
}
}
Modified: branches/db4o/freenet/src/freenet/client/async/USKChecker.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/USKChecker.java
2008-06-26 16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/client/async/USKChecker.java
2008-06-26 17:07:27 UTC (rev 20758)
@@ -28,7 +28,7 @@
this.cb = cb;
}
- public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, RequestScheduler sched, ObjectContainer container, ClientContext
context) {
+ public void onSuccess(ClientKeyBlock block, boolean fromStore, Object
token, ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(this, 1);
container.activate(cb, 1);
@@ -37,7 +37,7 @@
cb.onSuccess((ClientSSKBlock)block, context);
}
- public void onFailure(LowLevelGetException e, Object token,
RequestScheduler sched, ObjectContainer container, ClientContext context) {
+ public void onFailure(LowLevelGetException e, Object token,
ObjectContainer container, ClientContext context) {
if(persistent) {
container.activate(this, 1);
container.activate(cb, 1);
@@ -71,7 +71,7 @@
canRetry = true;
}
- if(canRetry && retry(sched, container, context)) return;
+ if(canRetry && retry(container, context)) return;
// Ran out of retries.
unregister(false, container);
Modified: branches/db4o/freenet/src/freenet/node/SendableGet.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-06-26
16:52:51 UTC (rev 20757)
+++ branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-06-26
17:07:27 UTC (rev 20758)
@@ -41,10 +41,10 @@
public abstract FetchContext getContext();
/** Called when/if the low-level request succeeds. */
- public abstract void onSuccess(ClientKeyBlock block, boolean fromStore,
Object token, RequestScheduler sched, ObjectContainer container, ClientContext
context);
+ public abstract void onSuccess(ClientKeyBlock block, boolean fromStore,
Object token, ObjectContainer container, ClientContext context);
/** Called when/if the low-level request fails. */
- public abstract void onFailure(LowLevelGetException e, Object token,
RequestScheduler sched, ObjectContainer container, ClientContext context);
+ public abstract void onFailure(LowLevelGetException e, Object token,
ObjectContainer container, ClientContext context);
/** Should the request ignore the datastore? */
public abstract boolean ignoreStore();
@@ -119,7 +119,7 @@
* @param block
* @param sched
*/
- public abstract void onGotKey(Key key, KeyBlock block, RequestScheduler
sched, ObjectContainer container, ClientContext context);
+ public abstract void onGotKey(Key key, KeyBlock block, ObjectContainer
container, ClientContext context);
/**
* Get the time at which the key specified by the given token will wake
up from the