Author: toad
Date: 2008-07-29 00:31:26 +0000 (Tue, 29 Jul 2008)
New Revision: 21463
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
branches/db4o/freenet/src/freenet/client/async/OfferedKeysList.java
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
branches/db4o/freenet/src/freenet/node/SendableGet.java
branches/db4o/freenet/src/freenet/node/SendableRequest.java
branches/db4o/freenet/src/freenet/node/SimpleSendableInsert.java
Log:
Remove from allRequestsByClientRequest on unregistration, not just on
removeFirst().
Move isSSK() and getRequestScheduler() into SendableRequest.
Modified:
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-07-29 00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-07-29 00:31:26 UTC (rev 21463)
@@ -136,7 +136,7 @@
if(!forInserts) {
offeredKeys = new
OfferedKeysList[RequestStarter.NUMBER_OF_PRIORITY_CLASSES];
for(short
i=0;i<RequestStarter.NUMBER_OF_PRIORITY_CLASSES;i++)
- offeredKeys[i] = new OfferedKeysList(core,
random, i);
+ offeredKeys[i] = new OfferedKeysList(core,
random, i, forSSKs);
} else {
offeredKeys = null;
}
@@ -1192,6 +1192,13 @@
public boolean isInsertScheduler() {
return isInsertScheduler;
}
+
+ public void removeFromAllRequestsByClientRequest(ClientRequester
clientRequest, SendableRequest get) {
+ if(get.persistent())
+ schedCore.removeFromAllRequestsByClientRequest(get,
clientRequest);
+ else
+
schedTransient.removeFromAllRequestsByClientRequest(get, clientRequest);
+ }
}
Modified: branches/db4o/freenet/src/freenet/client/async/OfferedKeysList.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/OfferedKeysList.java
2008-07-29 00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/client/async/OfferedKeysList.java
2008-07-29 00:31:26 UTC (rev 21463)
@@ -40,14 +40,16 @@
private final RandomSource random;
private final short priorityClass;
private final NodeClientCore core;
+ private final boolean isSSK;
- OfferedKeysList(NodeClientCore core, RandomSource random, short
priorityClass) {
+ OfferedKeysList(NodeClientCore core, RandomSource random, short
priorityClass, boolean isSSK) {
super(false);
this.keys = new HashSet();
this.keysList = new Vector();
this.random = random;
this.priorityClass = priorityClass;
this.core = core;
+ this.isSSK = isSSK;
logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
@@ -179,4 +181,8 @@
return (Key) token;
}
+ public boolean isSSK() {
+ return isSSK;
+ }
+
}
Modified:
branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-07-29 00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/client/async/SingleBlockInserter.java
2008-07-29 00:31:26 UTC (rev 21463)
@@ -273,13 +273,8 @@
}
}
- private ClientRequestScheduler getScheduler(ClientContext context) {
- String uriType = uri.getKeyType();
- if(uriType.equals("CHK"))
- return context.getChkInsertScheduler();
- else if(uriType.equals("SSK") || uriType.equals("KSK"))
- return context.getSskInsertScheduler();
- else throw new IllegalArgumentException();
+ public boolean isSSK() {
+ return uri.getKeyType().toUpperCase().equals("SSK");
}
public FreenetURI getURI(ObjectContainer container, ClientContext
context) {
Modified: branches/db4o/freenet/src/freenet/node/SendableGet.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-07-29
00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-07-29
00:31:26 UTC (rev 21463)
@@ -21,9 +21,6 @@
*/
public abstract class SendableGet extends BaseSendableGet {
- /** Is this an SSK? */
- public abstract boolean isSSK();
-
/** Parent BaseClientGetter. Required for schedulers. */
public final ClientRequester parent;
Modified: branches/db4o/freenet/src/freenet/node/SendableRequest.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SendableRequest.java 2008-07-29
00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/node/SendableRequest.java 2008-07-29
00:31:26 UTC (rev 21463)
@@ -4,6 +4,7 @@
import freenet.client.async.ChosenRequest;
import freenet.client.async.ClientContext;
+import freenet.client.async.ClientRequestScheduler;
import freenet.client.async.ClientRequester;
import freenet.support.Logger;
import freenet.support.RandomGrabArray;
@@ -107,8 +108,23 @@
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Cannot unregister "+this+"
: not registered", new Exception("debug"));
}
+ ClientRequester cr = getClientRequest();
+ container.activate(cr, 1);
+ getScheduler(context).removeFromAllRequestsByClientRequest(cr,
this);
+ // FIXME should we deactivate??
+ //container.deactivate(cr, 1);
}
+ public ClientRequestScheduler getScheduler(ClientContext context) {
+ if(isSSK())
+ return context.getSskInsertScheduler();
+ else
+ return context.getChkInsertScheduler();
+ }
+
+ /** Is this an SSK? For purposes of determining which scheduler to use.
*/
+ public abstract boolean isSSK();
+
/** Requeue after an internal error */
public abstract void internalError(Object keyNum, Throwable t,
RequestScheduler sched, ObjectContainer container, ClientContext context,
boolean persistent);
Modified: branches/db4o/freenet/src/freenet/node/SimpleSendableInsert.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SimpleSendableInsert.java
2008-07-29 00:17:06 UTC (rev 21462)
+++ branches/db4o/freenet/src/freenet/node/SimpleSendableInsert.java
2008-07-29 00:31:26 UTC (rev 21463)
@@ -142,4 +142,8 @@
if(finished) return null;
else return new Integer(0);
}
+
+ public boolean isSSK() {
+ return block instanceof SSKBlock;
+ }
}