Author: mrogers
Date: 2006-11-23 11:46:02 +0000 (Thu, 23 Nov 2006)
New Revision: 11032
Modified:
trunk/apps/load-balancing-sims/phase7/sim/Node.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
Log:
Advisory backoff
Modified: trunk/apps/load-balancing-sims/phase7/sim/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-22 22:59:24 UTC
(rev 11031)
+++ trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-23 11:46:02 UTC
(rev 11032)
@@ -15,7 +15,7 @@
// Flow control
public final static boolean USE_TOKENS = false;
public final static boolean USE_BACKOFF = true;
- public final static boolean USE_THROTTLE = true;
+ public final static boolean USE_THROTTLE = false;
public final static int FLOW_TOKENS = 20; // Shared by all peers
public final static double TOKEN_DELAY = 1.0; // Allocate initial tokens
public final static double DELAY_DECAY = 0.99; // Exp moving average
Modified: trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
2006-11-22 22:59:24 UTC (rev 11031)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
2006-11-23 11:46:02 UTC (rev 11032)
@@ -92,8 +92,16 @@
}
// Find the closest remaining peer, if any
- private Peer closestPeer ()
+ private Peer closestPeer()
{
+ Peer p = closestPeer (Node.USE_BACKOFF);
+ // If all peers are backed off, try again ignoring backoff
+ if (p == null && Node.USE_BACKOFF) return closestPeer (false);
+ else return p;
+ }
+
+ private Peer closestPeer (boolean useBackoff)
+ {
double now = Event.time();
double keyLoc = Node.keyToLocation (key);
double closestDist = Double.POSITIVE_INFINITY;
@@ -103,7 +111,7 @@
node.log ("no tokens for " + peer);
continue;
}
- if (Node.USE_BACKOFF && now < peer.backoffUntil) {
+ if (useBackoff && now < peer.backoffUntil) {
node.log ("backed off from " + peer
+ " until " + peer.backoffUntil);
continue;