Author: toad
Date: 2006-01-23 21:46:27 +0000 (Mon, 23 Jan 2006)
New Revision: 7904
Modified:
branches/async-client/src/freenet/client/async/SingleBlockInserter.java
branches/async-client/src/freenet/client/async/SingleFileInserter.java
branches/async-client/src/freenet/client/async/SplitFileInserterSegment.java
Log:
getCHKOnly mostly.
Modified:
branches/async-client/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/async-client/src/freenet/client/async/SingleBlockInserter.java
2006-01-23 21:30:18 UTC (rev 7903)
+++ branches/async-client/src/freenet/client/async/SingleBlockInserter.java
2006-01-23 21:46:27 UTC (rev 7904)
@@ -39,7 +39,7 @@
final boolean isMetadata;
final int sourceLength;
- public SingleBlockInserter(ClientPut parent, Bucket data, short
compressionCodec, FreenetURI uri, InserterContext ctx, PutCompletionCallback
cb, boolean isMetadata, int sourceLength, int token) throws InserterException {
+ public SingleBlockInserter(ClientPut parent, Bucket data, short
compressionCodec, FreenetURI uri, InserterContext ctx, PutCompletionCallback
cb, boolean isMetadata, int sourceLength, int token, boolean getCHKOnly) throws
InserterException {
this.token = token;
this.parent = parent;
this.retries = 0;
@@ -52,6 +52,12 @@
this.sourceData = data;
this.isMetadata = isMetadata;
this.sourceLength = sourceLength;
+ if(getCHKOnly) {
+ ClientKeyBlock block = encode();
+ cb.onEncode(block.getClientKey(), this);
+ cb.onSuccess(this);
+ finished = true;
+ }
}
protected ClientKeyBlock innerEncode() throws InserterException {
@@ -93,6 +99,7 @@
refToClientKeyBlock =
new SoftReference(block);
resultingURI = block.getClientKey().getURI();
+ cb.onEncode(block.getClientKey(), this);
return block;
}
@@ -160,10 +167,7 @@
}
public void schedule() {
- if(finished) {
- Logger.normal(this, "Asking to schedule but already
finished");
- return;
- }
+ if(finished) return;
parent.scheduler.register(this);
}
Modified: branches/async-client/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/async-client/src/freenet/client/async/SingleFileInserter.java
2006-01-23 21:30:18 UTC (rev 7903)
+++ branches/async-client/src/freenet/client/async/SingleFileInserter.java
2006-01-23 21:46:27 UTC (rev 7904)
@@ -144,7 +144,7 @@
if((block.clientMetadata == null ||
block.clientMetadata.isTrivial())) {
if(data.size() < blockSize) {
// Just insert it
- SingleBlockInserter bi = new
SingleBlockInserter(parent, data, codecNumber, block.desiredURI, ctx, cb,
metadata, (int)block.getData().size(), -1);
+ SingleBlockInserter bi = new
SingleBlockInserter(parent, data, codecNumber, block.desiredURI, ctx, cb,
metadata, (int)block.getData().size(), -1, getCHKOnly);
bi.schedule();
return;
}
@@ -153,7 +153,7 @@
MultiPutCompletionCallback mcb =
new MultiPutCompletionCallback(cb, parent,
dontTellParent);
// Insert single block, then insert pointer to it
- SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
mcb, metadata, (int)origSize, -1);
+ SingleBlockInserter dataPutter = new
SingleBlockInserter(parent, data, codecNumber, FreenetURI.EMPTY_CHK_URI, ctx,
mcb, metadata, (int)origSize, -1, getCHKOnly);
Metadata meta = new Metadata(Metadata.SIMPLE_REDIRECT,
dataPutter.getURI(), block.clientMetadata);
Bucket metadataBucket;
try {
@@ -161,7 +161,7 @@
} catch (IOException e) {
throw new
InserterException(InserterException.BUCKET_ERROR, e, null);
}
- SingleBlockInserter metaPutter = new
SingleBlockInserter(parent, metadataBucket, (short) -1, block.desiredURI, ctx,
mcb, true, (int)origSize, -1);
+ SingleBlockInserter metaPutter = new
SingleBlockInserter(parent, metadataBucket, (short) -1, block.desiredURI, ctx,
mcb, true, (int)origSize, -1, getCHKOnly);
mcb.add(metaPutter);
mcb.add(dataPutter);
mcb.arm();
Modified:
branches/async-client/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
---
branches/async-client/src/freenet/client/async/SplitFileInserterSegment.java
2006-01-23 21:30:18 UTC (rev 7903)
+++
branches/async-client/src/freenet/client/async/SplitFileInserterSegment.java
2006-01-23 21:46:27 UTC (rev 7904)
@@ -26,6 +26,7 @@
final int segNo;
private boolean encoded;
private boolean finished;
+ private boolean getCHKOnly;
private InserterException toThrow;
private final FailureCodeTracker errors;
private int blocksGotURI;
@@ -49,7 +50,7 @@
public void start() throws InserterException {
for(int i=0;i<dataBlockInserters.length;i++)
dataBlockInserters[i] =
- new SingleBlockInserter(parent.parent,
dataBlocks[i], (short)-1, FreenetURI.EMPTY_CHK_URI, blockInsertContext, this,
false, ClientCHKBlock.DATA_LENGTH, i);
+ new SingleBlockInserter(parent.parent,
dataBlocks[i], (short)-1, FreenetURI.EMPTY_CHK_URI, blockInsertContext, this,
false, ClientCHKBlock.DATA_LENGTH, i, getCHKOnly);
if(splitfileAlgo == null) {
// Don't need to encode blocks
} else {
@@ -76,7 +77,7 @@
// Start the inserts
for(int i=0;i<checkBlockInserters.length;i++)
checkBlockInserters[i] =
- new SingleBlockInserter(parent.parent,
checkBlocks[i], (short)-1, FreenetURI.EMPTY_CHK_URI, blockInsertContext, this,
false, ClientCHKBlock.DATA_LENGTH, i + dataBlocks.length);
+ new SingleBlockInserter(parent.parent,
checkBlocks[i], (short)-1, FreenetURI.EMPTY_CHK_URI, blockInsertContext, this,
false, ClientCHKBlock.DATA_LENGTH, i + dataBlocks.length, getCHKOnly);
} catch (IOException e) {
InserterException ex =
new
InserterException(InserterException.BUCKET_ERROR, e, null);