Author: toad
Date: 2009-01-28 17:49:17 +0000 (Wed, 28 Jan 2009)
New Revision: 25356
Modified:
branches/db4o/freenet/src/freenet/client/Metadata.java
branches/db4o/freenet/src/freenet/client/MetadataUnresolvedException.java
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
Log:
Resolve immediately on getting metadata to speed up site inserts and reduce the
amount to commit in the gotAllMetadata transaction.
Modified: branches/db4o/freenet/src/freenet/client/Metadata.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/Metadata.java 2009-01-28
17:42:06 UTC (rev 25355)
+++ branches/db4o/freenet/src/freenet/client/Metadata.java 2009-01-28
17:49:17 UTC (rev 25356)
@@ -105,6 +105,7 @@
short splitfileAlgorithm;
static public final short SPLITFILE_NONREDUNDANT = 0;
static public final short SPLITFILE_ONION_STANDARD = 1;
+ public static final int MAX_SIZE_IN_MANIFEST = Short.MAX_VALUE;
/** Splitfile parameters */
byte[] splitfileParams;
@@ -859,7 +860,7 @@
Metadata meta = (Metadata)
manifestEntries.get(name);
try {
byte[] data = meta.writeToByteArray();
- if(data.length > Short.MAX_VALUE) {
+ if(data.length > MAX_SIZE_IN_MANIFEST) {
FreenetURI uri =
meta.resolvedURI;
if(uri != null) {
meta = new
Metadata(SIMPLE_REDIRECT, null, null, uri, null);
Modified:
branches/db4o/freenet/src/freenet/client/MetadataUnresolvedException.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/MetadataUnresolvedException.java
2009-01-28 17:42:06 UTC (rev 25355)
+++ branches/db4o/freenet/src/freenet/client/MetadataUnresolvedException.java
2009-01-28 17:49:17 UTC (rev 25356)
@@ -8,7 +8,7 @@
public final Metadata[] mustResolve;
- MetadataUnresolvedException(Metadata[] mustResolve, String message) {
+ public MetadataUnresolvedException(Metadata[] mustResolve, String
message) {
super(message);
this.mustResolve = mustResolve;
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2009-01-28 17:42:06 UTC (rev 25355)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2009-01-28 17:49:17 UTC (rev 25356)
@@ -197,7 +197,24 @@
}
}
if(allMetadatas) {
+ // Will resolve etc.
gotAllMetadata(container, context);
+ } else {
+ // Resolve now to speed up the insert.
+ try {
+ byte[] buf = m.writeToByteArray();
+ if(buf.length >
Metadata.MAX_SIZE_IN_MANIFEST)
+ throw new
MetadataUnresolvedException(new Metadata[] { m }, "Too big");
+ } catch (MetadataUnresolvedException e) {
+ try {
+ resolve(e, container, context);
+ } catch (IOException e1) {
+ fail(new
InsertException(InsertException.BUCKET_ERROR, e1, null), container);
+ return;
+ } catch (InsertException e1) {
+ fail(e1, container);
+ }
+ }
}
if(persistent) {
container.deactivate(SimpleManifestPutter.this,
1);
@@ -701,7 +718,8 @@
}
/**
- * Start inserts for unresolved (too big) Metadata's.
+ * Start inserts for unresolved (too big) Metadata's. Eventually these
will call back with an onEncode(),
+ * meaning they have the CHK, and we can progress to
resolveAndStartBase().
* @param e
* @param container
* @param context
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs