Author: toad
Date: 2008-10-29 20:21:19 +0000 (Wed, 29 Oct 2008)
New Revision: 23190
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
Log:
Activation, don't store FEC codec.
Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-10-29 20:17:52 UTC (rev 23189)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-10-29 20:21:19 UTC (rev 23190)
@@ -242,8 +242,7 @@
// First split the data up
if((dataBlocks < segmentSize) || (segmentSize == -1)) {
// Single segment
- FECCodec codec = FECCodec.getCodec(splitfileAlgorithm,
origDataBlocks.length, executor);
- SplitFileInserterSegment onlySeg = new
SplitFileInserterSegment(this, codec, origDataBlocks, ctx, getCHKOnly, 0,
container);
+ SplitFileInserterSegment onlySeg = new
SplitFileInserterSegment(this, splitfileAlgorithm,
FECCodec.getCheckBlocks(splitfileAlgorithm, origDataBlocks.length),
origDataBlocks, ctx, getCHKOnly, 0, container);
segs.add(onlySeg);
} else {
int j = 0;
@@ -255,8 +254,7 @@
j = i;
for(int x=0;x<seg.length;x++)
if(seg[x] == null) throw new
NullPointerException("In splitIntoSegs: "+x+" is null of "+seg.length+" of
"+segNo);
- FECCodec codec =
FECCodec.getCodec(splitfileAlgorithm, seg.length, executor);
- SplitFileInserterSegment s = new
SplitFileInserterSegment(this, codec, seg, ctx, getCHKOnly, segNo, container);
+ SplitFileInserterSegment s = new
SplitFileInserterSegment(this, splitfileAlgorithm,
FECCodec.getCheckBlocks(splitfileAlgorithm, seg.length), seg, ctx, getCHKOnly,
segNo, container);
segs.add(s);
if(i == dataBlocks) break;
@@ -372,6 +370,13 @@
missingURIs = anyNulls(dataURIs) || anyNulls(checkURIs);
+ if(persistent) {
+ for(ClientCHK key : dataURIs)
+ container.activate(key, 5);
+ for(ClientCHK key : checkURIs)
+ container.activate(key, 5);
+ }
+
if(!missingURIs) {
// Create Metadata
m = new Metadata(splitfileAlgorithm, dataURIs,
checkURIs, segmentSize, checkSegmentSize, cm, dataLength, compressionCodec,
decompressedLength, isMetadata, insertAsArchiveManifest);
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-10-29 20:17:52 UTC (rev 23189)
+++
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-10-29 20:21:19 UTC (rev 23190)
@@ -31,7 +31,7 @@
final SplitFileInserter parent;
- final FECCodec splitfileAlgo;
+ final short splitfileAlgo;
final Bucket[] dataBlocks;
@@ -79,7 +79,7 @@
}
public SplitFileInserterSegment(SplitFileInserter parent,
- FECCodec splitfileAlgo, Bucket[] origDataBlocks,
+ short splitfileAlgo, int checkBlockCount, Bucket[]
origDataBlocks,
InsertContext blockInsertContext, boolean getCHKOnly,
int segNo, ObjectContainer container) {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
hashCode = super.hashCode();
@@ -90,8 +90,6 @@
this.blockInsertContext = blockInsertContext;
this.splitfileAlgo = splitfileAlgo;
this.dataBlocks = origDataBlocks;
- int checkBlockCount = splitfileAlgo == null ? 0 : splitfileAlgo
- .countCheckBlocks();
checkBlocks = new Bucket[checkBlockCount];
checkURIs = new ClientCHK[checkBlockCount];
dataURIs = new ClientCHK[origDataBlocks.length];
@@ -112,6 +110,7 @@
boolean getCHKOnly, int segNo, ClientContext context,
ObjectContainer container) throws ResumeException {
hashCode = super.hashCode();
this.parent = parent;
+ this.splitfileAlgo = splitfileAlgorithm;
this.getCHKOnly = getCHKOnly;
this.persistent = parent.persistent;
this.blockInsertContext = ctx;
@@ -238,8 +237,8 @@
}
checkFS.removeSubset(index);
}
- splitfileAlgo = FECCodec.getCodec(splitfileAlgorithm,
- dataBlockCount, checkBlocks.length,
context.mainExecutor);
+ if(persistent)
+ container.activate(splitfileAlgorithm, 10);
if(checkBlocks.length > dataBlocks.length) {
// Work around 1135 bug.
@@ -249,9 +248,9 @@
} else {
Logger.normal(this, "Not encoded because no check
blocks");
encoded = false;
- splitfileAlgo = FECCodec.getCodec(splitfileAlgorithm,
+ FECCodec splitfileAlgo =
FECCodec.getCodec(splitfileAlgorithm,
dataBlockCount, context.mainExecutor);
- int checkBlocksCount = splitfileAlgo.countCheckBlocks();
+ int checkBlocksCount =splitfileAlgo.countCheckBlocks();
this.checkURIs = new ClientCHK[checkBlocksCount];
this.checkBlocks = new Bucket[checkBlocksCount];
this.checkBlockInserters = new
SingleBlockInserter[checkBlocksCount];
@@ -446,7 +445,8 @@
if (logMINOR)
Logger.minor(this, "Segment " + segNo + " of "
+ parent + " ("
+ parent.dataLength + ") is not
encoded");
- if (splitfileAlgo != null) {
+ FECCodec splitfileAlgo =
FECCodec.getCodec(this.splitfileAlgo,
+ dataBlocks.length, checkBlocks.length,
context.mainExecutor);
if (logMINOR)
Logger.minor(this, "Encoding segment "
+ segNo + " of "
+ parent + " (" +
parent.dataLength + ") persistent="+persistent);
@@ -462,7 +462,6 @@
}
}
fin = false;
- }
} else {
for (int i = 0; i < checkBlockInserters.length; i++) {
if (checkBlocks[i] != null) {