Author: toad
Date: 2008-06-19 20:57:54 +0000 (Thu, 19 Jun 2008)
New Revision: 20502
Modified:
branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java
branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
branches/db4o/freenet/src/freenet/client/async/GetCompletionCallback.java
branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
branches/db4o/freenet/src/freenet/client/async/PutCompletionCallback.java
branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
branches/db4o/freenet/src/freenet/client/async/USKFetcherWrapper.java
branches/db4o/freenet/src/freenet/client/async/USKInserter.java
branches/db4o/freenet/src/freenet/client/async/USKProxyCompletionCallback.java
branches/db4o/freenet/src/freenet/client/async/USKRetriever.java
branches/db4o/freenet/src/freenet/client/events/ClientEventListener.java
branches/db4o/freenet/src/freenet/client/events/ClientEventProducer.java
branches/db4o/freenet/src/freenet/client/events/EventDumper.java
branches/db4o/freenet/src/freenet/client/events/EventLogger.java
branches/db4o/freenet/src/freenet/client/events/SimpleEventProducer.java
Log:
Pass ObjectContainer and ClientContext through event notifications.
The former is unreliable: it will be null if the caller wasn't transactional,
even if the recipient needs a transaction. But most of the time it's there, and
when it isn't the recipient can queue a job using the context.
ClientRequestor.notifyClients() therefore needs the parameters, as do several
things depending on it.
Passing arguments around is somewhat ugly, but it beats static in a few ways:
- Upgradeable to client/server-in-a-single-VM.
- Compatible with multiple nodes with separate client layers in a single VM.
- Prevents a lot of manual (developer) checking of whether we are on the
database thread or not: if we have a container, we're on the database thread.
We may move to static later on though for less ugliness. We'll see.
Modified: branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -35,7 +35,7 @@
private boolean fatal;
final InsertContext ctx;
- BinaryBlobInserter(Bucket blob, ClientPutter parent, RequestClient
clientContext, boolean tolerant, short prioClass, InsertContext ctx,
ClientContext context)
+ BinaryBlobInserter(Bucket blob, ClientPutter parent, RequestClient
clientContext, boolean tolerant, short prioClass, InsertContext ctx,
ClientContext context, ObjectContainer container)
throws IOException, BinaryBlobFormatException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.ctx = ctx;
@@ -66,7 +66,7 @@
inserters = (MySendableInsert[]) myInserters.toArray(new
MySendableInsert[myInserters.size()]);
parent.addMustSucceedBlocks(inserters.length);
- parent.notifyClients();
+ parent.notifyClients(container, context);
}
private ClientRequestScheduler getScheduler(KeyBlock block,
ClientContext context) {
@@ -122,7 +122,7 @@
completedBlocks++;
succeededBlocks++;
}
- parent.completedBlock(false);
+ parent.completedBlock(false, container, context);
maybeFinish(container, context);
}
@@ -185,9 +185,9 @@
if(fatal) BinaryBlobInserter.this.fatal = true;
}
if(fatal)
- parent.fatallyFailedBlock();
+ parent.fatallyFailedBlock(container, context);
else
- parent.failedBlock();
+ parent.failedBlock(container, context);
maybeFinish(container, context);
}
Modified: branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -219,14 +219,14 @@
return uri;
}
- public void notifyClients() {
- ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized));
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
+ ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized), container, context);
}
- public void onBlockSetFinished(ClientGetState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientGetState state, ObjectContainer
container, ClientContext context) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Set finished", new
Exception("debug"));
- blockSetFinalized();
+ blockSetFinalized(container, context);
}
public void onTransition(ClientGetState oldState, ClientGetState
newState, ObjectContainer container) {
Modified: branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -102,7 +102,7 @@
false,
getCHKOnly, false, null, false, false, targetFilename, earlyEncode);
else
currentState =
- new
BinaryBlobInserter(data, this, null, false, priorityClass, ctx, context);
+ new
BinaryBlobInserter(data, this, null, false, priorityClass, ctx, context,
container);
}
}
if(cancel) {
@@ -242,14 +242,14 @@
Logger.error(this, "Got metadata on "+this+" from "+state+"
(this means the metadata won't be inserted)");
}
- public void notifyClients() {
- ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized));
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
+ ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized), container, context);
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Set finished", new
Exception("debug"));
- blockSetFinalized();
+ blockSetFinalized(container, context);
}
public SimpleFieldSet getProgressFieldset() {
Modified: branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -57,14 +57,14 @@
/** Has totalBlocks stopped growing? */
protected boolean blockSetFinalized;
- public void blockSetFinalized() {
+ public void blockSetFinalized(ObjectContainer container, ClientContext
context) {
synchronized(this) {
if(blockSetFinalized) return;
blockSetFinalized = true;
}
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Finalized set of blocks for "+this,
new Exception("debug"));
- notifyClients();
+ notifyClients(container, context);
}
public synchronized void addBlock() {
@@ -87,28 +87,28 @@
if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this,
"addBlocks("+num+"): total="+totalBlocks+" successful="+successfulBlocks+"
failed="+failedBlocks+" required="+minSuccessBlocks);
}
- public void completedBlock(boolean dontNotify) {
+ public void completedBlock(boolean dontNotify, ObjectContainer
container, ClientContext context) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Completed block ("+dontNotify+ "):
total="+totalBlocks+" success="+successfulBlocks+" failed="+failedBlocks+"
fatally="+fatallyFailedBlocks+" finalised="+blockSetFinalized+"
required="+minSuccessBlocks+" on "+this);
synchronized(this) {
successfulBlocks++;
if(dontNotify) return;
}
- notifyClients();
+ notifyClients(container, context);
}
- public void failedBlock() {
+ public void failedBlock(ObjectContainer container, ClientContext
context) {
synchronized(this) {
failedBlocks++;
}
- notifyClients();
+ notifyClients(container, context);
}
- public void fatallyFailedBlock() {
+ public void fatallyFailedBlock(ObjectContainer container, ClientContext
context) {
synchronized(this) {
fatallyFailedBlocks++;
}
- notifyClients();
+ notifyClients(container, context);
}
public synchronized void addMustSucceedBlocks(int blocks) {
@@ -116,7 +116,7 @@
if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this,
"addMustSucceedBlocks("+blocks+"): total="+totalBlocks+"
successful="+successfulBlocks+" failed="+failedBlocks+"
required="+minSuccessBlocks);
}
- public abstract void notifyClients();
+ public abstract void notifyClients(ObjectContainer container,
ClientContext context);
/** Get client context object */
public RequestClient getClient() {
@@ -135,4 +135,9 @@
return client.persistent();
}
+
+ public void removeFrom(ObjectContainer container) {
+ // TODO FIXME do something!
+ }
+
}
Modified:
branches/db4o/freenet/src/freenet/client/async/GetCompletionCallback.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/GetCompletionCallback.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/GetCompletionCallback.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -21,7 +21,7 @@
/** Called when the ClientGetState knows that it knows about
* all the blocks it will need to fetch.
*/
- public void onBlockSetFinished(ClientGetState state, ObjectContainer
container);
+ public void onBlockSetFinished(ClientGetState state, ObjectContainer
container, ClientContext context);
public void onTransition(ClientGetState oldState, ClientGetState
newState, ObjectContainer container);
Modified: branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -68,7 +68,7 @@
try {
for(int i=0;i<algos;i++) {
// Only produce if we are compressing *the
original data*
- inserter.onStartCompression(i);
+ inserter.onStartCompression(i, null, context);
Compressor comp =
Compressor.getCompressionAlgorithmByDifficulty(i);
Bucket result;
result = comp.compress(origData, bucketFactory,
origData.size());
Modified:
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
2008-06-19 19:36:33 UTC (rev 20501)
+++
branches/db4o/freenet/src/freenet/client/async/MultiPutCompletionCallback.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -37,7 +37,7 @@
}
public void onSuccess(ClientPutState state, ObjectContainer container,
ClientContext context) {
- onBlockSetFinished(state, container);
+ onBlockSetFinished(state, container, context);
onFetchable(state, container);
synchronized(this) {
if(finished) return;
@@ -100,7 +100,7 @@
}
if(allGotBlocks) {
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
}
if(allDone) {
complete(e, container, context);
@@ -150,13 +150,13 @@
}
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
synchronized(this) {
this.waitingForBlockSet.remove(state);
if(!started) return;
if(!waitingForBlockSet.isEmpty()) return;
}
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
}
public void schedule(ObjectContainer container, ClientContext context)
throws InsertException {
Modified:
branches/db4o/freenet/src/freenet/client/async/PutCompletionCallback.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/PutCompletionCallback.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/PutCompletionCallback.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -34,6 +34,6 @@
/** Called when the ClientPutState knows that it knows about
* all the blocks it will need to put.
*/
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container);
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context);
}
Modified: branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -43,7 +43,7 @@
try {
sbi = new SingleBlockInserter(this, data,
(short)-1,
FreenetURI.EMPTY_CHK_URI, ctx, this, false,
- CHKBlock.DATA_LENGTH,
ctr, false, false, false, data);
+ CHKBlock.DATA_LENGTH,
ctr, false, false, false, data, null, context);
} catch (Throwable e) {
Logger.error(this, "Caught trying to insert
healing block: "+e, e);
return false;
@@ -78,7 +78,7 @@
return false;
}
- public void notifyClients() {
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
// Do nothing
}
@@ -118,7 +118,7 @@
Logger.error(this, "Got metadata on SimpleHealingQueue from
"+state+": "+m, new Exception("debug"));
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
// Ignore
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -140,32 +140,32 @@
SimpleManifestPutter.this.addBlocks(num);
}
- public void completedBlock(boolean dontNotify) {
- SimpleManifestPutter.this.completedBlock(dontNotify);
+ public void completedBlock(boolean dontNotify, ObjectContainer
container, ClientContext context) {
+ SimpleManifestPutter.this.completedBlock(dontNotify,
container, context);
}
- public void failedBlock() {
- SimpleManifestPutter.this.failedBlock();
+ public void failedBlock(ObjectContainer container,
ClientContext context) {
+ SimpleManifestPutter.this.failedBlock(container,
context);
}
- public void fatallyFailedBlock() {
- SimpleManifestPutter.this.fatallyFailedBlock();
+ public void fatallyFailedBlock(ObjectContainer container,
ClientContext context) {
+ SimpleManifestPutter.this.fatallyFailedBlock(container,
context);
}
public void addMustSucceedBlocks(int blocks) {
SimpleManifestPutter.this.addMustSucceedBlocks(blocks);
}
- public void notifyClients() {
+ public void notifyClients(ObjectContainer container,
ClientContext context) {
// FIXME generate per-filename events???
}
- public void onBlockSetFinished(ClientPutState state,
ObjectContainer container) {
+ public void onBlockSetFinished(ClientPutState state,
ObjectContainer container, ClientContext context) {
synchronized(SimpleManifestPutter.this) {
waitingForBlockSets.remove(this);
if(!waitingForBlockSets.isEmpty()) return;
}
- SimpleManifestPutter.this.blockSetFinalized();
+ SimpleManifestPutter.this.blockSetFinalized(container,
context);
}
public void onMajorProgress() {
@@ -604,24 +604,24 @@
// Ignore
}
- public void notifyClients() {
- ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized));
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
+ ctx.eventProducer.produceEvent(new
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks,
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks,
this.blockSetFinalized), container, context);
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
synchronized(this) {
this.metadataBlockSetFinalized = true;
if(!waitingForBlockSets.isEmpty()) return;
}
- this.blockSetFinalized();
+ this.blockSetFinalized(container, context);
}
- public void blockSetFinalized() {
+ public void blockSetFinalized(ObjectContainer container, ClientContext
context) {
synchronized(this) {
if(!metadataBlockSetFinalized) return;
if(waitingForBlockSets.isEmpty()) return;
}
- super.blockSetFinalized();
+ super.blockSetFinalized(container, context);
}
/**
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -27,7 +27,7 @@
public class SimpleSingleFileFetcher extends BaseSingleFileFetcher implements
ClientGetState {
SimpleSingleFileFetcher(ClientKey key, int maxRetries, FetchContext
ctx, ClientRequester parent,
- GetCompletionCallback rcb, boolean isEssential, boolean
dontAdd, long l) {
+ GetCompletionCallback rcb, boolean isEssential, boolean
dontAdd, long l, ObjectContainer container, ClientContext context) {
super(key, maxRetries, ctx, parent);
this.rcb = rcb;
this.token = l;
@@ -35,7 +35,7 @@
parent.addBlock();
if(isEssential)
parent.addMustSucceedBlocks(1);
- parent.notifyClients();
+ parent.notifyClients(container, context);
}
}
@@ -100,9 +100,9 @@
// :(
unregister(false);
if(e.isFatal() || forceFatal)
- parent.fatallyFailedBlock();
+ parent.fatallyFailedBlock(container, context);
else
- parent.failedBlock();
+ parent.failedBlock(container, context);
rcb.onFailure(e, this, container, context);
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -56,7 +56,7 @@
final int sourceLength;
private int consecutiveRNFs;
- public SingleBlockInserter(BaseClientPutter parent, Bucket data, short
compressionCodec, FreenetURI uri, InsertContext ctx, PutCompletionCallback cb,
boolean isMetadata, int sourceLength, int token, boolean getCHKOnly, boolean
addToParent, boolean dontSendEncoded, Object tokenObject) {
+ public SingleBlockInserter(BaseClientPutter parent, Bucket data, short
compressionCodec, FreenetURI uri, InsertContext ctx, PutCompletionCallback cb,
boolean isMetadata, int sourceLength, int token, boolean getCHKOnly, boolean
addToParent, boolean dontSendEncoded, Object tokenObject, ObjectContainer
container, ClientContext context) {
this.consecutiveRNFs = 0;
this.tokenObject = tokenObject;
this.token = token;
@@ -77,7 +77,7 @@
if(addToParent) {
parent.addBlock();
parent.addMustSucceedBlocks(1);
- parent.notifyClients();
+ parent.notifyClients(container, context);
}
logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
@@ -198,9 +198,9 @@
finished = true;
}
if(e.isFatal() || forceFatal)
- parent.fatallyFailedBlock();
+ parent.fatallyFailedBlock(container, context);
else
- parent.failedBlock();
+ parent.failedBlock(container, context);
cb.onFailure(e, this, container, context);
}
@@ -227,7 +227,7 @@
if(getCHKOnly) {
ClientKeyBlock block = encode(container, context);
cb.onEncode(block.getClientKey(), this, container,
context);
- parent.completedBlock(false);
+ parent.completedBlock(false, container, context);
cb.onSuccess(this, container, context);
finished = true;
} else {
@@ -269,7 +269,7 @@
synchronized(this) {
finished = true;
}
- parent.completedBlock(false);
+ parent.completedBlock(false, container, context);
cb.onSuccess(this, container, context);
}
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -69,8 +69,8 @@
ClientKey key, LinkedList metaStrings, FreenetURI
origURI, int addedMetaStrings, FetchContext ctx,
ArchiveContext actx, ArchiveHandler ah, Metadata
archiveMetadata, int maxRetries, int recursionLevel,
boolean dontTellClientGet, long l, boolean isEssential,
- Bucket returnBucket, boolean isFinal) throws
FetchException {
- super(key, maxRetries, ctx, parent, cb, isEssential, false, l);
+ Bucket returnBucket, boolean isFinal, ObjectContainer
container, ClientContext context) throws FetchException {
+ super(key, maxRetries, ctx, parent, cb, isEssential, false, l,
container, context);
logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this, "Creating SingleFileFetcher for
"+key+" from "+origURI+" meta="+metaStrings.toString(), new Exception("debug"));
this.isFinal = isFinal;
@@ -97,9 +97,9 @@
/** Copy constructor, modifies a few given fields, don't call
schedule().
* Used for things like slave fetchers for MultiLevelMetadata,
therefore does not remember returnBucket,
* metaStrings etc. */
- public SingleFileFetcher(SingleFileFetcher fetcher, Metadata newMeta,
GetCompletionCallback callback, FetchContext ctx2) throws FetchException {
+ public SingleFileFetcher(SingleFileFetcher fetcher, Metadata newMeta,
GetCompletionCallback callback, FetchContext ctx2, ObjectContainer container,
ClientContext context) throws FetchException {
// Don't add a block, we have already fetched the data, we are
just handling the metadata in a different fetcher.
- super(fetcher.key, fetcher.maxRetries, ctx2, fetcher.parent,
callback, false, true, fetcher.token);
+ super(fetcher.key, fetcher.maxRetries, ctx2, fetcher.parent,
callback, false, true, fetcher.token, container, context);
logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR) Logger.minor(this, "Creating SingleFileFetcher for
"+fetcher.key+" meta="+fetcher.metaStrings.toString(), new Exception("debug"));
this.returnBucket = null;
@@ -127,7 +127,7 @@
this.sched = sched;
if(parent instanceof ClientGetter)
((ClientGetter)parent).addKeyToBinaryBlob(block,
container, context);
- parent.completedBlock(fromStore);
+ parent.completedBlock(fromStore, container, context);
// Extract data
if(block == null) {
@@ -388,7 +388,7 @@
if(logMINOR) Logger.minor(this, "Is multi-level
metadata");
// Fetch on a second SingleFileFetcher, like
with archives.
metadata.setSimpleRedirect();
- final SingleFileFetcher f = new
SingleFileFetcher(this, metadata, new MultiLevelMetadataCallback(), ctx);
+ final SingleFileFetcher f = new
SingleFileFetcher(this, metadata, new MultiLevelMetadataCallback(), ctx,
container, context);
// Clear our own metadata so it can be garbage
collected, it will be replaced by whatever is fetched.
this.metadata = null;
f.wrapHandleMetadata(true, container, context);
@@ -442,9 +442,9 @@
addedMetaStrings++;
}
- final SingleFileFetcher f = new
SingleFileFetcher(parent, rcb, clientMetadata, redirectedKey, metaStrings,
this.uri, addedMetaStrings, ctx, actx, ah, archiveMetadata, maxRetries,
recursionLevel, false, token, true, returnBucket, isFinal);
+ final SingleFileFetcher f = new
SingleFileFetcher(parent, rcb, clientMetadata, redirectedKey, metaStrings,
this.uri, addedMetaStrings, ctx, actx, ah, archiveMetadata, maxRetries,
recursionLevel, false, token, true, returnBucket, isFinal, container, context);
if((redirectedKey instanceof ClientCHK) &&
!((ClientCHK)redirectedKey).isMetadata())
- rcb.onBlockSetFinished(this, container);
+ rcb.onBlockSetFinished(this, container,
context);
if(metadata.isCompressed()) {
Compressor codec =
Compressor.getCompressionAlgorithmByMetadataID(metadata.getCompressionCodec());
f.addDecompressor(codec);
@@ -517,7 +517,7 @@
decompressors, clientMetadata,
actx, recursionLevel, returnBucket, token, container);
parent.onTransition(this, sf, container);
sf.schedule(container, context);
- rcb.onBlockSetFinished(this, container);
+ rcb.onBlockSetFinished(this, container,
context);
// Clear our own metadata, we won't need it any
more.
// For multi-level metadata etc see above.
metadata = null;
@@ -554,7 +554,7 @@
Metadata newMeta = (Metadata) meta.clone();
newMeta.setSimpleRedirect();
final SingleFileFetcher f;
- f = new SingleFileFetcher(this, newMeta, new
ArchiveFetcherCallback(forData, element, callback), new FetchContext(ctx,
FetchContext.SET_RETURN_ARCHIVES, true));
+ f = new SingleFileFetcher(this, newMeta, new
ArchiveFetcherCallback(forData, element, callback), new FetchContext(ctx,
FetchContext.SET_RETURN_ARCHIVES, true), container, context);
if(logMINOR) Logger.minor(this, "fetchArchive(): "+f);
// Fetch the archive. The archive fetcher callback will unpack
it, and either call the element
// callback, or just go back around handleMetadata() on this,
which will see that the data is now
@@ -639,9 +639,9 @@
SingleFileFetcher.this.onFailure(e, true, sched,
container, context);
}
- public void onBlockSetFinished(ClientGetState state,
ObjectContainer container) {
+ public void onBlockSetFinished(ClientGetState state,
ObjectContainer container, ClientContext context) {
if(wasFetchingFinalData) {
- rcb.onBlockSetFinished(SingleFileFetcher.this,
container);
+ rcb.onBlockSetFinished(SingleFileFetcher.this,
container, context);
}
}
@@ -684,7 +684,7 @@
SingleFileFetcher.this.onFailure(e, true, sched,
container, context);
}
- public void onBlockSetFinished(ClientGetState state,
ObjectContainer container) {
+ public void onBlockSetFinished(ClientGetState state,
ObjectContainer container, ClientContext context) {
// Ignore as we are fetching metadata here
}
@@ -721,9 +721,9 @@
if((clientMetadata == null || clientMetadata.isTrivial()) &&
(!uri.hasMetaStrings()) &&
ctx.allowSplitfiles == false &&
ctx.followRedirects == false &&
returnBucket == null && key instanceof
ClientKey)
- return new SimpleSingleFileFetcher((ClientKey)key,
maxRetries, ctx, requester, cb, isEssential, false, l);
+ return new SimpleSingleFileFetcher((ClientKey)key,
maxRetries, ctx, requester, cb, isEssential, false, l, container, context);
if(key instanceof ClientKey)
- return new SingleFileFetcher(requester, cb,
clientMetadata, (ClientKey)key, uri.listMetaStrings(), uri, 0, ctx, actx, null,
null, maxRetries, recursionLevel, dontTellClientGet, l, isEssential,
returnBucket, isFinal);
+ return new SingleFileFetcher(requester, cb,
clientMetadata, (ClientKey)key, uri.listMetaStrings(), uri, 0, ctx, actx, null,
null, maxRetries, recursionLevel, dontTellClientGet, l, isEssential,
returnBucket, isFinal, container, context);
else {
return uskCreate(requester, cb, clientMetadata,
(USK)key, uri.listMetaStrings(), ctx, actx, maxRetries, recursionLevel,
dontTellClientGet, l, isEssential, returnBucket, isFinal, container, context);
}
@@ -749,7 +749,7 @@
SingleFileFetcher sf =
new
SingleFileFetcher(requester, myCB, clientMetadata, usk.getSSK(), metaStrings,
usk.getURI().addMetaStrings(metaStrings), 0, ctx, actx, null, null, maxRetries,
recursionLevel,
-
dontTellClientGet, l, isEssential, returnBucket, isFinal);
+
dontTellClientGet, l, isEssential, returnBucket, isFinal, container, context);
return sf;
}
} else {
@@ -802,7 +802,7 @@
try {
if(l == usk.suggestedEdition) {
SingleFileFetcher sf = new
SingleFileFetcher(parent, cb, clientMetadata, key, metaStrings,
key.getURI().addMetaStrings(metaStrings),
- 0, ctx, actx, null,
null, maxRetries, recursionLevel+1, dontTellClientGet, token, false,
returnBucket, true);
+ 0, ctx, actx, null,
null, maxRetries, recursionLevel+1, dontTellClientGet, token, false,
returnBucket, true, container, context);
sf.schedule(container, context);
} else {
cb.onFailure(new
FetchException(FetchException.PERMANENT_REDIRECT,
newUSK.getURI().addMetaStrings(metaStrings)), null, container, context);
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -168,7 +168,7 @@
// Compressed data
if(parent == cb) {
- ctx.eventProducer.produceEvent(new
FinishedCompressionEvent(bestCodec == null ? -1 :
bestCodec.codecNumberForMetadata(), origSize, data.size()));
+ ctx.eventProducer.produceEvent(new
FinishedCompressionEvent(bestCodec == null ? -1 :
bestCodec.codecNumberForMetadata(), origSize, data.size()), container, context);
if(logMINOR) Logger.minor(this, "Compressed
"+origSize+" to "+data.size()+" on "+this);
}
@@ -189,23 +189,23 @@
createInserter(parent, data,
codecNumber, block.desiredURI, ctx, cb, metadata, (int)block.getData().size(),
-1, getCHKOnly, true, true, container, context);
cb.onTransition(this, bi, container);
bi.schedule(container, context);
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
return;
}
}
if (fitsInOneCHK) {
// Insert single block, then insert pointer to it
if(reportMetadataOnly) {
- SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
cb, metadata, (int)origSize, -1, getCHKOnly, true, true, token);
+ SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
cb, metadata, (int)origSize, -1, getCHKOnly, true, true, token, container,
context);
Metadata meta =
makeMetadata(dataPutter.getURI(container, context));
cb.onMetadata(meta, this, container, context);
cb.onTransition(this, dataPutter, container);
dataPutter.schedule(container, context);
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
} else {
MultiPutCompletionCallback mcb =
new MultiPutCompletionCallback(cb,
parent, token);
- SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
mcb, metadata, (int)origSize, -1, getCHKOnly, true, false, token);
+ SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
mcb, metadata, (int)origSize, -1, getCHKOnly, true, false, token, container,
context);
Metadata meta =
makeMetadata(dataPutter.getURI(container, context));
Bucket metadataBucket;
try {
@@ -228,7 +228,7 @@
if(metaPutter instanceof SingleBlockInserter)
((SingleBlockInserter)metaPutter).encode(container, context);
metaPutter.schedule(container, context);
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
}
return;
}
@@ -238,13 +238,13 @@
// insert it. Then when the splitinserter has finished, and the
// metadata insert has finished too, tell the master callback.
if(reportMetadataOnly) {
- SplitFileInserter sfi = new SplitFileInserter(parent,
cb, data, bestCodec, origSize, block.clientMetadata, ctx, getCHKOnly, metadata,
token, insertAsArchiveManifest, freeData, context);
+ SplitFileInserter sfi = new SplitFileInserter(parent,
cb, data, bestCodec, origSize, block.clientMetadata, ctx, getCHKOnly, metadata,
token, insertAsArchiveManifest, freeData, container, context);
cb.onTransition(this, sfi, container);
sfi.start(container, context);
if(earlyEncode) sfi.forceEncode(container, context);
} else {
SplitHandler sh = new SplitHandler();
- SplitFileInserter sfi = new SplitFileInserter(parent,
sh, data, bestCodec, origSize, block.clientMetadata, ctx, getCHKOnly, metadata,
token, insertAsArchiveManifest, freeData, context);
+ SplitFileInserter sfi = new SplitFileInserter(parent,
sh, data, bestCodec, origSize, block.clientMetadata, ctx, getCHKOnly, metadata,
token, insertAsArchiveManifest, freeData, container, context);
sh.sfi = sfi;
cb.onTransition(this, sh, container);
sfi.start(container, context);
@@ -300,14 +300,14 @@
if(uri.getKeyType().equals("USK")) {
try {
return new USKInserter(parent, data,
compressionCodec, uri, ctx, cb, isMetadata, sourceLength, token,
- getCHKOnly, addToParent, this.token);
+ getCHKOnly, addToParent, this.token,
container, context);
} catch (MalformedURLException e) {
throw new
InsertException(InsertException.INVALID_URI, e, null);
}
} else {
SingleBlockInserter sbi =
new SingleBlockInserter(parent, data,
compressionCodec, uri, ctx, cb, isMetadata, sourceLength, token,
- getCHKOnly, addToParent, false,
this.token);
+ getCHKOnly, addToParent, false,
this.token, container, context);
if(encodeCHK)
cb.onEncode(sbi.getBlock(container,
context).getClientKey(), this, container, context);
return sbi;
@@ -567,7 +567,7 @@
block.free();
}
- public void onBlockSetFinished(ClientPutState state,
ObjectContainer container) {
+ public void onBlockSetFinished(ClientPutState state,
ObjectContainer container, ClientContext context) {
synchronized(this) {
if(state == sfi)
splitInsertSetBlocks = true;
@@ -576,7 +576,7 @@
if(!(splitInsertSetBlocks &&
metaInsertSetBlocks))
return;
}
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
}
public void schedule(ObjectContainer container, ClientContext
context) throws InsertException {
@@ -686,8 +686,8 @@
return null;
}
- public void onStartCompression(int i) {
+ public void onStartCompression(int i, ObjectContainer container,
ClientContext context) {
if(parent == cb)
- ctx.eventProducer.produceEvent(new
StartedCompressionEvent(i));
+ ctx.eventProducer.produceEvent(new
StartedCompressionEvent(i), container, context);
}
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -197,7 +197,7 @@
}
dontNotify = !scheduled;
}
- parentFetcher.parent.completedBlock(dontNotify);
+ parentFetcher.parent.completedBlock(dontNotify, container,
sched.getContext());
seg.possiblyRemoveFromParent();
if(decodeNow) {
removeSubSegments();
@@ -371,10 +371,10 @@
// :(
if(e.isFatal()) {
fatallyFailedBlocks++;
- parentFetcher.parent.fatallyFailedBlock();
+
parentFetcher.parent.fatallyFailedBlock(container, context);
} else {
failedBlocks++;
- parentFetcher.parent.failedBlock();
+ parentFetcher.parent.failedBlock(container,
context);
}
// Once it is no longer possible to have a successful
fetch, fail...
allFailed = failedBlocks + fatallyFailedBlocks >
(dataKeys.length + checkKeys.length - minFetched);
@@ -503,7 +503,7 @@
synchronized(this) {
scheduled = true;
}
- parentFetcher.parent.notifyClients();
+ parentFetcher.parent.notifyClients(container, context);
if(logMINOR)
Logger.minor(this, "scheduling "+seg+" :
"+seg.blockNums);
} catch (Throwable t) {
Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -69,7 +69,7 @@
return fs;
}
- public SplitFileInserter(BaseClientPutter put, PutCompletionCallback
cb, Bucket data, Compressor bestCodec, long decompressedLength, ClientMetadata
clientMetadata, InsertContext ctx, boolean getCHKOnly, boolean isMetadata,
Object token, boolean insertAsArchiveManifest, boolean freeData, ClientContext
context) throws InsertException {
+ public SplitFileInserter(BaseClientPutter put, PutCompletionCallback
cb, Bucket data, Compressor bestCodec, long decompressedLength, ClientMetadata
clientMetadata, InsertContext ctx, boolean getCHKOnly, boolean isMetadata,
Object token, boolean insertAsArchiveManifest, boolean freeData,
ObjectContainer container, ClientContext context) throws InsertException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.parent = put;
this.insertAsArchiveManifest = insertAsArchiveManifest;
@@ -100,7 +100,7 @@
checkSegmentSize = splitfileAlgorithm ==
Metadata.SPLITFILE_NONREDUNDANT ? 0 : ctx.splitfileSegmentCheckBlocks;
// Create segments
- segments = splitIntoSegments(segmentSize, dataBuckets,
context.mainExecutor);
+ segments = splitIntoSegments(segmentSize, dataBuckets,
context.mainExecutor, container, context);
int count = 0;
for(int i=0;i<segments.length;i++)
count += segments[i].countCheckBlocks();
@@ -198,7 +198,7 @@
/**
* Group the blocks into segments.
*/
- private SplitFileInserterSegment[] splitIntoSegments(int segmentSize,
Bucket[] origDataBlocks, Executor executor) {
+ private SplitFileInserterSegment[] splitIntoSegments(int segmentSize,
Bucket[] origDataBlocks, Executor executor, ObjectContainer container,
ClientContext context) {
int dataBlocks = origDataBlocks.length;
Vector segs = new Vector();
@@ -227,7 +227,7 @@
segNo++;
}
}
- parent.notifyClients();
+ parent.notifyClients(container, context);
return (SplitFileInserterSegment[]) segs.toArray(new
SplitFileInserterSegment[segs.size()]);
}
@@ -237,7 +237,7 @@
if(countDataBlocks > 32)
parent.onMajorProgress();
- parent.notifyClients();
+ parent.notifyClients(container, context);
}
@@ -256,7 +256,7 @@
}
if(encode) segment.forceEncode(container, context);
if(ret) return;
- cb.onBlockSetFinished(this, container);
+ cb.onBlockSetFinished(this, container, context);
if(countDataBlocks > 32)
parent.onMajorProgress();
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-06-19 19:36:33 UTC (rev 20501)
+++
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -408,11 +408,11 @@
dataBlockInserters[i] = new
SingleBlockInserter(parent.parent,
dataBlocks[i], (short) -1,
FreenetURI.EMPTY_CHK_URI,
blockInsertContext, this,
false, CHKBlock.DATA_LENGTH,
- i, getCHKOnly, false, false,
parent.token);
+ i, getCHKOnly, false, false,
parent.token, container, context);
dataBlockInserters[i].schedule(container,
context);
fin = false;
} else {
- parent.parent.completedBlock(true);
+ parent.parent.completedBlock(true, container,
context);
}
}
// parent.parent.notifyClients();
@@ -440,11 +440,11 @@
parent.parent,
checkBlocks[i], (short) -1,
FreenetURI.EMPTY_CHK_URI, blockInsertContext, this,
false,
CHKBlock.DATA_LENGTH, i + dataBlocks.length,
- getCHKOnly, false,
false, parent.token);
+ getCHKOnly, false,
false, parent.token, container, context);
checkBlockInserters[i].schedule(container, context);
fin = false;
} else
- parent.parent.completedBlock(true);
+ parent.parent.completedBlock(true,
container, context);
}
onEncodedSegment(container, context);
}
@@ -476,7 +476,7 @@
checkBlocks[i], (short) -1,
FreenetURI.EMPTY_CHK_URI,
blockInsertContext, this,
false, CHKBlock.DATA_LENGTH,
i + dataBlocks.length,
getCHKOnly, false, false,
- parent.token);
+ parent.token, container,
context);
checkBlockInserters[i].schedule(container,
context);
}
} catch (Throwable t) {
@@ -715,7 +715,7 @@
Logger.error(this, "Got onMetadata from " + state);
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
// Ignore
Logger.error(this, "Should not happen: onBlockSetFinished(" +
state
+ ") on " + this);
Modified: branches/db4o/freenet/src/freenet/client/async/USKFetcherWrapper.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/USKFetcherWrapper.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/USKFetcherWrapper.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -31,7 +31,7 @@
return false;
}
- public void notifyClients() {
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
// Do nothing
}
@@ -43,7 +43,7 @@
// Ignore
}
- public void onBlockSetFinished(ClientGetState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientGetState state, ObjectContainer
container, ClientContext context) {
// Ignore
}
Modified: branches/db4o/freenet/src/freenet/client/async/USKInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/USKInserter.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/USKInserter.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -110,7 +110,7 @@
// Success!
cb.onEncode(pubUSK.copy(edition), this, container,
context);
parent.addMustSucceedBlocks(1);
- parent.completedBlock(true);
+ parent.completedBlock(true, container, context);
cb.onSuccess(this, container, context);
} else {
scheduleInsert(container, context);
@@ -125,7 +125,7 @@
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "scheduling insert for
"+pubUSK.getURI()+ ' ' +edition);
sbi = new SingleBlockInserter(parent, data,
compressionCodec, privUSK.getInsertableSSK(edition).getInsertURI(),
- ctx, this, isMetadata, sourceLength,
token, getCHKOnly, false, true /* we don't use it */, tokenObject);
+ ctx, this, isMetadata, sourceLength,
token, getCHKOnly, false, true /* we don't use it */, tokenObject, container,
context);
}
try {
sbi.schedule(container, context);
@@ -167,7 +167,7 @@
public USKInserter(BaseClientPutter parent, Bucket data, short
compressionCodec, FreenetURI uri,
InsertContext ctx, PutCompletionCallback cb, boolean
isMetadata, int sourceLength, int token,
- boolean getCHKOnly, boolean addToParent, Object
tokenObject) throws MalformedURLException {
+ boolean getCHKOnly, boolean addToParent, Object
tokenObject, ObjectContainer container, ClientContext context) throws
MalformedURLException {
this.tokenObject = tokenObject;
this.parent = parent;
this.data = data;
@@ -181,7 +181,7 @@
if(addToParent) {
parent.addBlock();
parent.addMustSucceedBlocks(1);
- parent.notifyClients();
+ parent.notifyClients(container, context);
}
privUSK = InsertableUSK.createInsertable(uri);
pubUSK = privUSK.getUSK();
@@ -234,7 +234,7 @@
Logger.error(this, "Got onMetadata("+m+ ',' +state+ ')');
}
- public void onBlockSetFinished(ClientPutState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientPutState state, ObjectContainer
container, ClientContext context) {
// Ignore
}
Modified:
branches/db4o/freenet/src/freenet/client/async/USKProxyCompletionCallback.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/USKProxyCompletionCallback.java
2008-06-19 19:36:33 UTC (rev 20501)
+++
branches/db4o/freenet/src/freenet/client/async/USKProxyCompletionCallback.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -34,8 +34,8 @@
cb.onFailure(e, state, container, context);
}
- public void onBlockSetFinished(ClientGetState state, ObjectContainer
container) {
- cb.onBlockSetFinished(state, container);
+ public void onBlockSetFinished(ClientGetState state, ObjectContainer
container, ClientContext context) {
+ cb.onBlockSetFinished(state, container, context);
}
public void onTransition(ClientGetState oldState, ClientGetState
newState, ObjectContainer container) {
Modified: branches/db4o/freenet/src/freenet/client/async/USKRetriever.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/USKRetriever.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/async/USKRetriever.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -66,7 +66,7 @@
Logger.error(this, "Found edition "+state.getToken()+" but
failed to fetch edition: "+e, e);
}
- public void onBlockSetFinished(ClientGetState state, ObjectContainer
container) {
+ public void onBlockSetFinished(ClientGetState state, ObjectContainer
container, ClientContext context) {
// Ignore
}
@@ -78,7 +78,7 @@
return false;
}
- public void notifyClients() {
+ public void notifyClients(ObjectContainer container, ClientContext
context) {
// Ignore for now
}
Modified:
branches/db4o/freenet/src/freenet/client/events/ClientEventListener.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/events/ClientEventListener.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/events/ClientEventListener.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -3,7 +3,11 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.client.events;
+import com.db4o.ObjectContainer;
+import freenet.client.async.ClientContext;
+
+
/**
* Event handling for clients.
*
@@ -15,7 +19,10 @@
/**
* Hears an event.
+ * @param container The database context the event was generated in.
+ * NOTE THAT IT MAY NOT HAVE BEEN GENERATED IN A DATABASE CONTEXT AT ALL:
+ * In this case, container will be null, and you should use context to
schedule a DBJob.
**/
- public void receive(ClientEvent ce);
+ public void receive(ClientEvent ce, ObjectContainer maybeContainer,
ClientContext context);
}
Modified:
branches/db4o/freenet/src/freenet/client/events/ClientEventProducer.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/events/ClientEventProducer.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/events/ClientEventProducer.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -3,7 +3,11 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.client.events;
+import com.db4o.ObjectContainer;
+import freenet.client.async.ClientContext;
+
+
/**
* Event handling for clients.
*
@@ -15,7 +19,7 @@
* Sends the event to all registered EventListeners.
* @param ce the ClientEvent to raise
*/
- void produceEvent(ClientEvent ce);
+ void produceEvent(ClientEvent ce, ObjectContainer maybeContainer,
ClientContext context);
/**
* Adds an EventListener that will receive all events produced
Modified: branches/db4o/freenet/src/freenet/client/events/EventDumper.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/events/EventDumper.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/events/EventDumper.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -5,6 +5,10 @@
import java.io.PrintWriter;
+import com.db4o.ObjectContainer;
+
+import freenet.client.async.ClientContext;
+
public class EventDumper implements ClientEventListener {
final PrintWriter pw;
@@ -13,7 +17,7 @@
this.pw = writer;
}
- public void receive(ClientEvent ce) {
+ public void receive(ClientEvent ce, ObjectContainer container,
ClientContext context) {
pw.println(ce.getDescription());
}
Modified: branches/db4o/freenet/src/freenet/client/events/EventLogger.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/events/EventLogger.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/events/EventLogger.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -3,6 +3,9 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.client.events;
+import com.db4o.ObjectContainer;
+
+import freenet.client.async.ClientContext;
import freenet.support.Logger;
/**
@@ -24,7 +27,7 @@
* @param ce
* The event that occured
*/
- public void receive(ClientEvent ce) {
+ public void receive(ClientEvent ce, ObjectContainer container,
ClientContext context) {
Logger.logStatic(ce, ce.getDescription(), logPrio);
}
}
Modified:
branches/db4o/freenet/src/freenet/client/events/SimpleEventProducer.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/events/SimpleEventProducer.java
2008-06-19 19:36:33 UTC (rev 20501)
+++ branches/db4o/freenet/src/freenet/client/events/SimpleEventProducer.java
2008-06-19 20:57:54 UTC (rev 20502)
@@ -6,6 +6,9 @@
import java.util.NoSuchElementException;
import java.util.Vector;
+import com.db4o.ObjectContainer;
+
+import freenet.client.async.ClientContext;
import freenet.support.Logger;
/**
@@ -49,11 +52,11 @@
/**
* Sends the ClientEvent to all registered listeners of this object.
**/
- public void produceEvent(ClientEvent ce) {
+ public void produceEvent(ClientEvent ce, ObjectContainer container,
ClientContext context) {
for (Enumeration e = listeners.elements() ;
e.hasMoreElements();) {
try {
- ((ClientEventListener) e.nextElement()).receive(ce);
+ ((ClientEventListener) e.nextElement()).receive(ce, container,
context);
} catch (NoSuchElementException ne) {
Logger.normal(this, "Concurrent modification in "+
"produceEvent!: "+this);