Author: toad
Date: 2008-06-13 12:01:30 +0000 (Fri, 13 Jun 2008)
New Revision: 20281
Modified:
branches/db4o/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
Log:
Encodes happen on the database thread, so we should pass in the
container/context.
Some other build/params fixes.
Modified:
branches/db4o/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
2008-06-13 03:51:06 UTC (rev 20280)
+++ branches/db4o/freenet/src/freenet/client/async/BackgroundBlockEncoder.java
2008-06-13 12:01:30 UTC (rev 20281)
@@ -98,7 +98,7 @@
Logger.minor(this, "Encoding "+sbi);
if(sbi.isCancelled()) continue;
if(sbi.resultingURI != null) continue;
- sbi.tryEncode();
+ sbi.tryEncode(null);
}
}
Modified: branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
2008-06-13 03:51:06 UTC (rev 20280)
+++ branches/db4o/freenet/src/freenet/client/async/InsertCompressor.java
2008-06-13 12:01:30 UTC (rev 20281)
@@ -97,12 +97,12 @@
context.jobRunner.queue(new DBJob() {
- public void run(ObjectContainer
container) {
+ public void run(ObjectContainer
container, ClientContext context) {
inserter.onCompressed(output,
container, context);
container.delete(InsertCompressor.this);
}
- }, NativeThread.NORM_PRIORITY);
+ }, NativeThread.NORM_PRIORITY, false);
} else {
inserter.onCompressed(output, null, context);
}
@@ -111,12 +111,12 @@
if(persistent) {
context.jobRunner.queue(new DBJob() {
- public void run(ObjectContainer
container) {
+ public void run(ObjectContainer
container, ClientContext context) {
inserter.cb.onFailure(new
InsertException(InsertException.BUCKET_ERROR, e, null), inserter, container,
context);
container.delete(InsertCompressor.this);
}
- }, NativeThread.NORM_PRIORITY);
+ }, NativeThread.NORM_PRIORITY, false);
} else {
inserter.cb.onFailure(new
InsertException(InsertException.BUCKET_ERROR, e, null), inserter, null,
context);
}
@@ -125,12 +125,12 @@
if(persistent) {
context.jobRunner.queue(new DBJob() {
- public void run(ObjectContainer
container) {
+ public void run(ObjectContainer
container, ClientContext context) {
inserter.cb.onFailure(new
InsertException(InsertException.BUCKET_ERROR, e, null), inserter, container,
context);
container.delete(InsertCompressor.this);
}
- }, NativeThread.NORM_PRIORITY);
+ }, NativeThread.NORM_PRIORITY, false);
} else {
inserter.cb.onFailure(new
InsertException(InsertException.BUCKET_ERROR, e, null), inserter, null,
context);
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-06-13 03:51:06 UTC (rev 20280)
+++ branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-06-13 12:01:30 UTC (rev 20281)
@@ -110,7 +110,7 @@
}
}
- protected ClientKeyBlock encode(ObjectContainer container) throws
InsertException {
+ protected ClientKeyBlock encode(ObjectContainer container,
ClientContext context) throws InsertException {
ClientKeyBlock block;
boolean shouldSend;
synchronized(this) {
@@ -125,7 +125,7 @@
resultingURI = block.getClientKey().getURI();
}
if(shouldSend && !dontSendEncoded)
- cb.onEncode(block.getClientKey(), this, container);
+ cb.onEncode(block.getClientKey(), this, container,
context);
return block;
}
@@ -172,7 +172,7 @@
if(logMINOR) Logger.minor(this, "Consecutive RNFs:
"+consecutiveRNFs+" / "+ctx.consecutiveRNFsCountAsSuccess);
if(consecutiveRNFs ==
ctx.consecutiveRNFsCountAsSuccess) {
if(logMINOR) Logger.minor(this, "Consecutive
RNFs: "+consecutiveRNFs+" - counting as success");
- onSuccess(keyNum, container);
+ onSuccess(keyNum, container, context);
return;
}
} else
@@ -202,18 +202,18 @@
cb.onFailure(e, this, container, context);
}
- public ClientKeyBlock getBlock() {
+ public ClientKeyBlock getBlock(ObjectContainer container, ClientContext
context) {
try {
synchronized (this) {
if(finished) return null;
}
- return encode();
+ return encode(container, context);
} catch (InsertException e) {
- cb.onFailure(e, this);
+ cb.onFailure(e, this, container, context);
return null;
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
- cb.onFailure(new
InsertException(InsertException.INTERNAL_ERROR, t, null), this);
+ cb.onFailure(new
InsertException(InsertException.INTERNAL_ERROR, t, null), this, container,
context);
return null;
}
}
@@ -223,8 +223,8 @@
if(finished) return;
}
if(getCHKOnly) {
- ClientKeyBlock block = encode(container);
- cb.onEncode(block.getClientKey(), this, container);
+ ClientKeyBlock block = encode(container, context);
+ cb.onEncode(block.getClientKey(), this, container,
context);
parent.completedBlock(false);
cb.onSuccess(this, container, context);
finished = true;
@@ -242,12 +242,12 @@
else throw new IllegalArgumentException();
}
- public FreenetURI getURI() {
+ public FreenetURI getURI(ObjectContainer container, ClientContext
context) {
synchronized(this) {
if(resultingURI != null)
return resultingURI;
}
- getBlock();
+ getBlock(container, context);
synchronized(this) {
// FIXME not really necessary? resultingURI is never
dropped, only set.
return resultingURI;
@@ -258,30 +258,30 @@
return resultingURI;
}
- public void onSuccess(Object keyNum, ObjectContainer container) {
+ public void onSuccess(Object keyNum, ObjectContainer container,
ClientContext context) {
if(logMINOR) Logger.minor(this, "Succeeded ("+this+"): "+token);
if(parent.isCancelled()) {
- fail(new InsertException(InsertException.CANCELLED),
container);
+ fail(new InsertException(InsertException.CANCELLED),
container, context);
return;
}
synchronized(this) {
finished = true;
}
parent.completedBlock(false);
- cb.onSuccess(this, container);
+ cb.onSuccess(this, container, context);
}
public BaseClientPutter getParent() {
return parent;
}
- public void cancel(ObjectContainer container) {
+ public void cancel(ObjectContainer container, ClientContext context) {
synchronized(this) {
if(finished) return;
finished = true;
}
super.unregister(false);
- cb.onFailure(new InsertException(InsertException.CANCELLED),
this, container);
+ cb.onFailure(new InsertException(InsertException.CANCELLED),
this, container, context);
}
public synchronized boolean isEmpty() {
@@ -339,11 +339,11 @@
}
/** Attempt to encode the block, if necessary */
- public void tryEncode() {
+ public void tryEncode(ObjectContainer container, ClientContext context)
{
try {
- encode();
+ encode(container, context);
} catch (InsertException e) {
- fail(e);
+ fail(e, container, context);
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
// Don't requeue on BackgroundBlockEncoder.
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-13 03:51:06 UTC (rev 20280)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileFetcher.java
2008-06-13 12:01:30 UTC (rev 20281)
@@ -559,10 +559,10 @@
else {
if(!context.jobRunner.onDatabaseThread())
context.jobRunner.queue(new DBJob() {
- public void run(ObjectContainer
container) {
+ public void run(ObjectContainer
container, ClientContext context) {
innerWrapHandleMetadata(notFinalizedSize, container, context);
}
- }, parent.getPriorityClass());
+ }, parent.getPriorityClass(), false);
else
innerWrapHandleMetadata(notFinalizedSize,
container, context);
}