Author: toad
Date: 2007-05-03 16:53:18 +0000 (Thu, 03 May 2007)
New Revision: 13125

Added:
   trunk/freenet/src/freenet/support/RemoveRandomWithObject.java
   
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithContextObject.java
Removed:
   trunk/freenet/src/freenet/support/RemoveRandomWithClient.java
   trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithClient.java
Modified:
   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
   trunk/freenet/src/freenet/support/RandomGrabArrayWithClient.java
   trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
Log:
Prevent some confusion: WithClient -> WithObject.

Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2007-05-03 16:29:06 UTC (rev 13124)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2007-05-03 16:53:18 UTC (rev 13125)
@@ -24,7 +24,7 @@
 import freenet.node.SendableRequest;
 import freenet.support.Logger;
 import freenet.support.RandomGrabArray;
-import freenet.support.SectoredRandomGrabArrayWithClient;
+import freenet.support.SectoredRandomGrabArrayWithContextObject;
 import freenet.support.SectoredRandomGrabArrayWithInt;
 import freenet.support.SortedVectorByNumber;
 import freenet.support.api.StringCallback;
@@ -253,9 +253,9 @@
                        if(logMINOR) Logger.minor(this, "Registering retry 
count "+rc+" with prioclass "+priorityClass);
                }
                // Request
-               SectoredRandomGrabArrayWithClient requestGrabber = 
(SectoredRandomGrabArrayWithClient) clientGrabber.getGrabber(client);
+               SectoredRandomGrabArrayWithContextObject requestGrabber = 
(SectoredRandomGrabArrayWithContextObject) clientGrabber.getGrabber(client);
                if(requestGrabber == null) {
-                       requestGrabber = new 
SectoredRandomGrabArrayWithClient(client, random);
+                       requestGrabber = new 
SectoredRandomGrabArrayWithContextObject(client, random);
                        clientGrabber.addGrabber(client, requestGrabber);
                }
                requestGrabber.add(cr, req);

Modified: trunk/freenet/src/freenet/support/RandomGrabArrayWithClient.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArrayWithClient.java    
2007-05-03 16:29:06 UTC (rev 13124)
+++ trunk/freenet/src/freenet/support/RandomGrabArrayWithClient.java    
2007-05-03 16:53:18 UTC (rev 13125)
@@ -2,7 +2,7 @@

 import freenet.crypt.RandomSource;

-public class RandomGrabArrayWithClient extends RandomGrabArray implements 
RemoveRandomWithClient {
+public class RandomGrabArrayWithClient extends RandomGrabArray implements 
RemoveRandomWithObject {

        final Object client;

@@ -11,7 +11,7 @@
                this.client = client;
        }

-       public final Object getClient() {
+       public final Object getObject() {
                return client;
        }
 }

Deleted: trunk/freenet/src/freenet/support/RemoveRandomWithClient.java
===================================================================
--- trunk/freenet/src/freenet/support/RemoveRandomWithClient.java       
2007-05-03 16:29:06 UTC (rev 13124)
+++ trunk/freenet/src/freenet/support/RemoveRandomWithClient.java       
2007-05-03 16:53:18 UTC (rev 13125)
@@ -1,9 +0,0 @@
-package freenet.support;
-
-public interface RemoveRandomWithClient extends RemoveRandom {
-
-       public Object getClient();
-
-       public boolean isEmpty();
-       
-}

Added: trunk/freenet/src/freenet/support/RemoveRandomWithObject.java
===================================================================
--- trunk/freenet/src/freenet/support/RemoveRandomWithObject.java               
                (rev 0)
+++ trunk/freenet/src/freenet/support/RemoveRandomWithObject.java       
2007-05-03 16:53:18 UTC (rev 13125)
@@ -0,0 +1,9 @@
+package freenet.support;
+
+public interface RemoveRandomWithObject extends RemoveRandom {
+
+       public Object getObject();
+
+       public boolean isEmpty();
+       
+}

Modified: trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2007-05-03 16:29:06 UTC (rev 13124)
+++ trunk/freenet/src/freenet/support/SectoredRandomGrabArray.java      
2007-05-03 16:53:18 UTC (rev 13125)
@@ -11,13 +11,13 @@
 public class SectoredRandomGrabArray implements RemoveRandom {

        private final HashMap grabArraysByClient;
-       private RemoveRandomWithClient[] grabArrays;
+       private RemoveRandomWithObject[] grabArrays;
        private final RandomSource rand;

        public SectoredRandomGrabArray(RandomSource rand) {
                this.rand = rand;
                this.grabArraysByClient = new HashMap();
-               grabArrays = new RemoveRandomWithClient[0];
+               grabArrays = new RemoveRandomWithObject[0];
        }

        /**
@@ -29,7 +29,7 @@
                        if(logMINOR)
                                Logger.minor(this, "Adding new RGAWithClient 
for "+client+" on "+this+" for "+item);
                        rga = new RandomGrabArrayWithClient(client, rand);
-                       RemoveRandomWithClient[] newArrays = new 
RemoveRandomWithClient[grabArrays.length+1];
+                       RemoveRandomWithObject[] newArrays = new 
RemoveRandomWithObject[grabArrays.length+1];
                        System.arraycopy(grabArrays, 0, newArrays, 0, 
grabArrays.length);
                        newArrays[grabArrays.length] = rga;
                        grabArrays = newArrays;
@@ -46,17 +46,17 @@
         * Get a grabber. This lets us use things other than 
RandomGrabArrayWithClient's, so don't mix calls
         * to add() with calls to getGrabber/addGrabber!
         */
-       public synchronized RemoveRandomWithClient getGrabber(Object client) {
-               return (RemoveRandomWithClient) grabArraysByClient.get(client);
+       public synchronized RemoveRandomWithObject getGrabber(Object client) {
+               return (RemoveRandomWithObject) grabArraysByClient.get(client);
        }

        /**
         * Put a grabber. This lets us use things other than 
RandomGrabArrayWithClient's, so don't mix calls
         * to add() with calls to getGrabber/addGrabber!
         */
-       public synchronized void addGrabber(Object client, 
RemoveRandomWithClient requestGrabber) {
+       public synchronized void addGrabber(Object client, 
RemoveRandomWithObject requestGrabber) {
                grabArraysByClient.put(client, requestGrabber);
-               RemoveRandomWithClient[] newArrays = new 
RemoveRandomWithClient[grabArrays.length+1];
+               RemoveRandomWithObject[] newArrays = new 
RemoveRandomWithObject[grabArrays.length+1];
                System.arraycopy(grabArrays, 0, newArrays, 0, 
grabArrays.length);
                newArrays[grabArrays.length] = requestGrabber;
                grabArrays = newArrays;
@@ -67,9 +67,9 @@
                while(true) {
                        if(grabArrays.length == 0) return null;
                        int x = rand.nextInt(grabArrays.length);
-                       RemoveRandomWithClient rga = grabArrays[x];
+                       RemoveRandomWithObject rga = grabArrays[x];
                        if(logMINOR)
-                               Logger.minor(this, "Picked "+x+" of 
"+grabArrays.length+" : "+rga+" : "+rga.getClient());
+                               Logger.minor(this, "Picked "+x+" of 
"+grabArrays.length+" : "+rga+" : "+rga.getObject());
                        RandomGrabArrayItem item = rga.removeRandom();
                        if(logMINOR)
                                Logger.minor(this, "RGA has picked 
"+x+"/"+grabArrays.length+": "+item+
@@ -79,10 +79,10 @@
                        // other segements are cancelled. So just go around the 
loop in that case.
                        if(rga.isEmpty() || (item == null)) {
                                if(logMINOR)
-                                       Logger.minor(this, "Removing grab array 
"+x+" : "+rga+" for "+rga.getClient()+" (is empty)");
-                               Object client = rga.getClient();
+                                       Logger.minor(this, "Removing grab array 
"+x+" : "+rga+" for "+rga.getObject()+" (is empty)");
+                               Object client = rga.getObject();
                                grabArraysByClient.remove(client);
-                               RemoveRandomWithClient[] newArray = new 
RemoveRandomWithClient[grabArrays.length-1];
+                               RemoveRandomWithObject[] newArray = new 
RemoveRandomWithObject[grabArrays.length-1];
                                if(x > 0)
                                        System.arraycopy(grabArrays, 0, 
newArray, 0, x);
                                if(x < grabArrays.length-1)

Deleted: 
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithClient.java
===================================================================
--- trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithClient.java    
2007-05-03 16:29:06 UTC (rev 13124)
+++ trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithClient.java    
2007-05-03 16:53:18 UTC (rev 13125)
@@ -1,18 +0,0 @@
-package freenet.support;
-
-import freenet.crypt.RandomSource;
-
-public class SectoredRandomGrabArrayWithClient extends SectoredRandomGrabArray 
implements RemoveRandomWithClient {
-
-       private final Object client;
-       
-       public SectoredRandomGrabArrayWithClient(Object client, RandomSource 
rand) {
-               super(rand);
-               this.client = client;
-       }
-
-       public Object getClient() {
-               return client;
-       }
-       
-}

Copied: 
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithContextObject.java 
(from rev 13102, 
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithClient.java)
===================================================================
--- 
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithContextObject.java 
                            (rev 0)
+++ 
trunk/freenet/src/freenet/support/SectoredRandomGrabArrayWithContextObject.java 
    2007-05-03 16:53:18 UTC (rev 13125)
@@ -0,0 +1,18 @@
+package freenet.support;
+
+import freenet.crypt.RandomSource;
+
+public class SectoredRandomGrabArrayWithContextObject extends 
SectoredRandomGrabArray implements RemoveRandomWithObject {
+
+       private final Object object;
+       
+       public SectoredRandomGrabArrayWithContextObject(Object object, 
RandomSource rand) {
+               super(rand);
+               this.object = object;
+       }
+
+       public Object getObject() {
+               return object;
+       }
+       
+}


Reply via email to