Author: toad
Date: 2008-07-04 13:53:45 +0000 (Fri, 04 Jul 2008)
New Revision: 20990

Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
   
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java
   
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
   branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
   
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
Log:
Add ObjectContainer parameter to all the pending keys operations

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-07-04 13:53:29 UTC (rev 20989)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2008-07-04 13:53:45 UTC (rev 20990)
@@ -327,7 +327,7 @@
                                                block = node.fetchKey(key, 
dontCache);
                                        if(block == null) {
                                                if(!persistent) {
-                                                       
schedTransient.addPendingKey(key, getter);
+                                                       
schedTransient.addPendingKey(key, getter, null);
                                                } // If persistent, when it is 
registered (in a later job) the keys will be added first.
                                        } else {
                                                if(logMINOR)
@@ -436,14 +436,14 @@
                requestStarterQueueFiller.run(container, context);
        }

-       void addPendingKey(final ClientKey key, final SendableGet getter) {
+       void addPendingKey(final ClientKey key, final SendableGet getter, 
ObjectContainer container) {
                if(getter.persistent()) {
                        if(!databaseExecutor.onThread()) {
                                throw new IllegalStateException("Not on 
database thread!");
                        }
-                       schedCore.addPendingKey(key, getter);
+                       schedCore.addPendingKey(key, getter, container);
                } else
-                       schedTransient.addPendingKey(key, getter);
+                       schedTransient.addPendingKey(key, getter, container);
        }

        private synchronized ChosenRequest removeFirst(ObjectContainer 
container, boolean transientOnly, boolean notTransient) {
@@ -671,7 +671,7 @@
                        }
                }
                final Key key = block.getKey();
-               final SendableGet[] transientGets = 
schedTransient.removePendingKey(key);
+               final SendableGet[] transientGets = 
schedTransient.removePendingKey(key, null);
                if(transientGets != null && transientGets.length > 0) {
                        node.executor.execute(new Runnable() {
                                public void run() {
@@ -698,7 +698,7 @@

                        public void run(ObjectContainer container, 
ClientContext context) {
                                container.activate(key, 1);
-                               final SendableGet[] gets = 
schedCore.removePendingKey(key);
+                               final SendableGet[] gets = 
schedCore.removePendingKey(key, container);
                                if(gets == null) return;
                                if(persistentCooldownQueue != null) {
                                        for(int i=0;i<gets.length;i++) {
@@ -803,8 +803,8 @@
                        if(persistent)
                                container.activate(key, 5);
                        if(logMINOR) Logger.minor(this, "Restoring key: "+key);
-                       SendableGet[] gets = 
schedCore.getClientsForPendingKey(key);
-                       SendableGet[] transientGets = 
schedTransient.getClientsForPendingKey(key);
+                       SendableGet[] gets = 
schedCore.getClientsForPendingKey(key, container);
+                       SendableGet[] transientGets = 
schedTransient.getClientsForPendingKey(key, null);
                        if(gets == null && transientGets == null) {
                                // Not an error as this can happen due to race 
conditions etc.
                                if(logMINOR) Logger.minor(this, "Restoring key 
but no keys queued?? for "+key);
@@ -826,7 +826,7 @@

        public long countTransientQueuedRequests() {
                // Approximately... there might be some overlap in the two 
pendingKeys's...
-               return schedCore.countQueuedRequests() + 
schedTransient.countQueuedRequests();
+               return schedTransient.countQueuedRequests(null);
        }

        public KeysFetchingLocally fetchingKeys() {

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java  
    2008-07-04 13:53:29 UTC (rev 20989)
+++ 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java  
    2008-07-04 13:53:45 UTC (rev 20990)
@@ -74,7 +74,7 @@
         * Register a pending key to an already-registered request. This is 
necessary if we've
         * already registered a SendableGet, but we later add some more keys to 
it.
         */
-       void addPendingKey(ClientKey key, SendableGet getter) {
+       void addPendingKey(ClientKey key, SendableGet getter, ObjectContainer 
container) {
                logMINOR = Logger.shouldLog(Logger.MINOR, 
ClientRequestSchedulerBase.class);
                if(logMINOR)
                        Logger.minor(this, "Adding pending key "+key+" for 
"+getter);
@@ -175,7 +175,7 @@
                return dropped;
        }

-       public SendableGet[] removePendingKey(Key key) {
+       public SendableGet[] removePendingKey(Key key, ObjectContainer 
container) {
                Object o;
                final SendableGet[] gets;
                synchronized(pendingKeys) {
@@ -194,7 +194,7 @@
                return gets;
        }

-       public boolean anyWantKey(Key key) {
+       public boolean anyWantKey(Key key, ObjectContainer container) {
                synchronized(pendingKeys) {
                        return pendingKeys.get(key) != null;
                }
@@ -219,7 +219,7 @@
                return priority;
        }

-       public SendableGet[] getClientsForPendingKey(Key key) {
+       public SendableGet[] getClientsForPendingKey(Key key, ObjectContainer 
container) {
                Object o;
                synchronized(pendingKeys) {
                        o = pendingKeys.get(key);
@@ -234,7 +234,7 @@
                }
        }

-       protected boolean inPendingKeys(SendableRequest req, Key key) {
+       protected boolean inPendingKeys(SendableRequest req, Key key, 
ObjectContainer container) {
                Object o;
                synchronized(pendingKeys) {
                        o = pendingKeys.get(key);
@@ -251,7 +251,7 @@
                return false;
        }

-       public long countQueuedRequests() {
+       public long countQueuedRequests(ObjectContainer container) {
                if(pendingKeys != null)
                        return pendingKeys.size();
                else return 0;
@@ -392,7 +392,7 @@
                                        Logger.minor(this, "No key for "+tok+" 
for "+getter+" - already finished?");
                                        continue;
                        } else {
-                               addPendingKey(key, getter);
+                               addPendingKey(key, getter, container);
                        }
                }
        }

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2008-07-04 13:53:29 UTC (rev 20989)
+++ 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2008-07-04 13:53:45 UTC (rev 20990)
@@ -276,7 +276,7 @@
                                        Logger.minor(this, "Storing "+ret+" for 
"+req);
                                if((ctr++ & 15) == 0) {
                                        // This check is quite expensive, don't 
do it all the time.
-                                       if((req instanceof SendableGet) && 
!inPendingKeys(req, key)) {
+                                       if((req instanceof SendableGet) && 
!inPendingKeys(req, key, container)) {
                                                Logger.error(this, "Selected 
key not in pendingKeys: key "+key+" for "+req);
                                        }
                                }

Modified: 
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-07-04 13:53:29 UTC (rev 20989)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSegment.java 
2008-07-04 13:53:45 UTC (rev 20990)
@@ -567,7 +567,7 @@
                }
                if(cooldown) {
                        // Register to the next sub-segment before removing 
from the old one.
-                       sub.getScheduler(context).addPendingKey(key, sub);
+                       sub.getScheduler(context).addPendingKey(key, sub, 
container);
                        seg.unregisterKey(key.getNodeKey(), context, container);
                        if(logMINOR)
                                Logger.minor(this, "Adding to cooldown queue: 
"+key+" for "+this+" was on segment "+seg+" now registered to "+sub);

Modified: 
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java  
    2008-07-04 13:53:29 UTC (rev 20989)
+++ 
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java  
    2008-07-04 13:53:45 UTC (rev 20990)
@@ -459,7 +459,7 @@
                if(schedule) schedule(container, context, false, true); // 
Retrying so not in store
                else if(!dontSchedule)
                        // Already scheduled, however this key may not be 
registered.
-                       
getScheduler(context).addPendingKey(segment.getBlockKey(blockNo, container), 
this);
+                       
getScheduler(context).addPendingKey(segment.getBlockKey(blockNo, container), 
this, container);
        }

        public String toString() {


Reply via email to