Author: toad
Date: 2008-07-02 16:14:35 +0000 (Wed, 02 Jul 2008)
New Revision: 20934
Modified:
branches/db4o/freenet/src/freenet/client/FECJob.java
branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
branches/db4o/freenet/src/freenet/client/async/RegisterMe.java
branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
Log:
More persistent hashCode()'s.
Helpful with debugging, as well as avoiding any problems with putting
persistent elements into hash-based sets or maps.
Modified: branches/db4o/freenet/src/freenet/client/FECJob.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FECJob.java 2008-07-02
16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/FECJob.java 2008-07-02
16:14:35 UTC (rev 20934)
@@ -27,7 +27,13 @@
final boolean persistent;
/** Parent queue */
final FECQueue queue;
+ // A persistent hash code helps with debugging.
+ private final int hashCode;
+ public int hashCode() {
+ return hashCode;
+ }
+
public FECJob(FECCodec codec, FECQueue queue, SplitfileBlock[]
dataBlockStatus, SplitfileBlock[] checkBlockStatus, int blockLength,
BucketFactory bucketFactory, FECCallback callback, boolean isADecodingJob,
short priority, boolean persistent) {
this.codec = codec;
this.queue = queue;
@@ -48,6 +54,7 @@
this.callback = callback;
this.isADecodingJob = isADecodingJob;
this.persistent = persistent;
+ this.hashCode = super.hashCode();
}
public String toString() {
@@ -55,6 +62,7 @@
}
public FECJob(FECCodec codec, FECQueue queue, Bucket[] dataBlocks,
Bucket[] checkBlocks, int blockLength, BucketFactory bucketFactory, FECCallback
callback, boolean isADecodingJob, short priority, boolean persistent) {
+ this.hashCode = super.hashCode();
this.codec = codec;
this.queue = queue;
this.priority = priority;
Modified:
branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/PersistentChosenRequest.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -23,9 +23,16 @@
public class PersistentChosenRequest extends ChosenRequest {
ClientRequestSchedulerCore core;
+ // A persistent hashCode is helpful for debugging and lets us put PCR's
into hash-based maps and sets.
+ private final int hashCode;
PersistentChosenRequest(ClientRequestSchedulerCore core,
SendableRequest req, Object tok, Key key, ClientKey ckey, short prio) {
super(req, tok, key, ckey, prio);
+ hashCode = core.hashCode() ^ req.hashCode() ^ key.hashCode() ^
ckey.hashCode();
this.core = core;
}
+
+ public int hashCode() {
+ return hashCode;
+ }
}
Modified: branches/db4o/freenet/src/freenet/client/async/RegisterMe.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/RegisterMe.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/RegisterMe.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -13,8 +13,10 @@
final SendableRequest getter;
final ClientRequestSchedulerCore core;
final RegisterMeSortKey key;
+ private final int hashCode;
RegisterMe(SendableRequest getter, short prio,
ClientRequestSchedulerCore core) {
+ hashCode = (getter.hashCode() * prio) ^ core.hashCode();
this.getter = getter;
this.core = core;
this.key = new RegisterMeSortKey(prio);
@@ -23,5 +25,9 @@
public void objectOnActivate(ObjectContainer container) {
container.activate(key, 1);
}
+
+ public int hashCode() {
+ return hashCode;
+ }
}
Modified: branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/SingleFileInserter.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -53,6 +53,15 @@
private final boolean earlyEncode;
private final boolean persistent;
private boolean started;
+
+ // A persistent hashCode is helpful in debugging, and also means we can
put
+ // these objects into sets etc when we need to.
+
+ private final int hashCode;
+
+ public int hashCode() {
+ return hashCode;
+ }
/**
* @param parent
@@ -73,6 +82,7 @@
boolean metadata, InsertContext ctx, boolean
dontCompress,
boolean getCHKOnly, boolean reportMetadataOnly, Object
token, boolean insertAsArchiveManifest,
boolean freeData, String targetFilename, boolean
earlyEncode) {
+ hashCode = super.hashCode();
this.earlyEncode = earlyEncode;
this.reportMetadataOnly = reportMetadataOnly;
this.token = token;
Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -61,10 +61,20 @@
private long token;
final boolean persistent;
+ // A persistent hashCode is helpful in debugging, and also means we can
put
+ // these objects into sets etc when we need to.
+
+ private final int hashCode;
+
+ public int hashCode() {
+ return hashCode;
+ }
+
public SplitFileFetcher(Metadata metadata, GetCompletionCallback rcb,
ClientRequester parent2,
FetchContext newCtx, ArrayList decompressors2,
ClientMetadata clientMetadata,
ArchiveContext actx, int recursionLevel, Bucket
returnBucket, long token2, ObjectContainer container) throws FetchException,
MetadataParseException {
this.persistent = parent2.persistent();
+ this.hashCode = super.hashCode();
this.finished = false;
this.returnBucket = returnBucket;
this.fetchContext = newCtx;
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -75,10 +75,20 @@
private boolean scheduled;
private final boolean persistent;
+ // A persistent hashCode is helpful in debugging, and also means we can
put
+ // these objects into sets etc when we need to.
+
+ private final int hashCode;
+
+ public int hashCode() {
+ return hashCode;
+ }
+
private FECCodec codec;
public SplitFileFetcherSegment(short splitfileType, ClientCHK[]
splitfileDataKeys, ClientCHK[] splitfileCheckKeys, SplitFileFetcher fetcher,
ArchiveContext archiveContext, FetchContext fetchContext, long maxTempLength,
int recursionLevel, ClientRequester requester) throws MetadataParseException,
FetchException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ this.hashCode = super.hashCode();
this.persistent = fetcher.persistent;
this.parentFetcher = fetcher;
this.errors = new FailureCodeTracker(false);
Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-07-02 16:04:24 UTC (rev 20933)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileInserter.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -48,6 +48,15 @@
private boolean forceEncode;
private final long decompressedLength;
final boolean persistent;
+
+ // A persistent hashCode is helpful in debugging, and also means we can
put
+ // these objects into sets etc when we need to.
+
+ private final int hashCode;
+
+ public int hashCode() {
+ return hashCode;
+ }
public SimpleFieldSet getProgressFieldset() {
SimpleFieldSet fs = new SimpleFieldSet(false);
@@ -72,6 +81,7 @@
public SplitFileInserter(BaseClientPutter put, PutCompletionCallback
cb, Bucket data, Compressor bestCodec, long decompressedLength, ClientMetadata
clientMetadata, InsertContext ctx, boolean getCHKOnly, boolean isMetadata,
Object token, boolean insertAsArchiveManifest, boolean freeData, boolean
persistent, ObjectContainer container, ClientContext context) throws
InsertException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ hashCode = super.hashCode();
this.parent = put;
this.insertAsArchiveManifest = insertAsArchiveManifest;
this.token = token;
@@ -116,6 +126,7 @@
public SplitFileInserter(BaseClientPutter parent, PutCompletionCallback
cb, ClientMetadata clientMetadata, InsertContext ctx, boolean getCHKOnly,
boolean metadata, Object token, boolean insertAsArchiveManifest, SimpleFieldSet
fs, ObjectContainer container, ClientContext context) throws ResumeException {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ hashCode = super.hashCode();
this.parent = parent;
this.insertAsArchiveManifest = insertAsArchiveManifest;
this.token = token;
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-07-02 16:04:24 UTC (rev 20933)
+++
branches/db4o/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2008-07-02 16:14:35 UTC (rev 20934)
@@ -68,11 +68,21 @@
private int blocksCompleted;
private final boolean persistent;
+
+ // A persistent hashCode is helpful in debugging, and also means we can
put
+ // these objects into sets etc when we need to.
+
+ private final int hashCode;
+
+ public int hashCode() {
+ return hashCode;
+ }
public SplitFileInserterSegment(SplitFileInserter parent,
FECCodec splitfileAlgo, Bucket[] origDataBlocks,
InsertContext blockInsertContext, boolean getCHKOnly,
int segNo, ObjectContainer container) {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ hashCode = super.hashCode();
this.parent = parent;
this.getCHKOnly = getCHKOnly;
this.persistent = parent.persistent;
@@ -100,6 +110,7 @@
public SplitFileInserterSegment(SplitFileInserter parent,
SimpleFieldSet fs, short splitfileAlgorithm,
InsertContext ctx,
boolean getCHKOnly, int segNo, ClientContext context,
ObjectContainer container) throws ResumeException {
+ hashCode = super.hashCode();
this.parent = parent;
this.getCHKOnly = getCHKOnly;
this.persistent = parent.persistent;