Author: toad
Date: 2005-11-05 21:02:26 +0000 (Sat, 05 Nov 2005)
New Revision: 7485
Modified:
trunk/freenet/src/freenet/client/Fetcher.java
trunk/freenet/src/freenet/client/FetcherContext.java
trunk/freenet/src/freenet/client/Segment.java
trunk/freenet/src/freenet/client/SplitFetcher.java
trunk/freenet/src/freenet/keys/NodeCHK.java
Log:
More minor fixes. More files compile now.
Modified: trunk/freenet/src/freenet/client/Fetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/Fetcher.java 2005-11-05 20:47:25 UTC
(rev 7484)
+++ trunk/freenet/src/freenet/client/Fetcher.java 2005-11-05 21:02:26 UTC
(rev 7485)
@@ -231,7 +231,13 @@
return runMetadata(dm, recursionLevel+1, key,
metaStrings, metadata, container, thisKey, dontEnterImplicitArchives);
}
- SplitFetcher sf = new SplitFetcher(metadata,
ctx.maxTempLength, archiveContext, ctx);
+ FetcherContext newCtx;
+ if(metadata.splitUseLengths)
+ newCtx = new FetcherContext(ctx,
FetcherContext.SPLITFILE_USE_LENGTHS_MASK);
+ else
+ newCtx = new FetcherContext(ctx,
FetcherContext.SPLITFILE_DEFAULT_MASK);
+
+ SplitFetcher sf = new SplitFetcher(metadata,
archiveContext, newCtx);
Bucket sfResult = sf.fetch(); // will throw in event of
error
return new FetchResult(dm, sfResult);
} else {
Modified: trunk/freenet/src/freenet/client/FetcherContext.java
===================================================================
--- trunk/freenet/src/freenet/client/FetcherContext.java 2005-11-05
20:47:25 UTC (rev 7484)
+++ trunk/freenet/src/freenet/client/FetcherContext.java 2005-11-05
21:02:26 UTC (rev 7485)
@@ -7,7 +7,9 @@
/** Context for a Fetcher. Contains all the settings a Fetcher needs to know
about. */
public class FetcherContext implements Cloneable {
- public static final int SPLITFILE_DEFAULT_MASK = 1;
+ static final int SPLITFILE_DEFAULT_BLOCK_MASK = 1;
+ static final int SPLITFILE_DEFAULT_MASK = 2;
+ static final int SPLITFILE_USE_LENGTHS_MASK = 3;
/** Low-level client to send low-level requests to. */
final SimpleLowLevelClient client;
final long maxOutputLength;
@@ -24,6 +26,9 @@
final boolean allowSplitfiles;
final boolean followRedirects;
final boolean localRequestOnly;
+ /** Whether to allow non-full blocks, or blocks which are not direct
CHKs, in splitfiles.
+ * Set by the splitfile metadata and the mask constructor, so we don't
need to pass it in. */
+ final boolean splitfileUseLengths;
public FetcherContext(SimpleLowLevelClient client, long curMaxLength,
long curMaxTempLength, int maxRecursionLevel, int
maxArchiveRestarts,
@@ -46,10 +51,11 @@
this.allowSplitfiles = allowSplitfiles;
this.followRedirects = followRedirects;
this.localRequestOnly = localRequestOnly;
+ this.splitfileUseLengths = false;
}
public FetcherContext(FetcherContext ctx, int maskID) {
- if(maskID == SPLITFILE_DEFAULT_MASK) {
+ if(maskID == SPLITFILE_DEFAULT_BLOCK_MASK) {
this.client = ctx.client;
this.maxOutputLength = ctx.maxOutputLength;
this.maxTempLength = ctx.maxTempLength;
@@ -65,6 +71,41 @@
this.allowSplitfiles = false;
this.followRedirects = false;
this.localRequestOnly = ctx.localRequestOnly;
+ this.splitfileUseLengths = false;
+ } else if(maskID == SPLITFILE_DEFAULT_MASK) {
+ this.client = ctx.client;
+ this.maxOutputLength = ctx.maxOutputLength;
+ this.maxTempLength = ctx.maxTempLength;
+ this.archiveManager = ctx.archiveManager;
+ this.bucketFactory = ctx.bucketFactory;
+ this.maxRecursionLevel = ctx.maxRecursionLevel;
+ this.maxArchiveRestarts = ctx.maxArchiveRestarts;
+ this.dontEnterImplicitArchives =
ctx.dontEnterImplicitArchives;
+ this.random = ctx.random;
+ this.maxSplitfileThreads = ctx.maxSplitfileThreads;
+ this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
+ this.maxNonSplitfileRetries =
ctx.maxNonSplitfileRetries;
+ this.allowSplitfiles = ctx.allowSplitfiles;
+ this.followRedirects = ctx.followRedirects;
+ this.localRequestOnly = ctx.localRequestOnly;
+ this.splitfileUseLengths = false;
+ } else if(maskID == SPLITFILE_USE_LENGTHS_MASK) {
+ this.client = ctx.client;
+ this.maxOutputLength = ctx.maxOutputLength;
+ this.maxTempLength = ctx.maxTempLength;
+ this.archiveManager = ctx.archiveManager;
+ this.bucketFactory = ctx.bucketFactory;
+ this.maxRecursionLevel = ctx.maxRecursionLevel;
+ this.maxArchiveRestarts = ctx.maxArchiveRestarts;
+ this.dontEnterImplicitArchives =
ctx.dontEnterImplicitArchives;
+ this.random = ctx.random;
+ this.maxSplitfileThreads = ctx.maxSplitfileThreads;
+ this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
+ this.maxNonSplitfileRetries =
ctx.maxNonSplitfileRetries;
+ this.allowSplitfiles = ctx.allowSplitfiles;
+ this.followRedirects = ctx.followRedirects;
+ this.localRequestOnly = ctx.localRequestOnly;
+ this.splitfileUseLengths = true;
} else throw new IllegalArgumentException();
}
Modified: trunk/freenet/src/freenet/client/Segment.java
===================================================================
--- trunk/freenet/src/freenet/client/Segment.java 2005-11-05 20:47:25 UTC
(rev 7484)
+++ trunk/freenet/src/freenet/client/Segment.java 2005-11-05 21:02:26 UTC
(rev 7485)
@@ -239,7 +239,7 @@
minRetryLevel = 0;
this.recursionLevel = recursionLevel;
// FIXME be a bit more flexible here depending on flags
- blockFetchContext = new FetcherContext(fetcherContext,
FetcherContext.SPLITFILE_DEFAULT_MASK);
+ blockFetchContext = new FetcherContext(fetcherContext,
FetcherContext.SPLITFILE_DEFAULT_BLOCK_MASK);
}
/**
Modified: trunk/freenet/src/freenet/client/SplitFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/SplitFetcher.java 2005-11-05 20:47:25 UTC
(rev 7484)
+++ trunk/freenet/src/freenet/client/SplitFetcher.java 2005-11-05 21:02:26 UTC
(rev 7485)
@@ -7,6 +7,7 @@
import com.onionnetworks.fec.FECCodeFactory;
import freenet.keys.FreenetURI;
+import freenet.keys.NodeCHK;
import freenet.support.Bucket;
/**
@@ -55,15 +56,16 @@
/** Accept non-full splitfile chunks? */
private boolean splitUseLengths;
- public SplitFetcher(Metadata metadata, long maxTempLength,
ArchiveContext archiveContext, FetcherContext ctx) throws
MetadataParseException {
+ public SplitFetcher(Metadata metadata, ArchiveContext archiveContext,
FetcherContext ctx) throws MetadataParseException {
actx = archiveContext;
fctx = ctx;
overrideLength = metadata.dataLength;
- this.maxTempLength = maxTempLength;
+ this.maxTempLength = ctx.maxTempLength;
splitfileType = metadata.getSplitfileType();
splitfileDataBlocks = metadata.getSplitfileDataKeys();
splitfileCheckBlocks = metadata.getSplitfileCheckKeys();
splitUseLengths = metadata.splitUseLengths;
+ int blockLength = splitUseLengths ? -1 : NodeCHK.BLOCK_SIZE;
if(splitfileType == Metadata.SPLITFILE_NONREDUNDANT) {
// Don't need to do much - just fetch everything and
piece it together.
blocksPerSegment = -1;
@@ -79,7 +81,7 @@
} else throw new MetadataParseException("Unknown splitfile
format: "+splitfileType);
segments = new Segment[segmentCount]; // initially null on all
entries
if(segmentCount == 1) {
- segments[0] = new Segment(splitfileType,
splitfileDataBlocks, splitfileCheckBlocks, this, archiveContext, ctx,
maxTempLength, splitUseLengths);
+ segments[0] = new Segment(splitfileType,
splitfileDataBlocks, splitfileCheckBlocks, this, archiveContext, ctx,
maxTempLength, splitUseLengths, blockLength);
} else {
int dataBlocksPtr = 0;
int checkBlocksPtr = 0;
@@ -95,7 +97,7 @@
System.arraycopy(splitfileCheckBlocks,
checkBlocksPtr, checkBlocks, 0, copyCheckBlocks);
dataBlocksPtr += copyDataBlocks;
checkBlocksPtr += copyCheckBlocks;
- segments[i] = new Segment(splitfileType,
dataBlocks, checkBlocks, this, archiveContext, ctx, maxTempLength,
splitUseLengths);
+ segments[i] = new Segment(splitfileType,
dataBlocks, checkBlocks, this, archiveContext, ctx, maxTempLength,
splitUseLengths, blockLength);
}
}
unstartedSegments = segments;
Modified: trunk/freenet/src/freenet/keys/NodeCHK.java
===================================================================
--- trunk/freenet/src/freenet/keys/NodeCHK.java 2005-11-05 20:47:25 UTC (rev
7484)
+++ trunk/freenet/src/freenet/keys/NodeCHK.java 2005-11-05 21:02:26 UTC (rev
7485)
@@ -33,6 +33,8 @@
byte[] routingKey;
public static final short TYPE = 0x0302;
+ /** The size of the data */
+ public static final int BLOCK_SIZE = 32768;
public final void writeToDataOutputStream(DataOutputStream stream) throws
IOException {
write(stream);