[freenet-cvs] r9994 - trunk/freenet/src/freenet/node
Author: toad
Date: 2006-08-09 12:46:15 + (Wed, 09 Aug 2006)
New Revision: 9994
Modified:
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/SSKInsertHandler.java
trunk/freenet/src/freenet/node/Version.java
Log:
938: Decision on when to cache in the long term store was wrong.
What we should actually check is "Is this node closer to the key than any
connected node?"
What we were checking was "Did we reset the HTL? (i.e. are we closer than all
hops so far?)".
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===
--- trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-09 12:25:31 UTC
(rev 9993)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-09 12:46:15 UTC
(rev 9994)
@@ -349,7 +349,7 @@
if(!canCommit) return;
if(!prb.allReceived()) return;
CHKBlock block = new CHKBlock(prb.getBlock(), headers, key);
-node.store(block, resetNearestLoc);
+node.store(block);
Logger.minor(this, "Committed");
} catch (CHKVerifyException e) {
Logger.error(this, "Verify failed in InsertHandler: "+e+" -
headers: "+HexUtil.bytesToHex(headers), e);
Modified: trunk/freenet/src/freenet/node/Node.java
===
--- trunk/freenet/src/freenet/node/Node.java2006-08-09 12:25:31 UTC (rev
9993)
+++ trunk/freenet/src/freenet/node/Node.java2006-08-09 12:46:15 UTC (rev
9994)
@@ -2168,7 +2168,7 @@
}
long startTime = System.currentTimeMillis();
if(cache) {
- store(block, false);
+ store(block);
}
is = makeInsertSender((NodeCHK)block.getKey(),
MAX_HTL, uid, null, headers, prb, false,
lm.getLocation().getValue(), cache);
@@ -2276,7 +2276,7 @@
if(cache) {
try {
if(cache)
- store(block, false);
+ storeInsert(block);
} catch (KeyCollisionException e) {
throw new
LowLevelPutException(LowLevelPutException.COLLISION);
}
@@ -2838,13 +2838,26 @@
"\nSSK Datacache:
"+sskDatacache.hits()+"/"+(sskDatacache.hits()+sskDatacache.misses())+"/"+sskDatacache.keyCount());
}
+ public void store(CHKBlock block) {
+ store(block, block.getKey().toNormalizedDouble());
+ }
+
/**
* Store a datum.
* @param deep If true, insert to the store as well as the cache. Do
not set
* this to true unless the store results from an insert, and this node
is the
* closest node to the target; see the description of chkDatastore.
*/
- public void store(CHKBlock block, boolean deep) {
+ public void store(CHKBlock block, double loc) {
+ boolean deep = !peers.isCloserLocation(loc);
+ store(block, deep);
+ }
+
+ public void storeShallow(CHKBlock block) {
+ store(block, false);
+ }
+
+ private void store(CHKBlock block, boolean deep) {
try {
if(deep) {
chkDatastore.put(block);
@@ -2861,14 +2874,19 @@
Logger.error(this, "Cannot store data: "+e, e);
}
}
+
+ /** Store the block if this is a sink. Call for inserts. */
+ public void storeInsert(SSKBlock block) throws KeyCollisionException {
+ store(block, block.getKey().toNormalizedDouble());
+ }
- /**
-* Store a datum.
-* @param deep If true, insert to the store as well as the cache. Do
not set
-* this to true unless the store results from an insert, and this node
is the
-* closest node to the target; see the description of chkDatastore.
-*/
- public void store(SSKBlock block, boolean deep) throws
KeyCollisionException {
+ /** Store only to the cache, and not the store. Called by requests,
+* as only inserts cause data to be added to the store. */
+ public void storeShallow(SSKBlock block) throws KeyCollisionException {
+ store(block, false);
+ }
+
+ private void store(SSKBlock block, boolean deep) throws
KeyCollisionException {
try {
if(deep) {
sskDatastore.put(block, false);
@@ -2888,6 +2906,17 @@
}
/**
+* Store a da
[freenet-cvs] r9994 - trunk/freenet/src/freenet/node
Author: toad
Date: 2006-08-09 12:46:15 + (Wed, 09 Aug 2006)
New Revision: 9994
Modified:
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/SSKInsertHandler.java
trunk/freenet/src/freenet/node/Version.java
Log:
938: Decision on when to cache in the long term store was wrong.
What we should actually check is "Is this node closer to the key than any
connected node?"
What we were checking was "Did we reset the HTL? (i.e. are we closer than all
hops so far?)".
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===
--- trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-09 12:25:31 UTC
(rev 9993)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-09 12:46:15 UTC
(rev 9994)
@@ -349,7 +349,7 @@
if(!canCommit) return;
if(!prb.allReceived()) return;
CHKBlock block = new CHKBlock(prb.getBlock(), headers, key);
-node.store(block, resetNearestLoc);
+node.store(block);
Logger.minor(this, "Committed");
} catch (CHKVerifyException e) {
Logger.error(this, "Verify failed in InsertHandler: "+e+" -
headers: "+HexUtil.bytesToHex(headers), e);
Modified: trunk/freenet/src/freenet/node/Node.java
===
--- trunk/freenet/src/freenet/node/Node.java2006-08-09 12:25:31 UTC (rev
9993)
+++ trunk/freenet/src/freenet/node/Node.java2006-08-09 12:46:15 UTC (rev
9994)
@@ -2168,7 +2168,7 @@
}
long startTime = System.currentTimeMillis();
if(cache) {
- store(block, false);
+ store(block);
}
is = makeInsertSender((NodeCHK)block.getKey(),
MAX_HTL, uid, null, headers, prb, false,
lm.getLocation().getValue(), cache);
@@ -2276,7 +2276,7 @@
if(cache) {
try {
if(cache)
- store(block, false);
+ storeInsert(block);
} catch (KeyCollisionException e) {
throw new
LowLevelPutException(LowLevelPutException.COLLISION);
}
@@ -2838,13 +2838,26 @@
"\nSSK Datacache:
"+sskDatacache.hits()+"/"+(sskDatacache.hits()+sskDatacache.misses())+"/"+sskDatacache.keyCount());
}
+ public void store(CHKBlock block) {
+ store(block, block.getKey().toNormalizedDouble());
+ }
+
/**
* Store a datum.
* @param deep If true, insert to the store as well as the cache. Do
not set
* this to true unless the store results from an insert, and this node
is the
* closest node to the target; see the description of chkDatastore.
*/
- public void store(CHKBlock block, boolean deep) {
+ public void store(CHKBlock block, double loc) {
+ boolean deep = !peers.isCloserLocation(loc);
+ store(block, deep);
+ }
+
+ public void storeShallow(CHKBlock block) {
+ store(block, false);
+ }
+
+ private void store(CHKBlock block, boolean deep) {
try {
if(deep) {
chkDatastore.put(block);
@@ -2861,14 +2874,19 @@
Logger.error(this, "Cannot store data: "+e, e);
}
}
+
+ /** Store the block if this is a sink. Call for inserts. */
+ public void storeInsert(SSKBlock block) throws KeyCollisionException {
+ store(block, block.getKey().toNormalizedDouble());
+ }
- /**
-* Store a datum.
-* @param deep If true, insert to the store as well as the cache. Do
not set
-* this to true unless the store results from an insert, and this node
is the
-* closest node to the target; see the description of chkDatastore.
-*/
- public void store(SSKBlock block, boolean deep) throws
KeyCollisionException {
+ /** Store only to the cache, and not the store. Called by requests,
+* as only inserts cause data to be added to the store. */
+ public void storeShallow(SSKBlock block) throws KeyCollisionException {
+ store(block, false);
+ }
+
+ private void store(SSKBlock block, boolean deep) throws
KeyCollisionException {
try {
if(deep) {
sskDatastore.put(block, false);
@@ -2888,6 +2906,17 @@
}
/**
+
