Author: toad
Date: 2008-02-23 15:53:59 +0000 (Sat, 23 Feb 2008)
New Revision: 18126
Modified:
trunk/freenet/src/freenet/node/AnnounceSender.java
trunk/freenet/src/freenet/node/CHKInsertSender.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/SSKInsertSender.java
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
Log:
Decrement HTL *at the beginning* of the sender loop.
So we can immediately succeed/fail.
I think some of the timeouts are caused by requests bouncing around too much at
the end... see following commits.
Modified: trunk/freenet/src/freenet/node/AnnounceSender.java
===================================================================
--- trunk/freenet/src/freenet/node/AnnounceSender.java 2008-02-23 14:29:27 UTC
(rev 18125)
+++ trunk/freenet/src/freenet/node/AnnounceSender.java 2008-02-23 15:53:59 UTC
(rev 18126)
@@ -94,15 +94,26 @@
HashSet nodesRoutedTo = new HashSet();
HashSet nodesNotIgnored = new HashSet();
+ PeerNode next = null;
while(true) {
if(logMINOR) Logger.minor(this, "htl="+htl);
+ /*
+ * If we haven't routed to any node yet, decrement according to
the source.
+ * If we have, decrement according to the node which just failed.
+ * Because:
+ * 1) If we always decrement according to source then we can be at
max or min HTL
+ * for a long time while we visit *every* peer node. This is BAD!
+ * 2) The node which just failed can be seen as the requestor for
our purposes.
+ */
+ // Decrement at this point so we can DNF immediately on reaching
HTL 0.
+ htl = node.decrementHTL(hasForwarded ? next : source, htl);
+
if(htl == 0) {
// No more nodes.
complete();
return;
}
- PeerNode next;
if(onlyNode == null) {
// Route it
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null, null);
@@ -122,8 +133,6 @@
if(logMINOR) Logger.minor(this, "Routing request to "+next);
nodesRoutedTo.add(next);
- htl = node.decrementHTL(hasForwarded ? next : source, htl);
-
long xferUID = sendTo(next);
if(xferUID == -1) continue;
Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertSender.java 2008-02-23 14:29:27 UTC
(rev 18125)
+++ trunk/freenet/src/freenet/node/CHKInsertSender.java 2008-02-23 15:53:59 UTC
(rev 18126)
@@ -269,11 +269,22 @@
HashSet nodesRoutedTo = new HashSet();
HashSet nodesNotIgnored = new HashSet();
+ PeerNode next = null;
while(true) {
if(receiveFailed) {
return; // don't need to set status as killed by
CHKInsertHandler
}
+ /*
+ * If we haven't routed to any node yet, decrement according to
the source.
+ * If we have, decrement according to the node which just failed.
+ * Because:
+ * 1) If we always decrement according to source then we can be at
max or min HTL
+ * for a long time while we visit *every* peer node. This is BAD!
+ * 2) The node which just failed can be seen as the requestor for
our purposes.
+ */
+ // Decrement at this point so we can DNF immediately on reaching
HTL 0.
+ htl = node.decrementHTL(sentRequest ? next : source, htl);
synchronized (this) {
if(htl == 0) {
// Send an InsertReply back
@@ -282,7 +293,6 @@
}
}
// Route it
- PeerNode next;
// Can backtrack, so only route to nodes closer than we are to
target.
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null, null);
@@ -296,7 +306,6 @@
nodesRoutedTo.add(next);
Message req;
- htl = node.decrementHTL(sentRequest ? next : source, htl);
req = DMT.createFNPInsertRequest(uid, htl, myKey);
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2008-02-23 14:29:27 UTC
(rev 18125)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2008-02-23 15:53:59 UTC
(rev 18126)
@@ -382,7 +382,19 @@
int rejectOverloads=0;
HashSet nodesRoutedTo = new HashSet();
HashSet nodesNotIgnored = new HashSet();
+ PeerNode next = null;
while(true) {
+ /*
+ * If we haven't routed to any node yet, decrement according to
the source.
+ * If we have, decrement according to the node which just failed.
+ * Because:
+ * 1) If we always decrement according to source then we can be at
max or min HTL
+ * for a long time while we visit *every* peer node. This is BAD!
+ * 2) The node which just failed can be seen as the requestor for
our purposes.
+ */
+ // Decrement at this point so we can DNF immediately on reaching
HTL 0.
+ htl = node.decrementHTL((hasForwarded ? next : source), htl);
+
if(logMINOR) Logger.minor(this, "htl="+htl);
if(htl == 0) {
// This used to be RNF, I dunno why
@@ -395,7 +407,6 @@
routeAttempts++;
// Route it
- PeerNode next;
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null, key);
if(next == null) {
@@ -410,8 +421,6 @@
if(logMINOR) Logger.minor(this, "Routing request to "+next);
nodesRoutedTo.add(next);
- htl = node.decrementHTL((hasForwarded ? next : source), htl);
-
Message req = createDataRequest();
// Not possible to get an accurate time for sending, guaranteed to
be not later than the time of receipt.
Modified: trunk/freenet/src/freenet/node/SSKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/SSKInsertSender.java 2008-02-23 14:29:27 UTC
(rev 18125)
+++ trunk/freenet/src/freenet/node/SSKInsertSender.java 2008-02-23 15:53:59 UTC
(rev 18126)
@@ -122,8 +122,18 @@
HashSet nodesRoutedTo = new HashSet();
HashSet nodesNotIgnored = new HashSet();
+ PeerNode next = null;
while(true) {
-
+ /*
+ * If we haven't routed to any node yet, decrement according to
the source.
+ * If we have, decrement according to the node which just failed.
+ * Because:
+ * 1) If we always decrement according to source then we can be at
max or min HTL
+ * for a long time while we visit *every* peer node. This is BAD!
+ * 2) The node which just failed can be seen as the requestor for
our purposes.
+ */
+ // Decrement at this point so we can DNF immediately on reaching
HTL 0.
+ htl = node.decrementHTL(sentRequest ? next : source, htl);
if(htl == 0) {
// Send an InsertReply back
finish(SUCCESS, null);
@@ -131,7 +141,6 @@
}
// Route it
- PeerNode next;
next = node.peers.closerPeer(source, nodesRoutedTo,
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null, null);
if(next == null) {
@@ -142,8 +151,6 @@
if(logMINOR) Logger.minor(this, "Routing insert to "+next);
nodesRoutedTo.add(next);
- htl = node.decrementHTL(sentRequest ? next : source, htl);
-
Message req = DMT.createFNPSSKInsertRequest(uid, htl, myKey,
headers, data, pubKeyHash);
// Wait for ack or reject... will come before even a locally
generated DataReply
Modified:
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-02-23 14:29:27 UTC (rev 18125)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-02-23 15:53:59 UTC (rev 18126)
@@ -34,12 +34,12 @@
*/
public class RealNodeRequestInsertTest extends RealNodeRoutingTest {
- static final int NUMBER_OF_NODES = 50;
- static final int DEGREE = 5;
+ static final int NUMBER_OF_NODES = 100;
+ static final int DEGREE = 10;
static final short MAX_HTL = (short)10;
- static final boolean START_WITH_IDEAL_LOCATIONS = false;
+ static final boolean START_WITH_IDEAL_LOCATIONS = true;
static final boolean FORCE_NEIGHBOUR_CONNECTIONS = true;
- static final boolean ENABLE_SWAPPING = true;
+ static final boolean ENABLE_SWAPPING = false;
static final boolean ENABLE_ULPRS = false;
static final boolean ENABLE_PER_NODE_FAILURE_TABLES = false;
static final boolean ENABLE_SWAP_QUEUEING = false;
@@ -70,7 +70,7 @@
Executor executor = new PooledExecutor();
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5001+i, name, false, true, true,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
+ NodeStarter.createTestNode(5001+i, name, false, true, false,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}