Author: toad
Date: 2008-06-05 21:47:52 +0000 (Thu, 05 Jun 2008)
New Revision: 20230

Modified:
   branches/db4o/freenet/src/freenet/client/async/BaseClientGetter.java
   branches/db4o/freenet/src/freenet/client/async/BaseClientPutter.java
   branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
   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/ClientPutState.java
   branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
   branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
   branches/db4o/freenet/src/freenet/client/async/HealingQueue.java
   branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
Log:
More compile fixes/change of arguments.
Previous commit label inaccurate: most importantly, we got rid of the CRS 
references from ClientRequester, which cannot be serialised. We now feed in the 
ClientContext to provide them instead.

Modified: branches/db4o/freenet/src/freenet/client/async/BaseClientGetter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BaseClientGetter.java        
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/BaseClientGetter.java        
2008-06-05 21:47:52 UTC (rev 20230)
@@ -8,8 +8,8 @@
 public abstract class BaseClientGetter extends ClientRequester implements
                GetCompletionCallback {

-       protected BaseClientGetter(short priorityClass, ClientRequestScheduler 
chkScheduler, ClientRequestScheduler sskScheduler, RequestClient client) {
-               super(priorityClass, chkScheduler, sskScheduler, client);
+       protected BaseClientGetter(short priorityClass, RequestClient client) {
+               super(priorityClass, client);
        }

 }

Modified: branches/db4o/freenet/src/freenet/client/async/BaseClientPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BaseClientPutter.java        
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/BaseClientPutter.java        
2008-06-05 21:47:52 UTC (rev 20230)
@@ -7,8 +7,8 @@

 public abstract class BaseClientPutter extends ClientRequester {

-       protected BaseClientPutter(short priorityClass, ClientRequestScheduler 
chkScheduler, ClientRequestScheduler sskScheduler, RequestClient context) {
-               super(priorityClass, chkScheduler, sskScheduler, context);
+       protected BaseClientPutter(short priorityClass, RequestClient context) {
+               super(priorityClass, context);
        }

        public abstract void onMajorProgress();

Modified: 
branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-06-05 21:47:52 UTC (rev 20230)
@@ -69,7 +69,7 @@

        /** Try again - returns true if we can retry 
         * @param sched */
-       protected boolean retry(RequestScheduler sched, ObjectContainer 
container) {
+       protected boolean retry(RequestScheduler sched, ObjectContainer 
container, ClientContext context) {
                retryCount++;
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Attempting to retry... (max 
"+maxRetries+", current "+retryCount+ ')');
@@ -84,7 +84,7 @@
                                cooldownWakeupTime = sched.queueCooldown(key, 
this);
                                return true; // We will retry, just not yet. 
See requeueAfterCooldown(Key).
                        } else {
-                               schedule(container);
+                               schedule(container, context);
                        }
                        return true;
                }
@@ -164,7 +164,7 @@
                cooldownWakeupTime = -1;
        }

-       public void requeueAfterCooldown(Key key, long time, ObjectContainer 
container) {
+       public void requeueAfterCooldown(Key key, long time, ObjectContainer 
container, ClientContext context) {
                if(cooldownWakeupTime > time) {
                        if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "Not requeueing as deadline has not passed yet");
                        return;
@@ -175,7 +175,7 @@
                }
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Requeueing after cooldown "+key+" 
for "+this);
-               schedule(container);
+               schedule(container, context);
        }

 }

Modified: branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java      
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/BinaryBlobInserter.java      
2008-06-05 21:47:52 UTC (rev 20230)
@@ -5,6 +5,8 @@
 import java.util.Iterator;
 import java.util.Vector;

+import com.db4o.ObjectContainer;
+
 import freenet.client.FailureCodeTracker;
 import freenet.client.InsertContext;
 import freenet.client.InsertException;
@@ -33,7 +35,7 @@
        private boolean fatal;
        final InsertContext ctx;

-       BinaryBlobInserter(Bucket blob, ClientPutter parent, RequestClient 
clientContext, boolean tolerant, short prioClass, InsertContext ctx) 
+       BinaryBlobInserter(Bucket blob, ClientPutter parent, RequestClient 
clientContext, boolean tolerant, short prioClass, InsertContext ctx, 
ClientContext context) 
        throws IOException, BinaryBlobFormatException {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                this.ctx = ctx;
@@ -58,7 +60,7 @@
                        Key key = (Key) i.next();
                        KeyBlock block = blocks.get(key);
                        MySendableInsert inserter =
-                               new MySendableInsert(x++, block, prioClass, 
getScheduler(block), clientContext);
+                               new MySendableInsert(x++, block, prioClass, 
getScheduler(block, context), clientContext);
                        myInserters.add(inserter);
                }

@@ -67,20 +69,20 @@
                parent.notifyClients();
        }

-       private ClientRequestScheduler getScheduler(KeyBlock block) {
+       private ClientRequestScheduler getScheduler(KeyBlock block, 
ClientContext context) {
                if(block instanceof CHKBlock)
-                       return parent.chkScheduler;
+                       return context.chkFetchScheduler;
                else if(block instanceof SSKBlock)
-                       return parent.sskScheduler;
+                       return context.sskFetchScheduler;
                else throw new IllegalArgumentException("Unknown block type 
"+block.getClass()+" : "+block);
        }

-       public void cancel() {
+       public void cancel(ObjectContainer container) {
                for(int i=0;i<inserters.length;i++) {
                        if(inserters[i] != null)
                                inserters[i].cancel();
                }
-               parent.onFailure(new 
InsertException(InsertException.CANCELLED), this);
+               parent.onFailure(new 
InsertException(InsertException.CANCELLED), this, container);
        }

        public BaseClientPutter getParent() {
@@ -96,7 +98,7 @@
                return clientContext;
        }

-       public void schedule() throws InsertException {
+       public void schedule(ObjectContainer container, ClientContext context) 
throws InsertException {
                for(int i=0;i<inserters.length;i++) {
                        inserters[i].schedule();
                }
@@ -113,7 +115,7 @@
                        this.blockNum = i;
                }

-               public void onSuccess() {
+               public void onSuccess(ObjectContainer container) {
                        synchronized(this) {
                                if(inserters[blockNum] == null) return;
                                inserters[blockNum] = null;
@@ -121,23 +123,23 @@
                                succeededBlocks++;
                        }
                        parent.completedBlock(false);
-                       maybeFinish();
+                       maybeFinish(container);
                }

                // FIXME duplicated code from SingleBlockInserter
                // FIXME combine it somehow
-               public void onFailure(LowLevelPutException e) {
+               public void onFailure(LowLevelPutException e, Object keyNum, 
ObjectContainer container) {
                        synchronized(BinaryBlobInserter.this) {
                                if(inserters[blockNum] == null) return;
                        }
                        if(parent.isCancelled()) {
-                               fail(new 
InsertException(InsertException.CANCELLED), true);
+                               fail(new 
InsertException(InsertException.CANCELLED), true, container);
                                return;
                        }
                        logMINOR = Logger.shouldLog(Logger.MINOR, 
BinaryBlobInserter.this);
                        switch(e.code) {
                        case LowLevelPutException.COLLISION:
-                               fail(new 
InsertException(InsertException.COLLISION), false);
+                               fail(new 
InsertException(InsertException.COLLISION), false, container);
                                break;
                        case LowLevelPutException.INTERNAL_ERROR:
                                errors.inc(InsertException.INTERNAL_ERROR);
@@ -160,7 +162,7 @@
                                if(logMINOR) Logger.minor(this, "Consecutive 
RNFs: "+consecutiveRNFs+" / "+consecutiveRNFsCountAsSuccess);
                                if(consecutiveRNFs == 
consecutiveRNFsCountAsSuccess) {
                                        if(logMINOR) Logger.minor(this, 
"Consecutive RNFs: "+consecutiveRNFs+" - counting as success");
-                                       onSuccess();
+                                       onSuccess(container);
                                        return;
                                }
                        } else
@@ -168,14 +170,14 @@
                        if(logMINOR) Logger.minor(this, "Failed: "+e);
                        retries++;
                        if((retries > maxRetries) && (maxRetries != -1)) {
-                               fail(InsertException.construct(errors), false);
+                               fail(InsertException.construct(errors), false, 
container);
                                return;
                        }
                        // Retry *this block*
                        this.schedule();
                }

-               private void fail(InsertException e, boolean fatal) {
+               private void fail(InsertException e, boolean fatal, 
ObjectContainer container) {
                        synchronized(BinaryBlobInserter.this) {
                                if(inserters[blockNum] == null) return;
                                inserters[blockNum] = null;
@@ -186,7 +188,7 @@
                                parent.fatallyFailedBlock();
                        else
                                parent.failedBlock();
-                       maybeFinish();
+                       maybeFinish(container);
                }

                public boolean shouldCache() {
@@ -194,7 +196,7 @@
                }
        }

-       public void maybeFinish() {
+       public void maybeFinish(ObjectContainer container) {
                boolean success;
                boolean wasFatal;
                synchronized(this) {
@@ -204,11 +206,11 @@
                        wasFatal = fatal;
                }
                if(success) {
-                       parent.onSuccess(this);
+                       parent.onSuccess(this, container);
                } else if(wasFatal)
-                       parent.onFailure(new 
InsertException(InsertException.FATAL_ERRORS_IN_BLOCKS, errors, null), this);
+                       parent.onFailure(new 
InsertException(InsertException.FATAL_ERRORS_IN_BLOCKS, errors, null), this, 
container);
                else
-                       parent.onFailure(new 
InsertException(InsertException.TOO_MANY_RETRIES_IN_BLOCKS, errors, null), 
this);
+                       parent.onFailure(new 
InsertException(InsertException.TOO_MANY_RETRIES_IN_BLOCKS, errors, null), 
this, container);
        }

 }

Modified: branches/db4o/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientGetter.java    
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/ClientGetter.java    
2008-06-05 21:47:52 UTC (rev 20230)
@@ -9,6 +9,8 @@
 import java.net.MalformedURLException;
 import java.util.HashSet;

+import com.db4o.ObjectContainer;
+
 import freenet.client.ArchiveContext;
 import freenet.client.ClientMetadata;
 import freenet.client.FetchContext;
@@ -63,7 +65,7 @@
         */
        public ClientGetter(ClientCallback client, ClientRequestScheduler 
chkSched, ClientRequestScheduler sskSched,
                            FreenetURI uri, FetchContext ctx, short 
priorityClass, RequestClient clientContext, Bucket returnBucket, Bucket 
binaryBlobBucket) {
-               super(priorityClass, chkSched, sskSched, clientContext);
+               super(priorityClass, clientContext);
                this.clientCallback = client;
                this.returnBucket = returnBucket;
                this.uri = uri;
@@ -78,11 +80,11 @@
                archiveRestarts = 0;
        }

-       public void start() throws FetchException {
-               start(false, null);
+       public void start(ObjectContainer container, ClientContext context) 
throws FetchException {
+               start(false, null, container, context);
        }

-       public boolean start(boolean restart, FreenetURI overrideURI) throws 
FetchException {
+       public boolean start(boolean restart, FreenetURI overrideURI, 
ObjectContainer container, ClientContext context) throws FetchException {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Starting "+this);
                try {
@@ -99,7 +101,7 @@
                                }
                                currentState = SingleFileFetcher.create(this, 
this, new ClientMetadata(),
                                                uri, ctx, actx, 
ctx.maxNonSplitfileRetries, 0, false, -1, true,
-                                               returnBucket, true);
+                                               returnBucket, true, container, 
context);
                        }
                        if(cancelled) cancel();
                        if(currentState != null && !finished) {
@@ -108,11 +110,11 @@
                                                binaryBlobStream = new 
DataOutputStream(new BufferedOutputStream(binaryBlobBucket.getOutputStream()));
                                                
BinaryBlob.writeBinaryBlobHeader(binaryBlobStream);
                                        } catch (IOException e) {
-                                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to open binary blob 
bucket", e), null);
+                                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to open binary blob 
bucket", e), null, container, context);
                                                return false;
                                        }
                                }
-                               currentState.schedule();
+                               currentState.schedule(container, context);
                        }
                        if(cancelled) cancel();
                } catch (MalformedURLException e) {
@@ -121,10 +123,10 @@
                return true;
        }

-       public void onSuccess(FetchResult result, ClientGetState state) {
+       public void onSuccess(FetchResult result, ClientGetState state, 
ObjectContainer container, ClientContext context) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Succeeded from "+state);
-               if(!closeBinaryBlobStream()) return;
+               if(!closeBinaryBlobStream(container, context)) return;
                synchronized(this) {
                        finished = true;
                        currentState = null;
@@ -144,7 +146,7 @@
                                from.free();
                        } catch (IOException e) {
                                Logger.error(this, "Error copying from "+from+" 
to "+to+" : "+e.toString(), e);
-                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, e.toString()), state /* not 
strictly to blame, but we're not ako ClientGetState... */);
+                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, e.toString()), state /* not 
strictly to blame, but we're not ako ClientGetState... */, container, context);
                        }
                        result = new FetchResult(result, to);
                } else {
@@ -167,10 +169,10 @@

        }

-       public void onFailure(FetchException e, ClientGetState state) {
+       public void onFailure(FetchException e, ClientGetState state, 
ObjectContainer container, ClientContext context) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Failed from "+state+" : "+e, e);
-               closeBinaryBlobStream();
+               closeBinaryBlobStream(container, context);
                while(true) {
                        if(e.mode == FetchException.ARCHIVE_RESTART) {
                                int ar;
@@ -184,7 +186,7 @@
                                        e = new 
FetchException(FetchException.TOO_MANY_ARCHIVE_RESTARTS);
                                else {
                                        try {
-                                               start();
+                                               start(container, context);
                                        } catch (FetchException e1) {
                                                e = e1;
                                                continue;
@@ -218,7 +220,7 @@
                }
        }

-       public void cancel() {
+       public void cancel(ObjectContainer container) {
                boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR) Logger.minor(this, "Cancelling "+this);
                ClientGetState s;
@@ -228,7 +230,7 @@
                }
                if(s != null) {
                        if(logMINOR) Logger.minor(this, "Cancelling 
"+currentState);
-                       s.cancel();
+                       s.cancel(container);
                }
        }

@@ -244,13 +246,13 @@
                ctx.eventProducer.produceEvent(new 
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks, 
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks, 
this.blockSetFinalized));
        }

-       public void onBlockSetFinished(ClientGetState state) {
+       public void onBlockSetFinished(ClientGetState state, ObjectContainer 
container) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Set finished", new 
Exception("debug"));
                blockSetFinalized();
        }

-       public void onTransition(ClientGetState oldState, ClientGetState 
newState) {
+       public void onTransition(ClientGetState oldState, ClientGetState 
newState, ObjectContainer container) {
                synchronized(this) {
                        if(currentState == oldState) {
                                currentState = newState;
@@ -270,15 +272,15 @@
                return true;
        }

-       public boolean restart(FreenetURI redirect) throws FetchException {
-               return start(true, redirect);
+       public boolean restart(FreenetURI redirect, ObjectContainer container, 
ClientContext context) throws FetchException {
+               return start(true, redirect, container, context);
        }

        public String toString() {
                return super.toString()+ ':' +uri;
        }

-       void addKeyToBinaryBlob(ClientKeyBlock block) {
+       void addKeyToBinaryBlob(ClientKeyBlock block, ObjectContainer 
container, ClientContext context) {
                if(binaryBlobKeysAddedAlready == null) return;
                if(Logger.shouldLog(Logger.MINOR, this)) 
                        Logger.minor(this, "Adding key 
"+block.getClientKey().getURI()+" to "+this, new Exception("debug"));
@@ -291,7 +293,7 @@
                                BinaryBlob.writeKey(binaryBlobStream, block, 
key);
                        } catch (IOException e) {
                                Logger.error(this, "Failed to write key to 
binary blob stream: "+e, e);
-                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to write key to binary blob 
stream: "+e), null);
+                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to write key to binary blob 
stream: "+e), null, container, context);
                                binaryBlobStream = null;
                                binaryBlobKeysAddedAlready.clear();
                        }
@@ -303,7 +305,7 @@
         * @return True unless a failure occurred, in which case we will have 
already
         * called onFailure() with an appropriate error.
         */
-       private boolean closeBinaryBlobStream() {
+       private boolean closeBinaryBlobStream(ObjectContainer container, 
ClientContext context) {
                if(binaryBlobKeysAddedAlready == null) return true;
                synchronized(binaryBlobKeysAddedAlready) {
                        if(binaryBlobStream == null) return true;
@@ -316,7 +318,7 @@
                                return true;
                        } catch (IOException e) {
                                Logger.error(this, "Failed to close binary blob 
stream: "+e, e);
-                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to close binary blob 
stream: "+e), null);
+                               onFailure(new 
FetchException(FetchException.BUCKET_ERROR, "Failed to close binary blob 
stream: "+e), null, container, context);
                                if(!triedClose) {
                                        try {
                                                binaryBlobStream.close();
@@ -336,17 +338,17 @@
                return binaryBlobBucket != null;
        }

-       public void onExpectedMIME(String mime) {
+       public void onExpectedMIME(String mime, ObjectContainer container) {
                if(finalizedMetadata) return;
                expectedMIME = mime;
        }

-       public void onExpectedSize(long size) {
+       public void onExpectedSize(long size, ObjectContainer container) {
                if(finalizedMetadata) return;
                expectedSize = size;
        }

-       public void onFinalizedMetadata() {
+       public void onFinalizedMetadata(ObjectContainer container) {
                finalizedMetadata = true;
        }


Modified: branches/db4o/freenet/src/freenet/client/async/ClientPutState.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientPutState.java  
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/ClientPutState.java  
2008-06-05 21:47:52 UTC (rev 20230)
@@ -22,7 +22,7 @@
        public abstract void cancel(ObjectContainer container);

        /** Schedule the request. */
-       public abstract void schedule(ObjectContainer container) throws 
InsertException;
+       public abstract void schedule(ObjectContainer container, ClientContext 
context) throws InsertException;

        /**
         * Get the token, an object which is passed around with the insert and 
may be

Modified: branches/db4o/freenet/src/freenet/client/async/ClientPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientPutter.java    
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/ClientPutter.java    
2008-06-05 21:47:52 UTC (rev 20230)
@@ -5,6 +5,8 @@

 import java.io.IOException;

+import com.db4o.ObjectContainer;
+
 import freenet.client.ClientMetadata;
 import freenet.client.InsertBlock;
 import freenet.client.InsertContext;
@@ -55,7 +57,7 @@
        public ClientPutter(ClientCallback client, Bucket data, FreenetURI 
targetURI, ClientMetadata cm, InsertContext ctx,
                        ClientRequestScheduler chkScheduler, 
ClientRequestScheduler sskScheduler, short priorityClass, boolean getCHKOnly, 
                        boolean isMetadata, RequestClient clientContext, 
SimpleFieldSet stored, String targetFilename, boolean binaryBlob) {
-               super(priorityClass, chkScheduler, sskScheduler, clientContext);
+               super(priorityClass, clientContext);
                this.cm = cm;
                this.isMetadata = isMetadata;
                this.getCHKOnly = getCHKOnly;
@@ -70,11 +72,11 @@
                this.binaryBlob = binaryBlob;
        }

-       public void start(boolean earlyEncode) throws InsertException {
-               start(earlyEncode, false);
+       public void start(boolean earlyEncode, ObjectContainer container, 
ClientContext context) throws InsertException {
+               start(earlyEncode, false, container, context);
        }

-       public boolean start(boolean earlyEncode, boolean restart) throws 
InsertException {
+       public boolean start(boolean earlyEncode, boolean restart, 
ObjectContainer container, ClientContext context) throws InsertException {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Starting "+this);
                try {
@@ -100,11 +102,11 @@
                                                                        false, 
getCHKOnly, false, null, false, false, targetFilename, earlyEncode);
                                        else
                                                currentState =
-                                                       new 
BinaryBlobInserter(data, this, null, false, priorityClass, ctx);
+                                                       new 
BinaryBlobInserter(data, this, null, false, priorityClass, ctx, context);
                                }
                        }
                        if(cancel) {
-                               onFailure(new 
InsertException(InsertException.CANCELLED), null);
+                               onFailure(new 
InsertException(InsertException.CANCELLED), null, container);
                                oldProgress = null;
                                return false;
                        }
@@ -112,7 +114,7 @@
                                cancel = cancelled;
                        }
                        if(cancel) {
-                               onFailure(new 
InsertException(InsertException.CANCELLED), null);
+                               onFailure(new 
InsertException(InsertException.CANCELLED), null, container);
                                oldProgress = null;
                                return false;
                        }
@@ -121,13 +123,13 @@
                        if(currentState instanceof SingleFileInserter)
                                
((SingleFileInserter)currentState).start(oldProgress);
                        else
-                               currentState.schedule();
+                               currentState.schedule(container, context);
                        synchronized(this) {
                                oldProgress = null;
                                cancel = cancelled;
                        }
                        if(cancel) {
-                               onFailure(new 
InsertException(InsertException.CANCELLED), null);
+                               onFailure(new 
InsertException(InsertException.CANCELLED), null, container);
                                return false;
                        }
                } catch (InsertException e) {
@@ -169,7 +171,7 @@
                return true;
        }

-       public void onSuccess(ClientPutState state) {
+       public void onSuccess(ClientPutState state, ObjectContainer container) {
                synchronized(this) {
                        finished = true;
                        currentState = null;
@@ -183,7 +185,7 @@
                client.onSuccess(this);
        }

-       public void onFailure(InsertException e, ClientPutState state) {
+       public void onFailure(InsertException e, ClientPutState state, 
ObjectContainer container) {
                synchronized(this) {
                        finished = true;
                        currentState = null;
@@ -196,7 +198,7 @@
                client.onMajorProgress();
        }

-       public void onEncode(BaseClientKey key, ClientPutState state) {
+       public void onEncode(BaseClientKey key, ClientPutState state, 
ObjectContainer container) {
                synchronized(this) {
                        this.uri = key.getURI();
                        if(targetFilename != null)
@@ -205,7 +207,7 @@
                client.onGeneratedURI(uri, this);
        }

-       public void cancel() {
+       public void cancel(ObjectContainer container, ClientContext context) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Cancelling "+this, new 
Exception("debug"));
                ClientPutState oldState = null;
@@ -216,8 +218,8 @@
                        if(startedStarting) return;
                        startedStarting = true;
                }
-               if(oldState != null) oldState.cancel();
-               onFailure(new InsertException(InsertException.CANCELLED), null);
+               if(oldState != null) oldState.cancel(container);
+               onFailure(new InsertException(InsertException.CANCELLED), null, 
container);
        }

        public synchronized boolean isFinished() {
@@ -228,7 +230,7 @@
                return uri;
        }

-       public synchronized void onTransition(ClientPutState oldState, 
ClientPutState newState) {
+       public synchronized void onTransition(ClientPutState oldState, 
ClientPutState newState, ObjectContainer container) {
                if(newState == null) throw new NullPointerException();
                if(currentState == oldState)
                        currentState = newState;
@@ -236,7 +238,7 @@
                        Logger.error(this, "onTransition: cur="+currentState+", 
old="+oldState+", new="+newState);
        }

-       public void onMetadata(Metadata m, ClientPutState state) {
+       public void onMetadata(Metadata m, ClientPutState state, 
ObjectContainer container) {
                Logger.error(this, "Got metadata on "+this+" from "+state+" 
(this means the metadata won't be inserted)");
        }

@@ -244,7 +246,7 @@
                ctx.eventProducer.produceEvent(new 
SplitfileProgressEvent(this.totalBlocks, this.successfulBlocks, 
this.failedBlocks, this.fatallyFailedBlocks, this.minSuccessBlocks, 
this.blockSetFinalized));
        }

-       public void onBlockSetFinished(ClientPutState state) {
+       public void onBlockSetFinished(ClientPutState state, ObjectContainer 
container) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Set finished", new 
Exception("debug"));
                blockSetFinalized();
@@ -255,7 +257,7 @@
                return currentState.getProgressFieldset();
        }

-       public void onFetchable(ClientPutState state) {
+       public void onFetchable(ClientPutState state, ObjectContainer 
container) {
                client.onFetchable(this);
        }

@@ -268,11 +270,11 @@
                return true;
        }

-       public boolean restart(boolean earlyEncode) throws InsertException {
-               return start(earlyEncode, true);
+       public boolean restart(boolean earlyEncode, ObjectContainer container, 
ClientContext context) throws InsertException {
+               return start(earlyEncode, true, container, context);
        }

-       public void onTransition(ClientGetState oldState, ClientGetState 
newState) {
+       public void onTransition(ClientGetState oldState, ClientGetState 
newState, ObjectContainer container) {
                // Ignore, at the moment
        }


Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-06-05 21:47:52 UTC (rev 20230)
@@ -636,10 +636,10 @@
                        } else {
                                if(gets != null)
                                for(int i=0;i<gets.length;i++)
-                                       gets[i].requeueAfterCooldown(key, now, 
container);
+                                       gets[i].requeueAfterCooldown(key, now, 
container, clientContext);
                                if(transientGets != null)
                                for(int i=0;i<transientGets.length;i++)
-                                       
transientGets[i].requeueAfterCooldown(key, now, container);
+                                       
transientGets[i].requeueAfterCooldown(key, now, container, clientContext);
                        }
                }
                if(keys.length < MAX_KEYS) return found;
@@ -694,4 +694,8 @@
                return clientContext.fecQueue;
        }

+       public ClientContext getContext() {
+               return clientContext;
+       }
+
 }

Modified: branches/db4o/freenet/src/freenet/client/async/HealingQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/HealingQueue.java    
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/HealingQueue.java    
2008-06-05 21:47:52 UTC (rev 20230)
@@ -8,6 +8,6 @@
 public interface HealingQueue {

        /** Queue a Bucket of data to insert as a CHK. */
-       void queue(Bucket data);
+       void queue(Bucket data, ClientContext context);

 }

Modified: branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java      
2008-06-05 21:23:01 UTC (rev 20229)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleHealingQueue.java      
2008-06-05 21:47:52 UTC (rev 20230)
@@ -25,7 +25,7 @@
        final HashMap runningInserters;

        public SimpleHealingQueue(ClientRequestScheduler scheduler, 
InsertContext context, short prio, int maxRunning) {
-               super(prio, scheduler, null, new RequestClient() {
+               super(prio, new RequestClient() {
                        public boolean persistent() {
                                return false;
                        } });
@@ -34,7 +34,7 @@
                this.maxRunning = maxRunning;
        }

-       public boolean innerQueue(Bucket data) {
+       public boolean innerQueue(Bucket data, ClientContext context) {
                SingleBlockInserter sbi;
                int ctr;
                synchronized(this) {
@@ -51,7 +51,7 @@
                        runningInserters.put(data, sbi);
                }
                try {
-                       sbi.schedule(null);
+                       sbi.schedule(null, context);
                        if(Logger.shouldLog(Logger.MINOR, this))
                                Logger.minor(this, "Started healing insert 
"+ctr+" for "+data);
                        return true;
@@ -61,8 +61,8 @@
                }
        }

-       public void queue(Bucket data) {
-               if(!innerQueue(data))
+       public void queue(Bucket data, ClientContext context) {
+               if(!innerQueue(data, context))
                        data.free();
        }



Reply via email to