Author: nextgens
Date: 2007-03-24 14:35:01 +0000 (Sat, 24 Mar 2007)
New Revision: 12307
Modified:
trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
Log:
Simplify the API
Modified: trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
===================================================================
--- trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2007-03-24
14:27:15 UTC (rev 12306)
+++ trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2007-03-24
14:35:01 UTC (rev 12307)
@@ -439,7 +439,7 @@
// ###############################
- public void addToQueue(Bucket[] dataBlocks, Bucket[] checkBlocks, int
blockLength, BucketFactory bucketFactory, StandardOnionFECCodecEncoderCallback
callback, boolean isADecodingJob){
+ public void addToQueue(FECJob job){
synchronized (_awaitingJobs) {
if((fecRunnerThread == null) ||
!fecRunnerThread.isAlive()){
if(fecRunnerThread != null) Logger.error(this,
"The callback died!! restarting a new one, please report that error.");
@@ -450,7 +450,7 @@
fecRunnerThread.start();
}
- _awaitingJobs.addFirst(new FECJob(dataBlocks,
checkBlocks, blockLength, bucketFactory, callback, isADecodingJob));
+ _awaitingJobs.addFirst(job);
}
if(logMINOR) Logger.minor(this, "Adding a new job to the queue
(" +_awaitingJobs.size() + ").");
synchronized (fecRunner){
@@ -458,22 +458,6 @@
}
}
- public void addToQueue(SplitfileBlock[] dataBlockStatus,
SplitfileBlock[] checkBlockStatus, int blockLength, BucketFactory
bucketFactory, StandardOnionFECCodecEncoderCallback callback, boolean
isADecodingJob){
- addToQueue(dataBlockStatus, checkBlockStatus, blockLength,
bucketFactory, callback, isADecodingJob);
- if(logMINOR) {
- if(isADecodingJob)
- Logger.minor(this, "Queueing decode: " +
dataBlockStatus.length
- + " data blocks, " +
checkBlockStatus.length
- + " check blocks, block length " +
blockLength + " with "
- + this, new Exception("debug"));
- else
- Logger.minor(this, "Queueing encode: " +
dataBlockStatus.length
- + " data blocks, " +
checkBlockStatus.length
- + " check blocks, block length " +
blockLength + " with "
- + this, new Exception("debug"));
- }
- }
-
private final LinkedList _awaitingJobs = new LinkedList();
private final FECRunner fecRunner = new FECRunner();
private Thread fecRunnerThread;
@@ -483,7 +467,7 @@
public void onDecodedSegment();
}
- private class FECJob {
+ public class FECJob {
final Bucket[] dataBlocks, checkBlocks;
final SplitfileBlock[] dataBlockStatus, checkBlockStatus;
final BucketFactory bucketFactory;
@@ -491,7 +475,7 @@
final StandardOnionFECCodecEncoderCallback callback;
final boolean isADecodingJob;
- FECJob(SplitfileBlock[] dataBlockStatus, SplitfileBlock[]
checkBlockStatus, int blockLength, BucketFactory bucketFactory,
StandardOnionFECCodecEncoderCallback callback, boolean isADecodingJob) {
+ public FECJob(SplitfileBlock[] dataBlockStatus,
SplitfileBlock[] checkBlockStatus, int blockLength, BucketFactory
bucketFactory, StandardOnionFECCodecEncoderCallback callback, boolean
isADecodingJob) {
this.dataBlockStatus = dataBlockStatus;
this.checkBlockStatus = checkBlockStatus;
@@ -508,7 +492,7 @@
this.isADecodingJob = isADecodingJob;
}
- FECJob(Bucket[] dataBlocks, Bucket[] checkBlocks, int
blockLength, BucketFactory bucketFactory, StandardOnionFECCodecEncoderCallback
callback, boolean isADecodingJob) {
+ public FECJob(Bucket[] dataBlocks, Bucket[] checkBlocks, int
blockLength, BucketFactory bucketFactory, StandardOnionFECCodecEncoderCallback
callback, boolean isADecodingJob) {
this.dataBlocks = dataBlocks;
this.checkBlocks = checkBlocks;
this.dataBlockStatus = null;
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2007-03-24 14:27:15 UTC (rev 12306)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2007-03-24 14:35:01 UTC (rev 12307)
@@ -195,7 +195,7 @@
if(splitfileType != Metadata.SPLITFILE_NONREDUNDANT) {
StandardOnionFECCodec fec =
(StandardOnionFECCodec)codec;
- fec.addToQueue(dataBuckets, checkBuckets,
CHKBlock.DATA_LENGTH, fetchContext.bucketFactory, this, true);
+ fec.addToQueue(fec.new FECJob(dataBuckets,
checkBuckets, CHKBlock.DATA_LENGTH, fetchContext.bucketFactory, this, true));
// Now have all the data blocks (not necessarily all
the check blocks)
}
}
@@ -234,7 +234,7 @@
// Encode any check blocks we don't have
if(codec != null) {
StandardOnionFECCodec fec = (StandardOnionFECCodec)
codec;
- fec.addToQueue(dataBuckets, checkBuckets, 32768,
fetchContext.bucketFactory, this, false);
+ fec.addToQueue(fec.new FECJob(dataBuckets,
checkBuckets, 32768, fetchContext.bucketFactory, this, false));
}
}
Modified: trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2007-03-24 14:27:15 UTC (rev 12306)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2007-03-24 14:35:01 UTC (rev 12307)
@@ -423,8 +423,8 @@
// Encode blocks
synchronized(this) {
if(!encoded){
- StandardOnionFECCodec fec =
(StandardOnionFECCodec) splitfileAlgo;
- fec.addToQueue(dataBlocks,
checkBlocks, CHKBlock.DATA_LENGTH, blockInsertContext.persistentBucketFactory,
this, false);
+ StandardOnionFECCodec fec =
(StandardOnionFECCodec) splitfileAlgo;
+ fec.addToQueue(fec.new
FECJob(dataBlocks, checkBlocks, CHKBlock.DATA_LENGTH,
blockInsertContext.persistentBucketFactory, this, false));
}
}
fin = false;