Author: robert
Date: 2008-01-11 03:28:42 +0000 (Fri, 11 Jan 2008)
New Revision: 17006

Modified:
   trunk/freenet/src/freenet/node/MessageItem.java
   trunk/freenet/src/freenet/node/PeerNode.java
   trunk/freenet/src/freenet/node/RequestSender.java
Log:
revert 16959, queue priorities is a MUCH better solution


Modified: trunk/freenet/src/freenet/node/MessageItem.java
===================================================================
--- trunk/freenet/src/freenet/node/MessageItem.java     2008-01-10 22:55:33 UTC 
(rev 17005)
+++ trunk/freenet/src/freenet/node/MessageItem.java     2008-01-11 03:28:42 UTC 
(rev 17006)
@@ -72,8 +72,4 @@
                        }
                }
        }
-       
-       public boolean isForMessage(Message msg) {
-               return this.msg.equals(msg);
-       }
 }

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-01-10 22:55:33 UTC 
(rev 17005)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-01-11 03:28:42 UTC 
(rev 17006)
@@ -16,7 +16,6 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedList;
-import java.util.ListIterator;
 import java.util.Vector;
 import java.util.zip.DataFormatException;
 import java.util.zip.Inflater;
@@ -969,21 +968,6 @@
                // It will wake up before the maximum coalescing delay (100ms) 
because
                // it wakes up every 100ms *anyway*.
        }
-       
-       private boolean maybeRemoveMessageFromQueue(Message removeMe) {
-               Logger.normal(this, "attempting to remove message from 
send-queue: "+removeMe);
-               synchronized (messagesToSendNow) {
-                       ListIterator i=messagesToSendNow.listIterator();
-                       while (i.hasNext()) {
-                               MessageItem it=(MessageItem)i.next();
-                               if (it.isForMessage(removeMe)) {
-                                       i.remove();
-                                       return true;
-                               }
-                       }
-               }
-               return false;
-       }

        public long getMessageQueueLengthBytes() {
                long x = 0;
@@ -1417,36 +1401,6 @@
                htl--;
                return htl;
        }
-
-       /**
-        * Conceptually, send a message to this node IF it can be done within 
'timeout', returing true
-        * only after the message was sent (similiar to sendSync), and false if 
the message cannot be
-        * sent to the node in that time period. As an optimization, however, 
this function may return
-        * immediately if it is determined that the message would not leave the 
node within the timeout
-        * period.
-        */
-       public boolean conditionalSend(Message req, ByteCounter ctr, long 
timeout) throws NotConnectedException {
-               if (timeout<=0)
-                       return false;
-               if (getProbableSendQueueTime() > timeout) {
-                       Logger.normal(this, "conditionalSend; pre-emptively not 
sending message ("+timeout+"ms): "+req);
-                       return false;
-               }
-               SyncMessageCallback cb = new SyncMessageCallback();
-               sendAsync(req, cb, 0, ctr);
-               cb.waitForSend(timeout);
-               if (cb.done) {
-                       return true;
-               } else {
-                       //best-effort: remove the message from the send queue 
it is ok if we can't prematurely
-                       //remove the item (i.e. race condition / now it is 
sent), but it will generate unclaimed messages, etc.
-                       if (!maybeRemoveMessageFromQueue(req))
-                               Logger.error(this, "unable to stop transmition 
of request: "+req);
-                       else
-                               Logger.normal(this, "removed request from queue 
for timeout: "+req);
-                       return false;
-               }
-       }

        /**
        * Enqueue a message to be sent to this node and wait up to a minute for 
it to be transmitted.

Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java   2008-01-10 22:55:33 UTC 
(rev 17005)
+++ trunk/freenet/src/freenet/node/RequestSender.java   2008-01-11 03:28:42 UTC 
(rev 17006)
@@ -4,7 +4,6 @@
 package freenet.node;

 import java.util.HashSet;
-import java.util.ArrayList;

 import freenet.crypt.CryptFormatException;
 import freenet.crypt.DSAPublicKey;
@@ -47,9 +46,6 @@
 public final class RequestSender implements Runnable, ByteCounter {

     // Constants
-       //SEND_TIMEOUT is not a hard timeout, MAX_SEND_TIMEOUT is.
-       static final int SEND_TIMEOUT = 1000;
-       static final int MAX_SEND_TIMEOUT = 5000;
     static final int ACCEPTED_TIMEOUT = 5000;
     static final int FETCH_TIMEOUT = 120000;
     /** Wait up to this long to get a path folding reply */
@@ -144,7 +140,6 @@
                int rejectOverloads=0;
         HashSet nodesRoutedTo = new HashSet();
         HashSet nodesNotIgnored = new HashSet();
-               ArrayList busyPeers = new ArrayList();
         while(true) {
             if(logMINOR) Logger.minor(this, "htl="+htl);
             if(htl == 0) {
@@ -157,18 +152,9 @@
                        routeAttempts++;

             // Route it
-                       long sendTimeout = SEND_TIMEOUT;
-                       boolean usingBusyPeer=false;
             PeerNode next;
             next = node.peers.closerPeer(source, nodesRoutedTo, 
nodesNotIgnored, target, true, node.isAdvancedModeEnabled(), -1, null);

-                       if (next == null && !busyPeers.isEmpty()) {
-                               next = (PeerNode)busyPeers.remove(0);
-                               usingBusyPeer=true;
-                               if (logMINOR) Logger.minor(this, "trying 
previously-found busy peer: "+next);
-                               sendTimeout = MAX_SEND_TIMEOUT;
-                       }
-                       
             if(next == null) {
                                if (logMINOR && rejectOverloads>0)
                                        Logger.minor(this, "no more peers, but 
overloads ("+rejectOverloads+"/"+routeAttempts+" overloaded)");
@@ -205,25 +191,10 @@
                                 *   make ACCEPTED_TIMEOUT much more likely,
                                 *   leave many hanging-requests/unclaimedFIFO 
items,
                                 *   potentially make overloaded peers MORE 
overloaded (we make a request and promptly forget about them).
-                                * using conditionalSend could:
-                                *   make ACCEPTED_TIMEOUT as accurate as 
sendSync (as it to waits for transmittion)
-                                *   reduce general latency around peers which 
have slow network links
-                                *   not needlessly overload nodes w/ forgotten 
requests (as conditonalSend will try and withdraw the request if it times out)
-                                *!!!make us skip peers which would otherwise 
have the data (they are closer, but slower)
-                                *
-                                * To avoid the pitfall of conditionalSend 
(potentially skipping a good peer), we will come back to them when it is
-                                * apparent that we cannot fill the request 
quickly. Using conditionalSend this way might actually approximate
-                                * Q-routing (for load balancing/latency) 
across the network; if SEND_TIMEOUT is too high... this reduces to
-                                * using sendSync w/ a good error catch, and if 
SEND_TIMEOUT is too low... this reduces to creating a cache-backbone
-                                * of fast links in the network which will 
always be queried before general nodes in the network are.
+                                * 
+                                * Don't use sendAsync().
                                 */
-               if (!next.conditionalSend(req, this, sendTimeout)) {
-                                       if (usingBusyPeer)
-                                               continue;
-                                       Logger.normal(this, "will try this peer 
later if no others are available");
-                                       busyPeers.add(next);
-                                       continue;
-                               }
+               next.sendSync(req, this);
             } catch (NotConnectedException e) {
                Logger.minor(this, "Not connected");
                continue;


Reply via email to