Author: toad
Date: 2008-06-06 21:27:12 +0000 (Fri, 06 Jun 2008)
New Revision: 20247

Modified:
   branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
   branches/db4o/freenet/src/freenet/client/InsertContext.java
   branches/db4o/freenet/src/freenet/client/async/ClientContext.java
   branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
   branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
   branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
Log:
Move BackgroundBlockEncoder from InsertContext into ClientContext, since it is 
transient.

Modified: 
branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java     
2008-06-06 19:27:36 UTC (rev 20246)
+++ branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java     
2008-06-06 21:27:12 UTC (rev 20247)
@@ -42,7 +42,6 @@
        private final BucketFactory persistentBucketFactory;
        private final PersistentFileTracker persistentFileTracker;
        private final NodeClientCore core;
-       private final BackgroundBlockEncoder blockEncoder;
        /** One CEP for all requests and inserts */
        private final ClientEventProducer globalEventProducer;
        private long curMaxLength;

Modified: branches/db4o/freenet/src/freenet/client/InsertContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/InsertContext.java 2008-06-06 
19:27:36 UTC (rev 20246)
+++ branches/db4o/freenet/src/freenet/client/InsertContext.java 2008-06-06 
21:27:12 UTC (rev 20247)
@@ -32,12 +32,11 @@
        /** Interesting tradeoff, see comments at top of Node.java. */
        public final boolean cacheLocalRequests;
        public final USKManager uskManager;
-       public final BackgroundBlockEncoder backgroundBlockEncoder;
        public final Executor executor;

        public InsertContext(BucketFactory bf, BucketFactory persistentBF, 
PersistentFileTracker tracker, RandomSource random,
                        int maxRetries, int rnfsToSuccess, int maxThreads, int 
splitfileSegmentDataBlocks, int splitfileSegmentCheckBlocks,
-                       ClientEventProducer eventProducer, boolean 
cacheLocalRequests, USKManager uskManager, BackgroundBlockEncoder blockEncoder, 
Executor executor) {
+                       ClientEventProducer eventProducer, boolean 
cacheLocalRequests, USKManager uskManager, Executor executor) {
                this.bf = bf;
                this.persistentFileTracker = tracker;
                this.persistentBucketFactory = persistentBF;
@@ -52,7 +51,6 @@
                this.splitfileSegmentDataBlocks = splitfileSegmentDataBlocks;
                this.splitfileSegmentCheckBlocks = splitfileSegmentCheckBlocks;
                this.cacheLocalRequests = cacheLocalRequests;
-               this.backgroundBlockEncoder = blockEncoder;
                this.executor = executor;
        }

@@ -71,7 +69,6 @@
                this.splitfileSegmentDataBlocks = 
ctx.splitfileSegmentDataBlocks;
                this.splitfileSegmentCheckBlocks = 
ctx.splitfileSegmentCheckBlocks;
                this.cacheLocalRequests = ctx.cacheLocalRequests;
-               this.backgroundBlockEncoder = ctx.backgroundBlockEncoder;
                this.executor = ctx.executor;
        }

@@ -90,7 +87,6 @@
                this.splitfileSegmentDataBlocks = 
ctx.splitfileSegmentDataBlocks;
                this.splitfileSegmentCheckBlocks = 
ctx.splitfileSegmentCheckBlocks;
                this.cacheLocalRequests = ctx.cacheLocalRequests;
-               this.backgroundBlockEncoder = ctx.backgroundBlockEncoder;
                this.executor = ctx.executor;
        }


Modified: branches/db4o/freenet/src/freenet/client/async/ClientContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientContext.java   
2008-06-06 19:27:36 UTC (rev 20246)
+++ branches/db4o/freenet/src/freenet/client/async/ClientContext.java   
2008-06-06 21:27:12 UTC (rev 20247)
@@ -22,6 +22,7 @@
        public final DBJobRunner jobRunner;
        public final Executor mainExecutor;
        public final long nodeDBHandle;
+       public final BackgroundBlockEncoder backgroundBlockEncoder;

        public ClientContext(NodeClientCore core) {
                this.fecQueue = core.fecQueue;
@@ -32,6 +33,7 @@
                jobRunner = core;
                this.mainExecutor = core.getExecutor();
                this.nodeDBHandle = core.node.nodeDBHandle;
+               this.backgroundBlockEncoder = core.backgroundBlockEncoder;
        }

 }

Modified: 
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-06-06 19:27:36 UTC (rev 20246)
+++ branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-06-06 21:27:12 UTC (rev 20247)
@@ -226,7 +226,7 @@
                        ClientKeyBlock block = encode(container);
                        cb.onEncode(block.getClientKey(), this, container);
                        parent.completedBlock(false);
-                       cb.onSuccess(this, container);
+                       cb.onSuccess(this, container, context);
                        finished = true;
                } else {
                        getScheduler(context).register(this);

Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java       
2008-06-06 19:27:36 UTC (rev 20246)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java       
2008-06-06 21:27:12 UTC (rev 20247)
@@ -240,7 +240,7 @@

        }

-       public void encodedSegment(SplitFileInserterSegment segment, 
ObjectContainer container) {
+       public void encodedSegment(SplitFileInserterSegment segment, 
ObjectContainer container, ClientContext context) {
                if(logMINOR) Logger.minor(this, "Encoded segment 
"+segment.segNo+" of "+this);
                boolean ret = false;
                boolean encode;
@@ -253,7 +253,7 @@
                                }
                        }
                }
-               if(encode) segment.forceEncode();
+               if(encode) segment.forceEncode(context);
                if(ret) return;
                cb.onBlockSetFinished(this, container);
                if(countDataBlocks > 32)
@@ -455,13 +455,13 @@
        }

        /** Force the remaining blocks which haven't been encoded so far to be 
encoded ASAP. */
-       public void forceEncode() {
+       public void forceEncode(ClientContext context) {
                Logger.minor(this, "Forcing encode on "+this);
                synchronized(this) {
                        forceEncode = true;
                }
                for(int i=0;i<segments.length;i++) {
-                       segments[i].forceEncode();
+                       segments[i].forceEncode(context);
                }
        }


Modified: 
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java    
    2008-06-06 19:27:36 UTC (rev 20246)
+++ 
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java    
    2008-06-06 21:27:12 UTC (rev 20247)
@@ -493,7 +493,7 @@

                // Tell parent only after have started the inserts.
                // Because of the counting.
-               parent.encodedSegment(this, container);
+               parent.encodedSegment(this, container, context);

                synchronized (this) {
                        for (int i = 0; i < dataBlockInserters.length; i++) {
@@ -733,8 +733,8 @@
         * Force the remaining blocks which haven't been encoded so far to be
         * encoded ASAP.
         */
-       public void forceEncode() {
-               
blockInsertContext.backgroundBlockEncoder.queue(dataBlockInserters);
-               
blockInsertContext.backgroundBlockEncoder.queue(checkBlockInserters);
+       public void forceEncode(ClientContext context) {
+               context.backgroundBlockEncoder.queue(dataBlockInserters);
+               context.backgroundBlockEncoder.queue(checkBlockInserters);
        }
 }


Reply via email to