Author: toad
Date: 2008-02-22 21:47:40 +0000 (Fri, 22 Feb 2008)
New Revision: 18110

Modified:
   trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
   trunk/freenet/src/freenet/client/async/OfferedKeysList.java
   trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
   trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
   trunk/freenet/src/freenet/node/SendableRequest.java
   trunk/freenet/src/freenet/node/SimpleSendableInsert.java
Log:
Add sendableKeys(). Use it in registration so we don't end up sending a 
non-sendable request.

Modified: trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-02-22 21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java   
2008-02-22 21:47:40 UTC (rev 18110)
@@ -38,6 +38,10 @@
                return keys;
        }

+       public Object[] sendableKeys() {
+               return keys;
+       }
+       
        public Object chooseKey() {
                return keys[0];
        }

Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-02-22 21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-02-22 21:47:40 UTC (rev 18110)
@@ -214,7 +214,7 @@
                        SendableGet getter = (SendableGet)req;
                        if(!getter.ignoreStore()) {
                                boolean anyValid = false;
-                               Object[] keyTokens = getter.allKeys();
+                               Object[] keyTokens = getter.sendableKeys();
                                for(int i=0;i<keyTokens.length;i++) {
                                        Object tok = keyTokens[i];
                                        ClientKeyBlock block = null;

Modified: trunk/freenet/src/freenet/client/async/OfferedKeysList.java
===================================================================
--- trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2008-02-22 
21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2008-02-22 
21:47:40 UTC (rev 18110)
@@ -65,6 +65,11 @@
                throw new UnsupportedOperationException();
        }

+       public Object[] sendableKeys() {
+               // Not supported.
+               throw new UnsupportedOperationException();
+       }
+
        public Object chooseKey() {
                // Pick a random key
                if(keysList.isEmpty()) return null;

Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-02-22 21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-02-22 21:47:40 UTC (rev 18110)
@@ -346,13 +346,17 @@
                return true;
        }

-       public synchronized Object[] allKeys() {
+       public synchronized Object[] sendableKeys() {
                if(finished)
                        return new Object[] {};
                else
                        return new Object[] { new Integer(0) };
        }

+       public synchronized Object[] allKeys() {
+               return sendableKeys();
+       }
+
        public synchronized Object chooseKey() {
                if(finished) return null;
                else return new Integer(0);

Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2008-02-22 21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java      
2008-02-22 21:47:40 UTC (rev 18110)
@@ -91,6 +91,13 @@
                return segment.getKeyNumbersAtRetryLevel(retryCount);
        }

+       /**
+        * Just those keys which are eligible to be started now.
+        */
+       public Object[] sendableKeys() {
+               return blockNums.toArray();
+       }
+       
        private synchronized Object removeRandomBlockNum() {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(blockNums.isEmpty()) {

Modified: trunk/freenet/src/freenet/node/SendableRequest.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableRequest.java 2008-02-22 21:37:53 UTC 
(rev 18109)
+++ trunk/freenet/src/freenet/node/SendableRequest.java 2008-02-22 21:47:40 UTC 
(rev 18110)
@@ -27,7 +27,11 @@
        /** All key identifiers. Including those not currently eligible to be 
sent because 
         * they are on a cooldown queue, requests for them are in progress, 
etc. */
        public abstract Object[] allKeys();
-       
+
+       /** All key identifiers currently eligible to be sent. Does not include 
those 
+        * currently running, on the cooldown queue etc. */
+       public abstract Object[] sendableKeys();
+
        /** ONLY called by RequestStarter. Start the actual request using the 
NodeClientCore
         * provided, and the key and key number earlier got from chooseKey(). 
         * The request itself may have been removed from the overall queue 
already.

Modified: trunk/freenet/src/freenet/node/SimpleSendableInsert.java
===================================================================
--- trunk/freenet/src/freenet/node/SimpleSendableInsert.java    2008-02-22 
21:37:53 UTC (rev 18109)
+++ trunk/freenet/src/freenet/node/SimpleSendableInsert.java    2008-02-22 
21:47:40 UTC (rev 18110)
@@ -119,6 +119,11 @@
                return new Object[] { new Integer(0) };
        }

+       public synchronized Object[] sendableKeys() {
+               if(finished) return new Object[] {};
+               return new Object[] { new Integer(0) };
+       }
+
        public synchronized Object chooseKey() {
                if(finished) return null;
                else return new Integer(0);


Reply via email to