Author: mrogers
Date: 2006-11-25 21:05:20 +0000 (Sat, 25 Nov 2006)
New Revision: 11048
Modified:
trunk/apps/load-balancing-sims/phase7/sim/CongestionWindow.java
trunk/apps/load-balancing-sims/phase7/sim/Event.java
trunk/apps/load-balancing-sims/phase7/sim/LruCache.java
trunk/apps/load-balancing-sims/phase7/sim/LruMap.java
trunk/apps/load-balancing-sims/phase7/sim/Network.java
trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
trunk/apps/load-balancing-sims/phase7/sim/Node.java
trunk/apps/load-balancing-sims/phase7/sim/Peer.java
trunk/apps/load-balancing-sims/phase7/sim/SearchThrottle.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskRequestHandler.java
Log:
Logging changes: don't waste time building strings that won't be printed
Modified: trunk/apps/load-balancing-sims/phase7/sim/CongestionWindow.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/CongestionWindow.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/CongestionWindow.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -4,6 +4,8 @@
class CongestionWindow
{
+ public final static boolean LOG = false;
+
public final static int MIN_CWIND = Packet.MAX_SIZE; // Min window size
public final static int MAX_CWIND = 1000000; // Max window size
public final static double ALPHA = 0.3125; // AIMD increase parameter
@@ -22,10 +24,12 @@
public void reset()
{
- peer.log ("congestion window decreased to " + MIN_CWIND);
cwind = MIN_CWIND;
- peer.log ("returning to slow start");
slowStart = true;
+ if (LOG) {
+ peer.log ("congestion window decreased to " + cwind);
+ peer.log ("returning to slow start");
+ }
}
public int available()
@@ -37,31 +41,35 @@
public void bytesSent (int bytes)
{
inflight += bytes;
- peer.log (inflight + " bytes in flight");
+ if (LOG) peer.log (inflight + " bytes in flight");
}
// Take bytes out of flight
public void bytesAcked (int bytes)
{
inflight -= bytes;
- peer.log (inflight + " bytes in flight");
// Increase the window
if (slowStart) cwind += bytes / GAMMA;
else cwind += bytes * bytes * ALPHA / cwind;
if (cwind > MAX_CWIND) cwind = MAX_CWIND;
- peer.log ("congestion window increased to " + cwind);
+ if (LOG) {
+ peer.log (inflight + " bytes in flight");
+ peer.log ("congestion window increased to " + cwind);
+ }
}
// Decrease the window when a packet is fast retransmitted
public void fastRetransmission (double now)
{
- peer.log (inflight + " bytes in flight");
cwind *= BETA;
if (cwind < MIN_CWIND) cwind = MIN_CWIND;
- peer.log ("congestion window decreased to " + cwind);
+ if (LOG) {
+ peer.log (inflight + " bytes in flight");
+ peer.log ("congestion window decreased to " + cwind);
+ }
// The slow start phase ends when the first packet is lost
if (slowStart) {
- peer.log ("leaving slow start");
+ if (LOG) peer.log ("leaving slow start");
slowStart = false;
}
}
@@ -69,7 +77,7 @@
// Decrease the window when a packet is retransmitted due to a timeout
public void timeout (double now)
{
- peer.log (inflight + " bytes in flight");
+ if (LOG) peer.log (inflight + " bytes in flight");
if (slowStart) fastRetransmission (now); // Leave slow start
else reset(); // Reset the window and return to slow start
}
Modified: trunk/apps/load-balancing-sims/phase7/sim/Event.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Event.java 2006-11-25
00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/Event.java 2006-11-25
21:05:20 UTC (rev 11048)
@@ -9,8 +9,8 @@
private static double now = 0.0;
private static double lastLogTime = Double.POSITIVE_INFINITY;
private static int nextId = 0;
- public static double startLogging = 0.0;
public static double duration = Double.POSITIVE_INFINITY;
+ public static boolean blankLine = false; // Blank line between events?
public static void reset()
{
@@ -53,9 +53,8 @@
public static void log (String message)
{
- if (now < startLogging) return;
// Print a blank line between events
- if (now > lastLogTime) System.out.println();
+ if (blankLine && now > lastLogTime) System.out.println();
lastLogTime = now;
System.out.print (now + " " + message + "\n");
}
Modified: trunk/apps/load-balancing-sims/phase7/sim/LruCache.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/LruCache.java 2006-11-25
00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/LruCache.java 2006-11-25
21:05:20 UTC (rev 11048)
@@ -5,6 +5,8 @@
class LruCache<Key>
{
+ public final static boolean LOG = false;
+
public final int capacity;
private LinkedHashSet<Key> set;
@@ -16,7 +18,7 @@
public boolean get (Key key)
{
- log ("searching cache for key " + key);
+ if (LOG) log ("searching cache for key " + key);
if (set.remove (key)) {
set.add (key); // Move the key to the fresh end
return true;
@@ -26,14 +28,15 @@
public void put (Key key)
{
- if (set.remove (key))
- log ("key " + key + " already in cache");
+ if (set.remove (key)) {
+ if (LOG) log ("key " + key + " already in cache");
+ }
else {
- log ("adding key " + key + " to cache");
+ if (LOG) log ("adding key " + key + " to cache");
if (set.size() == capacity) {
// Discard the oldest element
Key oldest = set.iterator().next();
- log ("discarding key " + oldest);
+ if (LOG) log ("discarding key " + oldest);
set.remove (oldest);
}
}
@@ -42,6 +45,6 @@
private void log (String message)
{
- // Event.log (message);
+ Event.log (message);
}
}
Modified: trunk/apps/load-balancing-sims/phase7/sim/LruMap.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/LruMap.java 2006-11-25
00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/LruMap.java 2006-11-25
21:05:20 UTC (rev 11048)
@@ -6,6 +6,8 @@
class LruMap<Key,Value>
{
+ public final static boolean LOG = false;
+
public final int capacity;
private LinkedHashSet<Key> set;
private HashMap<Key,Value> map;
@@ -19,7 +21,7 @@
public Value get (Key key)
{
- log ("searching cache for key " + key);
+ if (LOG) log ("searching cache for key " + key);
Value value = map.get (key);
if (value != null) {
// Move the key to the fresh end
@@ -34,18 +36,18 @@
{
Value existing = map.get (key);
if (existing == null) {
- log ("adding key " + key + " to cache");
+ if (LOG) log ("adding key " + key + " to cache");
if (set.size() == capacity) {
// Discard the oldest element
Key oldest = set.iterator().next();
- log ("discarding key " + oldest);
+ if (LOG) log ("discarding key " + oldest);
set.remove (oldest);
}
map.put (key, value);
return value;
}
else {
- log ("key " + key + " already in cache");
+ if (LOG) log ("key " + key + " already in cache");
// Move the key to the fresh end
set.remove (key);
set.add (key);
@@ -55,6 +57,6 @@
private void log (String message)
{
- // Event.log (message);
+ Event.log (message);
}
}
Modified: trunk/apps/load-balancing-sims/phase7/sim/Network.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Network.java 2006-11-25
00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/Network.java 2006-11-25
21:05:20 UTC (rev 11048)
@@ -3,6 +3,8 @@
class Network
{
+ public final static boolean LOG = false;
+
private static HashMap<Integer,NetworkInterface> interfaces
= new HashMap<Integer,NetworkInterface>();
private static int nextAddress = 0;
@@ -18,7 +20,7 @@
// If the network allows reordering, randomise the latency a bit
if (reorder) p.latency *= (0.95 + Math.random() * 0.1);
if (Math.random() < lossRate) {
- Event.log (p + " lost by network");
+ if (LOG) Event.log (p + " lost by network");
return;
}
// Schedule the arrival of the packet at the destination
Modified: trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -5,6 +5,8 @@
class NetworkInterface implements EventTarget
{
+ public final static boolean LOG = false;
+
public final int address; // Represents an IP address and port
private Node node; // The owner of this network interface
private double txSpeed, rxSpeed; // Bytes per second
@@ -32,12 +34,12 @@
public void sendPacket (Packet p)
{
if (txQueueSize + p.size > txQueueMaxSize) {
- log ("no room in txQueue, " + p + " lost");
+ if (LOG) log ("no room in txQueue, " + p + " lost");
return;
}
txQueue.add (p);
txQueueSize += p.size;
- log (txQueueSize + " bytes in txQueue");
+ if (LOG) log (txQueueSize + " bytes in txQueue");
// If there are no other packets in the queue, start to transmit
if (txQueue.size() == 1) txStart (p);
}
@@ -48,12 +50,12 @@
private void rxQueueAdd (Packet p)
{
if (rxQueueSize + p.size > rxQueueMaxSize) {
- log ("no room in rxQueue, " + p + " lost");
+ if (LOG) log ("no room in rxQueue, " + p + " lost");
return;
}
rxQueue.add (p);
rxQueueSize += p.size;
- log (rxQueueSize + " bytes in rxQueue");
+ if (LOG) log (rxQueueSize + " bytes in rxQueue");
// If there are no other packets in the queue, start to receive
if (rxQueue.size() == 1) rxStart (p);
}
@@ -61,7 +63,7 @@
// Start receiving a packet
private void rxStart (Packet p)
{
- log ("starting to receive " + p);
+ if (LOG) log ("starting to receive " + p);
// Delay depends on rx speed
Event.schedule (this, p.size / rxSpeed, RX_END, p);
}
@@ -69,7 +71,7 @@
// Finish receiving a packet, pass it to the node
private void rxEnd (Packet p)
{
- log ("finished receiving " + p);
+ if (LOG) log ("finished receiving " + p);
node.handlePacket (p);
rxQueueSize -= p.size;
rxQueue.poll();
@@ -80,7 +82,7 @@
// Start transmitting a packet
private void txStart (Packet p)
{
- log ("starting to transmit " + p);
+ if (LOG) log ("starting to transmit " + p);
// Delay depends on tx speed
Event.schedule (this, p.size / txSpeed, TX_END, p);
}
@@ -88,7 +90,7 @@
// Finish transmitting a packet
private void txEnd (Packet p)
{
- log ("finished transmitting " + p);
+ if (LOG) log ("finished transmitting " + p);
Network.deliver (p);
txQueueSize -= p.size;
txQueue.poll();
@@ -98,7 +100,7 @@
private void log (String message)
{
- // Event.log (address + " " + message);
+ Event.log (address + " " + message);
}
// EventTarget interface
Modified: trunk/apps/load-balancing-sims/phase7/sim/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-25 00:17:11 UTC
(rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-25 21:05:20 UTC
(rev 11048)
@@ -9,6 +9,8 @@
public class Node implements EventTarget
{
+ public final static boolean LOG = false;
+
// Coarse-grained retransmission timer
public final static double RETX_TIMER = 0.1; // Seconds
@@ -75,7 +77,6 @@
{
if (n == this) return false;
if (peers.containsKey (n.net.address)) return false;
- // log ("adding peer " + n.net.address);
Peer p = new Peer (this, n.net.address, n.location, latency);
peers.put (n.net.address, p);
return true;
@@ -152,7 +153,7 @@
{
if (recentlySeenRequests.add (id)) return false;
- log ("rejecting recently seen search " + id);
+ if (LOG) log ("rejecting recently seen search " + id);
prev.sendMessage (new RejectedLoop (id));
if (useTokens) allocateToken (prev);
// Don't forward the same search back to prev
@@ -164,7 +165,7 @@
// Add a CHK to the cache
public void cacheChk (int key)
{
- log ("key " + key + " added to CHK cache");
+ if (LOG) log ("key " + key + " added to CHK cache");
chkCache.put (key);
}
@@ -172,10 +173,10 @@
public void storeChk (int key)
{
if (closerThanPeers (keyToLocation (key))) {
- log ("key " + key + " added to CHK store");
+ if (LOG) log ("key " + key + " added to CHK store");
chkStore.put (key);
}
- else log ("key " + key + " not added to CHK store");
+ else if (LOG) log ("key " + key + " not added to CHK store");
}
// Retrieve an SSK from the cache or the store
@@ -189,7 +190,7 @@
// Add an SSK to the cache
public void cacheSsk (int key, int value)
{
- log ("key " + key + " added to SSK cache");
+ if (LOG) log ("key " + key + " added to SSK cache");
sskCache.put (key, value);
}
@@ -197,16 +198,16 @@
public void storeSsk (int key, int value)
{
if (closerThanPeers (keyToLocation (key))) {
- log ("key " + key + " added to SSK store");
+ if (LOG) log ("key " + key + " added to SSK store");
sskStore.put (key, value);
}
- else log ("key " + key + " not added to SSK store");
+ else if (LOG) log ("key " + key + " not added to SSK store");
}
// Add a public key to the cache
public void cachePubKey (int key)
{
- log ("public key " + key + " added to cache");
+ if (LOG) log ("public key " + key + " added to cache");
pubKeyCache.put (key);
}
@@ -214,10 +215,10 @@
public void storePubKey (int key)
{
if (closerThanPeers (keyToLocation (key))) {
- log ("public key " + key + " added to store");
+ if (LOG) log ("public key " + key + " added to store");
pubKeyStore.put (key);
}
- else log ("public key " + key + " not added to store");
+ else if (LOG) log ("public key " + key + " not added to store");
}
// Called by Peer to start the retransmission timer
@@ -225,7 +226,7 @@
{
if (timerRunning) return;
timerRunning = true;
- // log ("starting retransmission timer");
+ if (LOG) log ("starting retransmission timer");
Event.schedule (this, RETX_TIMER, CHECK_TIMEOUTS, null);
}
@@ -238,12 +239,12 @@
if (p.messages != null) {
double now = Event.time();
for (Message m : p.messages) {
- log ("sending " + m + " to " + p.dest);
+ if (LOG) log ("sending " + m + " to " + p.dest);
double d = now - m.deadline;
delay *= DELAY_DECAY;
delay += d * (1.0 - DELAY_DECAY);
}
- log ("average message delay " + delay);
+ if (LOG) log ("average message delay " + delay);
}
// Send the packet
net.sendPacket (p);
@@ -262,14 +263,16 @@
public void handlePacket (Packet p)
{
Peer peer = peers.get (p.src);
- if (peer == null) log ("received packet from unknown peer");
+ if (peer == null) {
+ if (LOG) log ("received packet from unknown peer");
+ }
else peer.handlePacket (p);
}
// Called by Peer
public void handleMessage (Message m, Peer src)
{
- if (src != null) log ("received " + m + " from " + src);
+ if (src != null && LOG) log ("received " + m + " from " + src);
if (m instanceof Token)
handleToken ((Token) m, src);
else if (m instanceof ChkRequest)
@@ -282,7 +285,9 @@
handleSskInsert ((SskInsert) m, src);
else {
MessageHandler mh = messageHandlers.get (m.id);
- if (mh == null) log ("no message handler for " + m);
+ if (mh == null) {
+ if (LOG) log ("no message handler for " + m);
+ }
else mh.handleMessage (m, src);
}
}
@@ -300,12 +305,12 @@
if (rejectIfRecentlySeen (prev, r.id)) return;
// Accept the search
if (prev != null) {
- log ("accepting " + r);
+ if (LOG) log ("accepting " + r);
prev.sendMessage (new Accepted (r.id));
}
// If the data is in the store, return it
if (chkStore.get (r.key)) {
- log ("key " + r.key + " found in CHK store");
+ if (LOG) log ("key " + r.key + " found in CHK store");
if (prev == null) log (r + " succeeded locally");
else {
prev.sendMessage (new ChkDataFound (r.id));
@@ -315,10 +320,10 @@
if (useTokens) allocateToken (prev);
return;
}
- log ("key " + r.key + " not found in CHK store");
+ if (LOG) log ("key " + r.key + " not found in CHK store");
// If the data is in the cache, return it
if (chkCache.get (r.key)) {
- log ("key " + r.key + " found in CHK cache");
+ if (LOG) log ("key " + r.key + " found in CHK cache");
if (prev == null) log (r + " succeeded locally");
else {
prev.sendMessage (new ChkDataFound (r.id));
@@ -328,7 +333,7 @@
if (useTokens) allocateToken (prev);
return;
}
- log ("key " + r.key + " not found in CHK cache");
+ if (LOG) log ("key " + r.key + " not found in CHK cache");
// Store the request handler and forward the search
ChkRequestHandler rh = new ChkRequestHandler (r, this, prev);
messageHandlers.put (r.id, rh);
@@ -343,7 +348,7 @@
if (rejectIfRecentlySeen (prev, i.id)) return;
// Accept the search
if (prev != null) {
- log ("accepting " + i);
+ if (LOG) log ("accepting " + i);
prev.sendMessage (new Accepted (i.id));
}
// Store the insert handler and wait for a DataInsert
@@ -360,17 +365,19 @@
if (rejectIfRecentlySeen (prev, r.id)) return;
// Look up the public key
boolean pub = pubKeyStore.get (r.key) || pubKeyCache.get(r.key);
- if (pub) log ("public key " + r.key + " found in cache");
- else log ("public key " + r.key + " not found in cache");
+ if (LOG) {
+ if (pub) log ("public key " +r.key+ " found in cache");
+ else log ("public key " +r.key+ " not found in cache");
+ }
// Accept the search
if (prev != null) {
- log ("accepting " + r);
+ if (LOG) log ("accepting " + r);
prev.sendMessage (new Accepted (r.id));
}
// If the data is in the store, return it
Integer data = sskStore.get (r.key);
if (pub && data != null) {
- log ("key " + r.key + " found in SSK store");
+ if (LOG) log ("key " + r.key + " found in SSK store");
if (prev == null) log (r + " succeeded locally");
else {
prev.sendMessage (new SskDataFound (r.id,data));
@@ -381,11 +388,11 @@
if (useTokens) allocateToken (prev);
return;
}
- log ("key " + r.key + " not found in SSK store");
+ if (LOG) log ("key " + r.key + " not found in SSK store");
// If the data is in the cache, return it
data = sskCache.get (r.key);
if (pub && data != null) {
- log ("key " + r.key + " found in SSK cache");
+ if (LOG) log ("key " + r.key + " found in SSK cache");
if (prev == null) log (r + " succeeded locally");
else {
prev.sendMessage (new SskDataFound (r.id,data));
@@ -396,7 +403,7 @@
if (useTokens) allocateToken (prev);
return;
}
- log ("key " + r.key + " not found in SSK cache");
+ if (LOG) log ("key " + r.key + " not found in SSK cache");
// Store the request handler and forward the search
SskRequestHandler rh = new SskRequestHandler (r,this,prev,!pub);
messageHandlers.put (r.id, rh);
@@ -411,11 +418,13 @@
if (rejectIfRecentlySeen (prev, i.id)) return;
// Look up the public key
boolean pub = pubKeyStore.get (i.key) || pubKeyCache.get(i.key);
- if (pub) log ("public key " + i.key + " found in cache");
- else log ("public key " + i.key + " not found in cache");
+ if (LOG) {
+ if (pub) log ("public key " +i.key+ " found in cache");
+ else log ("public key " +i.key+ " not found in cache");
+ }
// Accept the search
if (prev != null) {
- log ("accepting " + i);
+ if (LOG) log ("accepting " + i);
prev.sendMessage (new SskAccepted (i.id, !pub));
}
// Store the insert handler and possibly wait for the pub key
@@ -437,9 +446,11 @@
public void removeMessageHandler (int id)
{
MessageHandler mh = messageHandlers.remove (id);
- if (mh == null) log ("no message handler to remove for " + id);
+ if (mh == null) {
+ if (LOG) log ("no message handler to remove for " + id);
+ }
else {
- log ("removing message handler for " + id);
+ if (LOG) log ("removing message handler for " + id);
if (useTokens) allocateToken (mh.prev);
}
}
@@ -450,7 +461,7 @@
if (p == null) {
if (spareTokens == 0) {
// The client will have to wait
- log ("not enough tokens");
+ if (LOG) log ("not enough tokens");
return false;
}
spareTokens--;
@@ -459,7 +470,7 @@
else {
if (p.tokensIn == 0) {
// This indicates a misbehaving sender
- log ("WARNING: not enough tokens");
+ if (LOG) log ("WARNING: not enough tokens");
return false;
}
p.tokensIn--;
@@ -494,14 +505,14 @@
private void addToSearchQueue (Search s)
{
searchQueue.add (s);
- log (searchQueue.size() + " searches in queue");
if (useThrottle) {
+ if (LOG) log (searchQueue.size() +" searches in queue");
if (searchQueue.size() > 1) return; // Already waiting
double now = Event.time();
double wait = searchThrottle.delay (now);
if (wait <= 0.0) sendSearch();
else {
- log ("throttled for " + wait + " seconds");
+ if (LOG) log ("throttled for "+wait+" seconds");
Event.schedule (this, wait, SEND_SEARCH, null);
}
}
@@ -531,7 +542,7 @@
searchThrottle.sent (now);
if (searchQueue.isEmpty()) return;
double wait = searchThrottle.delay (now);
- log ("throttled for " + wait + " seconds");
+ if (LOG) log ("throttled for " + wait + " seconds");
Event.schedule (this, wait, SEND_SEARCH, null);
}
}
@@ -539,28 +550,28 @@
public void generateChkRequest (int key)
{
ChkRequest cr = new ChkRequest (key, location);
- log ("generating " + cr);
+ if (LOG) log ("generating " + cr);
addToSearchQueue (cr);
}
public void generateChkInsert (int key)
{
ChkInsert ci = new ChkInsert (key, location);
- log ("generating " + ci);
+ if (LOG) log ("generating " + ci);
addToSearchQueue (ci);
}
public void generateSskRequest (int key)
{
SskRequest sr = new SskRequest (key, location, true);
- log ("generating " + sr);
+ if (LOG) log ("generating " + sr);
addToSearchQueue (sr);
}
public void generateSskInsert (int key, int value)
{
SskInsert si = new SskInsert (key, value, location);
- log ("generating " + si);
+ if (LOG) log ("generating " + si);
addToSearchQueue (si);
}
@@ -569,7 +580,7 @@
boolean stopTimer = true;
for (Peer p : peers()) if (p.checkTimeouts()) stopTimer = false;
if (stopTimer) {
- // log ("stopping retransmission timer");
+ if (LOG) log ("stopping retransmission timer");
timerRunning = false;
}
else Event.schedule (this, RETX_TIMER, CHECK_TIMEOUTS, null);
Modified: trunk/apps/load-balancing-sims/phase7/sim/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-25 00:17:11 UTC
(rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-25 21:05:20 UTC
(rev 11048)
@@ -6,6 +6,8 @@
public class Peer implements EventTarget
{
+ public final static boolean LOG = false;
+
private Node node; // The local node
public int address; // The remote node's address
public double location; // The remote node's routing location
@@ -71,11 +73,11 @@
{
m.deadline = Event.time() + MAX_DELAY;
if (m instanceof Block) {
- log (m + " added to transfer queue");
+ if (LOG) log (m + " added to transfer queue");
transferQueue.add (m);
}
else {
- log (m + " added to search queue");
+ if (LOG) log (m + " added to search queue");
searchQueue.add (m);
}
// Start the coalescing timer
@@ -87,7 +89,7 @@
// Queue an ack for transmission
private void sendAck (int seq)
{
- log ("ack " + seq + " added to ack queue");
+ if (LOG) log ("ack " + seq + " added to ack queue");
ackQueue.add (new Ack (seq, Event.time() + MAX_DELAY));
// Start the coalescing timer
startTimer();
@@ -100,7 +102,7 @@
{
if (timerRunning) return;
timerRunning = true;
- log ("starting coalescing timer");
+ if (LOG) log ("starting coalescing timer");
Event.schedule (this, MAX_DELAY, CHECK_DEADLINES, null);
}
@@ -108,7 +110,7 @@
private boolean send()
{
int waiting = ackQueue.size+searchQueue.size+transferQueue.size;
- log (waiting + " bytes waiting");
+ if (LOG) log (waiting + " bytes waiting");
if (waiting == 0) return false;
// Return to slow start when the link is idle
@@ -119,7 +121,7 @@
// How many bytes can we send?
int size = Math.min (Packet.MAX_SIZE, window.available());
size = Math.min (size, node.bandwidth.available());
- log (size + " bytes available for packet");
+ if (LOG) log (size + " bytes available for packet");
// Urgent acks to send?
if (ackQueue.deadline() <= now) return sendPacket (size);
@@ -129,11 +131,11 @@
// Urgent transfers and room to send them?
if (transferQueue.deadline() <= now
&& transferQueue.headSize() <= size) return sendPacket (size);
- // Enough non-urgent messages for a large packet?
+ // Enough non-urgent messages for a large packet, and room?
if (waiting >= Packet.SENSIBLE_PAYLOAD
&& size >= Packet.SENSIBLE_PAYLOAD) return sendPacket (size);
- log ("not sending a packet");
+ if (LOG) log ("not sending a packet");
return false;
}
@@ -144,7 +146,7 @@
Packet p = new Packet (node.net.address, address, latency);
// Add all waiting acks to the packet
while (ackQueue.size > 0) p.addAck (ackQueue.pop());
- log ((maxSize - p.size) + " bytes available for messages");
+ if (LOG) log ((maxSize - p.size) + " bytes for messages");
// Don't allow more than SEQ_RANGE payloads to be in flight
if (txSeq <= txMaxSeq) {
// Alternate priority between searches and transfers
@@ -158,14 +160,18 @@
p.addMessages (transferQueue, maxSize);
tgif = true;
}
- if (p.messages == null) log ("no messages added");
+ if (p.messages == null) {
+ if (LOG) log ("no messages added");
+ }
else p.seq = txSeq++;
}
- else log ("waiting for ack " + (txMaxSeq - SEQ_RANGE + 1));
+ else if (LOG) {
+ log ("waiting for ack " + (txMaxSeq - SEQ_RANGE + 1));
+ }
// Don't send empty packets
if (p.acks == null && p.messages == null) return false;
// Transmit the packet
- log ("sending packet " + p.seq + ", " + p.size + " bytes");
+ if (LOG) log ("sending packet " +p.seq+ ", " +p.size+ " bytes");
node.sendPacket (p);
// If the packet contains data, buffer it for retransmission
if (p.messages != null) {
@@ -186,22 +192,22 @@
private void handleData (Packet p)
{
- log ("received packet " + p.seq + ", expected " + rxSeq);
+ if (LOG) log ("received packet " +p.seq+ ", expected " +rxSeq);
if (p.seq < rxSeq || rxDupe.contains (p.seq)) {
- log ("duplicate packet");
+ if (LOG) log ("duplicate packet");
sendAck (p.seq); // Original ack may have been lost
}
else if (p.seq == rxSeq) {
// Find the sequence number of the next missing packet
while (rxDupe.remove (++rxSeq));
- log ("packet in order, now expecting " + rxSeq);
+ if (LOG) log ("packet in order, now expecting " +rxSeq);
// Deliver the messages to the node
for (Message m : p.messages)
node.handleMessage (m, this);
sendAck (p.seq);
}
else if (p.seq < rxSeq + SEQ_RANGE) {
- log ("packet out of order");
+ if (LOG) log ("packet out of order");
rxDupe.add (p.seq);
// Deliver the messages to the node
for (Message m : p.messages)
@@ -209,13 +215,13 @@
sendAck (p.seq);
}
// This indicates a misbehaving sender - discard the packet
- else log ("WARNING: sequence number out of range");
+ else if (LOG) log ("WARNING: sequence number out of range");
}
private void handleAck (Ack a)
{
int seq = a.id;
- log ("received ack " + seq);
+ if (LOG) log ("received ack " + seq);
double now = Event.time();
Iterator<Packet> i = txBuffer.iterator();
while (i.hasNext()) {
@@ -223,20 +229,22 @@
double age = now - p.sent;
// Explicit ack
if (p.seq == seq) {
- log ("packet " + p.seq + " acknowledged");
i.remove();
// Update the congestion window
window.bytesAcked (p.size);
// Update the average round-trip time
rtt = rtt * RTT_DECAY + age * (1.0 - RTT_DECAY);
- log ("round-trip time " + age);
- log ("average round-trip time " + rtt);
+ if (LOG) {
+ log ("packet " +p.seq+ " acknowledged");
+ log ("round-trip time " + age);
+ log ("average round-trip time " + rtt);
+ }
break;
}
// Fast retransmission
if (p.seq < seq && age > FRTO * rtt + MAX_DELAY) {
p.sent = now;
- log ("fast retransmitting packet " + p.seq);
+ if (LOG) log ("fast retransmitting " + p.seq);
node.resendPacket (p);
window.fastRetransmission (now);
}
@@ -244,7 +252,7 @@
// Recalculate the maximum sequence number
if (txBuffer.isEmpty()) txMaxSeq = txSeq + SEQ_RANGE - 1;
else txMaxSeq = txBuffer.peek().seq + SEQ_RANGE - 1;
- log ("maximum sequence number " + txMaxSeq);
+ if (LOG) log ("maximum sequence number " + txMaxSeq);
// Send as many packets a possible
if (timerRunning) while (send());
else checkDeadlines();
@@ -259,7 +267,7 @@
backoffLength *= BACKOFF_MULTIPLIER;
if (backoffLength > MAX_BACKOFF) backoffLength = MAX_BACKOFF;
backoffUntil = now + backoffLength * Math.random();
- log ("backing off until " + backoffUntil);
+ if (LOG) log ("backing off until " + backoffUntil);
}
// When a search is accepted, reset the backoff length unless backed off
@@ -268,20 +276,20 @@
if (!Node.useBackoff) return;
if (Event.time() < backoffUntil) return;
backoffLength = INITIAL_BACKOFF;
- log ("resetting backoff length");
+ if (LOG) log ("resetting backoff length");
}
// Check retx timeouts, return true if there are packets in flight
public boolean checkTimeouts()
{
- log (txBuffer.size() + " packets in flight");
+ if (LOG) log (txBuffer.size() + " packets in flight");
if (txBuffer.isEmpty()) return false;
double now = Event.time();
for (Packet p : txBuffer) {
if (now - p.sent > RTO * rtt + MAX_DELAY) {
// Retransmission timeout
- log ("retransmitting packet " + p.seq);
+ if (LOG) log ("retransmitting " + p.seq);
p.sent = now;
node.resendPacket (p);
window.timeout (now);
@@ -306,7 +314,7 @@
// If there's no deadline, stop the timer
if (dl == Double.POSITIVE_INFINITY) {
if (timerRunning) {
- log ("stopping coalescing timer");
+ if (LOG) log ("stopping coalescing timer");
timerRunning = false;
}
return;
@@ -316,7 +324,7 @@
if (shouldPoll()) sleep = Math.max (sleep, node.bandwidth.poll);
else sleep = Math.max (sleep, MIN_SLEEP);
timerRunning = true;
- log ("sleeping for " + sleep + " seconds");
+ if (LOG) log ("sleeping for " + sleep + " seconds");
Event.schedule (this, sleep, CHECK_DEADLINES, null);
}
@@ -343,7 +351,7 @@
public void log (String message)
{
- // Event.log (node.net.address + ":" + address + " " + message);
+ Event.log (node.net.address + ":" + address + " " + message);
}
public String toString()
Modified: trunk/apps/load-balancing-sims/phase7/sim/SearchThrottle.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/SearchThrottle.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/SearchThrottle.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -4,6 +4,8 @@
public class SearchThrottle
{
+ public final static boolean LOG = false;
+
public final static double INITIAL_RATE = 5.0; // Searches per second
public final static double MAX_RATE = 50.0;
public final static double MIN_RATE = 1.0 / 300.0;
@@ -17,14 +19,14 @@
{
rate += ALPHA;
if (rate > MAX_RATE) rate = MAX_RATE;
- Event.log ("rate increased to " + rate);
+ if (LOG) Event.log ("rate increased to " + rate);
}
public void decreaseRate()
{
rate *= BETA;
if (rate < MIN_RATE) rate = MIN_RATE;
- Event.log ("rate decreased to " + rate);
+ if (LOG) Event.log ("rate decreased to " + rate);
}
// Return the time remaining until the next search can be sent
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -32,7 +32,7 @@
handleDataInsert ((DataInsert) m);
else if (m instanceof Block)
handleBlock ((Block) m);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
else if (src == next) {
if (m instanceof Accepted)
@@ -47,19 +47,19 @@
handleInsertReply ((InsertReply) m);
else if (m instanceof TransfersCompleted)
handleCompleted ((TransfersCompleted) m, src);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
else if (receivers.contains (src)) {
if (m instanceof TransfersCompleted)
handleCompleted ((TransfersCompleted) m, src);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
- else node.log ("unexpected source for " + m);
+ else if (LOG) node.log ("unexpected source for " + m);
}
private void handleDataInsert (DataInsert di)
{
- if (inState != STARTED) node.log (di + " out of order");
+ if (inState != STARTED && LOG) node.log (di + " out of order");
inState = TRANSFERRING;
// Start the search
forwardSearch();
@@ -74,7 +74,8 @@
private void handleBlock (Block b)
{
- if (inState != TRANSFERRING) node.log (b + " out of order");
+ if (inState != TRANSFERRING && LOG)
+ node.log (b + " out of order");
if (blocks[b.index] != null) return; // Ignore duplicates
blocks[b.index] = b;
blocksReceived++;
@@ -95,7 +96,7 @@
private void handleAccepted (Accepted a)
{
- if (searchState != SENT) node.log (a + " out of order");
+ if (searchState != SENT && LOG) node.log (a + " out of order");
searchState = ACCEPTED;
next.successNotOverload(); // Reset the backoff length
// Wait 120 seconds for a reply to the search
@@ -112,7 +113,8 @@
private void handleInsertReply (InsertReply ir)
{
- if (searchState != ACCEPTED) node.log (ir + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (ir + " out of order");
if (prev == null) {
node.log (this + " succeeded");
node.increaseSearchRate();
@@ -154,7 +156,9 @@
inState = COMPLETED;
node.cacheChk (key);
node.storeChk (key);
- if (prev == null) node.log (this + " completed");
+ if (prev == null) {
+ if (LOG) node.log (this + " completed");
+ }
else prev.sendMessage (new TransfersCompleted (id));
node.removeMessageHandler (id);
}
@@ -174,7 +178,7 @@
private void dataTimeout()
{
if (inState != STARTED) return;
- node.log (this + " data timeout from " + prev);
+ if (LOG) node.log (this + " data timeout from " + prev);
prev.sendMessage (new TransfersCompleted(id));
reallyFinish();
}
@@ -183,7 +187,7 @@
private void transferInTimeout()
{
if (inState != TRANSFERRING) return;
- node.log (this + " transfer timeout from " + prev);
+ if (LOG) node.log (this + " transfer timeout from " + prev);
prev.sendMessage (new TransfersCompleted(id));
reallyFinish();
}
@@ -192,7 +196,7 @@
private void transferOutTimeout (Peer p)
{
if (!receivers.remove (p)) return;
- node.log (this + " transfer timeout to " + p);
+ if (LOG) node.log (this + " transfer timeout to " + p);
// FIXME: should we back off?
considerFinishing();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -17,8 +17,9 @@
public void handleMessage (Message m, Peer src)
{
- if (src != next)
- node.log ("unexpected source for " + m);
+ if (src != next) {
+ if (LOG) node.log ("unexpected source for " + m);
+ }
else if (m instanceof Accepted)
handleAccepted ((Accepted) m);
else if (m instanceof RejectedLoop)
@@ -33,12 +34,13 @@
handleChkDataFound ((ChkDataFound) m);
else if (m instanceof Block)
handleBlock ((Block) m);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
private void handleChkDataFound (ChkDataFound df)
{
- if (searchState != ACCEPTED) node.log (df + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (df + " out of order");
searchState = TRANSFERRING;
if (prev != null) prev.sendMessage (df); // Forward the message
// If we have all the blocks and the headers, cache the data
@@ -56,13 +58,14 @@
private void handleBlock (Block b)
{
- if (searchState != TRANSFERRING) node.log (b + " out of order");
+ if (searchState != TRANSFERRING && LOG)
+ node.log (b + " out of order");
if (blocks[b.index]) return; // Ignore duplicates
blocks[b.index] = true;
blocksReceived++;
// Forward the block
if (prev != null) {
- node.log ("forwarding " + b);
+ if (LOG) node.log ("forwarding " + b);
prev.sendMessage (b);
}
// If we have all the blocks and the headers, cache the data
Modified: trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/MessageHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -7,6 +7,8 @@
public abstract class MessageHandler
{
+ public final static boolean LOG = false;
+
// State machine
protected final static int STARTED = 0;
protected final static int SENT = 1;
@@ -39,7 +41,7 @@
double target = Node.keyToLocation (key);
if (Node.distance (target, node.location)
< Node.distance (target, closest)) {
- node.log ("resetting htl of " + this); // FIXME
+ if (LOG) node.log ("resetting htl of " + this);
closest = node.location;
htl = Search.MAX_HTL;
}
@@ -57,7 +59,7 @@
next = null;
// If the search has run out of hops, reply and finish
if (htl == 0) {
- node.log (this + " has no hops remaining");
+ if (LOG) node.log (this + " has no hops remaining");
sendReply();
finish();
return;
@@ -65,7 +67,7 @@
// Find the closest remaining peer
next = closestPeer();
if (next == null) {
- node.log ("route not found for " + this);
+ if (LOG) node.log ("route not found for " + this);
if (prev == null) {
node.log (this + " failed (rnf)");
node.increaseSearchRate(); // Yes, increase
@@ -79,11 +81,11 @@
if (Node.distance (target, next.location)
>= Node.distance (target, closest))
htl = node.decrementHtl (htl);
- node.log (this + " has htl " + htl);
+ if (LOG) node.log (this + " has htl " + htl);
// Consume a token
if (Node.useTokens) next.tokensOut--;
// Forward the search
- node.log ("forwarding " + this + " to " + next.address);
+ if (LOG) node.log ("forwarding " +this+ " to " + next.address);
next.sendMessage (makeSearchMessage());
nexts.remove (next);
searchState = SENT;
@@ -97,7 +99,7 @@
Peer p = closestPeer (Node.useBackoff);
// If all peers are backed off, try again ignoring backoff
if (p == null && Node.useBackoff) {
- node.log ("considering backed off peers");
+ if (LOG) node.log ("considering backed off peers");
return closestPeer (false);
}
else return p;
@@ -111,11 +113,11 @@
Peer closestPeer = null;
for (Peer peer : nexts) {
if (Node.useTokens && peer.tokensOut == 0) {
- node.log ("no tokens for " + peer);
+ if (LOG) node.log ("no tokens for " + peer);
continue;
}
if (useBackoff && now < peer.backoffUntil) {
- node.log ("backed off from " + peer
+ if (LOG) node.log ("backed off from " + peer
+ " until " + peer.backoffUntil);
continue;
}
@@ -130,7 +132,7 @@
protected void handleRejectedLoop (RejectedLoop rl)
{
- if (searchState != SENT) node.log (rl + " out of order");
+ if (searchState != SENT && LOG) node.log (rl + " out of order");
next.successNotOverload(); // Reset the backoff length
forwardSearch();
}
@@ -149,7 +151,8 @@
protected void handleRouteNotFound (RouteNotFound rnf)
{
- if (searchState != ACCEPTED) node.log (rnf + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (rnf + " out of order");
// Use the remaining htl to try another peer
if (rnf.htl < htl) htl = rnf.htl;
forwardSearch();
@@ -160,7 +163,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != SENT) return;
- node.log (this + " accepted timeout for " + p);
+ if (LOG) node.log (this + " accepted timeout for " + p);
p.localRejectedOverload(); // Back off from p
// Tell the sender to slow down
if (prev == null) node.decreaseSearchRate();
@@ -174,7 +177,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != ACCEPTED) return;
- node.log (this + " search timeout for " + p);
+ if (LOG) node.log (this + " search timeout for " + p);
p.localRejectedOverload(); // Back off from p
// Tell the sender to slow down
if (prev == null) {
Modified: trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -19,7 +19,7 @@
protected void handleAccepted (Accepted a)
{
- if (searchState != SENT) node.log (a + " out of order");
+ if (searchState != SENT && LOG) node.log (a + " out of order");
searchState = ACCEPTED;
next.successNotOverload(); // Reset the backoff length
// Wait 60 seconds for a reply to the search
@@ -28,7 +28,8 @@
protected void handleDataNotFound (DataNotFound dnf)
{
- if (searchState != ACCEPTED) node.log (dnf + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (dnf + " out of order");
if (prev == null) node.log (this + " failed (dnf)");
else prev.sendMessage (dnf); // Forward the message
finish();
@@ -55,7 +56,7 @@
protected void transferTimeout (Peer p)
{
if (searchState != TRANSFERRING) return;
- node.log (this + " transfer timeout from " + p);
+ if (LOG) node.log (this + " transfer timeout from " + p);
if (prev == null) node.log (this + " failed (xfer)");
finish();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -35,8 +35,10 @@
{
Integer old = node.fetchSsk (key);
if (old != null && old.intValue() != data) {
- node.log (this + " collided");
- if (prev == null) node.log (this + " collided locally");
+ if (LOG) node.log (this + " collided");
+ if (prev == null) {
+ if (LOG) node.log (this + " collided locally");
+ }
else prev.sendMessage (new SskDataFound (id, old));
// Continue inserting the old data
data = old;
@@ -49,7 +51,7 @@
if (src == prev) {
if (m instanceof SskPubKey)
handleSskPubKey ((SskPubKey) m);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
else if (src == next) {
if (m instanceof SskAccepted)
@@ -64,14 +66,15 @@
handleCollision ((SskDataFound) m);
else if (m instanceof InsertReply)
handleInsertReply ((InsertReply) m);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
- else node.log ("unexpected source for " + m);
+ else if (LOG) node.log ("unexpected source for " + m);
}
private void handleSskPubKey (SskPubKey pk)
{
- if (searchState != STARTED) node.log (pk + " out of order");
+ if (searchState != STARTED && LOG)
+ node.log (pk + " out of order");
pubKey = pk;
checkCollision();
forwardSearch();
@@ -79,7 +82,7 @@
private void handleSskAccepted (SskAccepted sa)
{
- if (searchState != SENT) node.log (sa + " out of order");
+ if (searchState != SENT && LOG) node.log (sa + " out of order");
searchState = ACCEPTED;
next.successNotOverload(); // Reset the backoff length
// Wait 60 seconds for a reply to the search
@@ -90,15 +93,19 @@
private void handleCollision (SskDataFound sdf)
{
- if (searchState != ACCEPTED) node.log (sdf + " out of order");
- if (prev == null) node.log (this + " collided");
+ if (searchState != ACCEPTED && LOG)
+ node.log (sdf + " out of order");
+ if (prev == null) {
+ if (LOG) node.log (this + " collided");
+ }
else prev.sendMessage (sdf); // Forward the message
data = sdf.data; // Is this safe?
}
private void handleInsertReply (InsertReply ir)
{
- if (searchState != ACCEPTED) node.log (ir + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (ir + " out of order");
if (prev == null) {
node.log (this + " succeeded");
node.increaseSearchRate();
@@ -145,7 +152,7 @@
private void keyTimeout()
{
if (searchState != STARTED) return;
- node.log (this + " key timeout for " + prev);
+ if (LOG) node.log (this + " key timeout for " + prev);
finish();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskRequestHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/SskRequestHandler.java
2006-11-25 00:17:11 UTC (rev 11047)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/SskRequestHandler.java
2006-11-25 21:05:20 UTC (rev 11048)
@@ -20,8 +20,9 @@
public void handleMessage (Message m, Peer src)
{
- if (src != next)
- node.log ("unexpected source for " + m);
+ if (src != next) {
+ if (LOG) node.log ("unexpected source for " + m);
+ }
else if (m instanceof Accepted)
handleAccepted ((Accepted) m);
else if (m instanceof RejectedLoop)
@@ -36,12 +37,13 @@
handleSskDataFound ((SskDataFound) m);
else if (m instanceof SskPubKey)
handleSskPubKey ((SskPubKey) m);
- else node.log ("unexpected type for " + m);
+ else if (LOG) node.log ("unexpected type for " + m);
}
private void handleSskDataFound (SskDataFound df)
{
- if (searchState != ACCEPTED) node.log (df + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (df + " out of order");
dataFound = df;
if (pubKey == null) return; // Keep waiting
if (prev == null) {
@@ -59,7 +61,8 @@
private void handleSskPubKey (SskPubKey pk)
{
- if (searchState != ACCEPTED) node.log (pk + " out of order");
+ if (searchState != ACCEPTED && LOG)
+ node.log (pk + " out of order");
pubKey = pk;
if (dataFound == null) return; // Keep waiting
if (prev == null) {