Author: toad
Date: 2007-02-16 15:08:43 +0000 (Fri, 16 Feb 2007)
New Revision: 11813
Modified:
trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
trunk/freenet/src/freenet/node/SendableRequest.java
trunk/freenet/src/freenet/node/SimpleSendableInsert.java
trunk/freenet/src/freenet/support/RandomGrabArray.java
trunk/freenet/src/freenet/support/RandomGrabArrayItem.java
Log:
canRemove()
Some queued requests may want to stay on the queue.
Specifically, those which are actually a bunch of queued requests.
We will use this soon to queue Segment's directly so that the per-block objects
don't need to be in memory permanently.
Modified: trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2007-02-16 14:24:21 UTC (rev 11812)
+++ trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2007-02-16 15:08:43 UTC (rev 11813)
@@ -113,5 +113,9 @@
return !ctx.cacheLocalRequests;
}
+ public boolean canRemove() {
+ // Simple request, once it's sent, it's sent. May be requeued
at a different # retries.
+ return true;
+ }
}
Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2007-02-16 14:24:21 UTC (rev 11812)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2007-02-16 15:08:43 UTC (rev 11813)
@@ -329,4 +329,8 @@
}
}
+ public boolean canRemove() {
+ return true;
+ }
+
}
Modified: trunk/freenet/src/freenet/node/SendableRequest.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableRequest.java 2007-02-16 14:24:21 UTC
(rev 11812)
+++ trunk/freenet/src/freenet/node/SendableRequest.java 2007-02-16 15:08:43 UTC
(rev 11813)
@@ -23,5 +23,5 @@
/** Get the ClientRequest */
public ClientRequester getClientRequest();
-
+
}
Modified: trunk/freenet/src/freenet/node/SimpleSendableInsert.java
===================================================================
--- trunk/freenet/src/freenet/node/SimpleSendableInsert.java 2007-02-16
14:24:21 UTC (rev 11812)
+++ trunk/freenet/src/freenet/node/SimpleSendableInsert.java 2007-02-16
15:08:43 UTC (rev 11813)
@@ -73,4 +73,8 @@
return finished;
}
+ public boolean canRemove() {
+ return true;
+ }
+
}
Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java 2007-02-16
14:24:21 UTC (rev 11812)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java 2007-02-16
15:08:43 UTC (rev 11813)
@@ -50,6 +50,7 @@
if(index == 0) return null;
int i = rand.nextInt(index);
RandomGrabArrayItem ret = reqs[i];
+ if(!ret.canRemove()) return ret;
reqs[i] = reqs[--index];
reqs[index] = null;
if(ret != null)
Modified: trunk/freenet/src/freenet/support/RandomGrabArrayItem.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArrayItem.java 2007-02-16
14:24:21 UTC (rev 11812)
+++ trunk/freenet/src/freenet/support/RandomGrabArrayItem.java 2007-02-16
15:08:43 UTC (rev 11813)
@@ -5,4 +5,9 @@
/** If true, will be automatically removed from the RGA, and not
returned. */
public boolean isFinished();
+ /** Can this item be removed from the queue?
+ * Called immediately after finding a request to remove.
+ * If returns false, the item will remain in the queue and may be
chosen again. */
+ public boolean canRemove();
+
}