Author: toad
Date: 2008-06-14 13:51:33 +0000 (Sat, 14 Jun 2008)
New Revision: 20340

Modified:
   branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java
   branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java
   branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
   branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java
   branches/db4o/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
Log:
Remove defaultFetchContext/defaultInsertContext from FCPClient and pass in 
FCPServer to ClientGet etc constructors

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java   2008-06-14 
13:44:37 UTC (rev 20339)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientGet.java   2008-06-14 
13:51:33 UTC (rev 20340)
@@ -74,12 +74,12 @@
        public ClientGet(FCPClient globalClient, FreenetURI uri, boolean 
dsOnly, boolean ignoreDS,
                        int maxSplitfileRetries, int maxNonSplitfileRetries, 
long maxOutputLength,
                        short returnType, boolean persistRebootOnly, String 
identifier, int verbosity, short prioClass,
-                       File returnFilename, File returnTempFilename) throws 
IdentifierCollisionException, NotAllowedException {
+                       File returnFilename, File returnTempFilename, FCPServer 
server) throws IdentifierCollisionException, NotAllowedException {
                super(uri, identifier, verbosity, null, globalClient, prioClass,
                                (persistRebootOnly ? 
ClientRequest.PERSIST_REBOOT : ClientRequest.PERSIST_FOREVER),
                                null, true);

-               fctx = new FetchContext(client.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
                fctx.eventProducer.addEventListener(this);
                fctx.localRequestOnly = dsOnly;
                fctx.ignoreStore = ignoreDS;
@@ -133,12 +133,12 @@
                        }
        }

-       public ClientGet(FCPConnectionHandler handler, ClientGetMessage 
message) throws IdentifierCollisionException, MessageInvalidException {
+       public ClientGet(FCPConnectionHandler handler, ClientGetMessage 
message, FCPServer server) throws IdentifierCollisionException, 
MessageInvalidException {
                super(message.uri, message.identifier, message.verbosity, 
handler, message.priorityClass,
                                message.persistenceType, message.clientToken, 
message.global);
                // Create a Fetcher directly in order to get more fine-grained 
control,
                // since the client may override a few context elements.
-               fctx = new FetchContext(client.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
                fctx.eventProducer.addEventListener(this);
                // ignoreDS
                fctx.localRequestOnly = message.dsOnly;
@@ -214,7 +214,7 @@
         * supposedly serialized out by the node.
         * @throws IOException
         */
-       public ClientGet(SimpleFieldSet fs, FCPClient client2) throws 
IOException {
+       public ClientGet(SimpleFieldSet fs, FCPClient client2, FCPServer 
server) throws IOException {
                super(fs, client2);

                returnType = 
ClientGetMessage.parseValidReturnType(fs.get("ReturnType"));
@@ -231,7 +231,7 @@
                boolean ignoreDS = Fields.stringToBool(fs.get("IgnoreDS"), 
false);
                boolean dsOnly = Fields.stringToBool(fs.get("DSOnly"), false);
                int maxRetries = Integer.parseInt(fs.get("MaxRetries"));
-               fctx = new FetchContext(client.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
+               fctx = new FetchContext(server.defaultFetchContext, 
FetchContext.IDENTICAL_MASK, false);
                fctx.eventProducer.addEventListener(this);
                // ignoreDS
                fctx.localRequestOnly = dsOnly;

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java       
2008-06-14 13:44:37 UTC (rev 20339)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientPutBase.java       
2008-06-14 13:51:33 UTC (rev 20340)
@@ -56,10 +56,10 @@

        public ClientPutBase(FreenetURI uri, String identifier, int verbosity, 
FCPConnectionHandler handler, 
                        short priorityClass, short persistenceType, String 
clientToken, boolean global, boolean getCHKOnly,
-                       boolean dontCompress, int maxRetries, boolean 
earlyEncode) throws MalformedURLException {
+                       boolean dontCompress, int maxRetries, boolean 
earlyEncode, FCPServer server) throws MalformedURLException {
                super(uri, identifier, verbosity, handler, priorityClass, 
persistenceType, clientToken, global);
                this.getCHKOnly = getCHKOnly;
-               ctx = new InsertContext(client.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
+               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
                ctx.dontCompress = dontCompress;
                ctx.eventProducer.addEventListener(this);
                ctx.maxInsertRetries = maxRetries;
@@ -69,10 +69,10 @@

        public ClientPutBase(FreenetURI uri, String identifier, int verbosity, 
FCPConnectionHandler handler,
                        FCPClient client, short priorityClass, short 
persistenceType, String clientToken, boolean global,
-                       boolean getCHKOnly, boolean dontCompress, int 
maxRetries, boolean earlyEncode) throws MalformedURLException {
+                       boolean getCHKOnly, boolean dontCompress, int 
maxRetries, boolean earlyEncode, FCPServer server) throws MalformedURLException 
{
                super(uri, identifier, verbosity, handler, client, 
priorityClass, persistenceType, clientToken, global);
                this.getCHKOnly = getCHKOnly;
-               ctx = new InsertContext(client.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
+               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer(), persistenceType == ClientRequest.PERSIST_CONNECTION);
                ctx.dontCompress = dontCompress;
                ctx.eventProducer.addEventListener(this);
                ctx.maxInsertRetries = maxRetries;
@@ -80,7 +80,7 @@
                publicURI = getPublicURI(uri);
        }

-       public ClientPutBase(SimpleFieldSet fs, FCPClient client2) throws 
MalformedURLException {
+       public ClientPutBase(SimpleFieldSet fs, FCPClient client2, FCPServer 
server) throws MalformedURLException {
                super(fs, client2);
                publicURI = getPublicURI(uri);
                getCHKOnly = Fields.stringToBool(fs.get("CHKOnly"), false);
@@ -90,7 +90,7 @@
                finished = Fields.stringToBool(fs.get("Finished"), false);
                //finished = false;
                succeeded = Fields.stringToBool(fs.get("Succeeded"), false);
-               ctx = new InsertContext(client.defaultInsertContext, new 
SimpleEventProducer());
+               ctx = new InsertContext(server.defaultInsertContext, new 
SimpleEventProducer());
                ctx.dontCompress = dontCompress;
                ctx.eventProducer.addEventListener(this);
                ctx.maxInsertRetries = maxRetries;

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java        
2008-06-14 13:44:37 UTC (rev 20339)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java        
2008-06-14 13:51:33 UTC (rev 20340)
@@ -39,10 +39,10 @@
        private final boolean wasDiskPut;

        public ClientPutDir(FCPConnectionHandler handler, ClientPutDirMessage 
message, 
-                       HashMap manifestElements, boolean wasDiskPut) throws 
IdentifierCollisionException, MalformedURLException {
+                       HashMap manifestElements, boolean wasDiskPut, FCPServer 
server) throws IdentifierCollisionException, MalformedURLException {
                super(message.uri, message.identifier, message.verbosity, 
handler,
                                message.priorityClass, message.persistenceType, 
message.clientToken, message.global,
-                               message.getCHKOnly, message.dontCompress, 
message.maxRetries, message.earlyEncode);
+                               message.getCHKOnly, message.dontCompress, 
message.maxRetries, message.earlyEncode, server);
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                this.wasDiskPut = wasDiskPut;
                this.manifestElements = manifestElements;
@@ -68,8 +68,8 @@
        /**
        *       Puts a disk dir
        */
-       public ClientPutDir(FCPClient client, FreenetURI uri, String 
identifier, int verbosity, short priorityClass, short persistenceType, String 
clientToken, boolean getCHKOnly, boolean dontCompress, int maxRetries, File 
dir, String defaultName, boolean allowUnreadableFiles, boolean global, boolean 
earlyEncode) throws FileNotFoundException, IdentifierCollisionException, 
MalformedURLException {
-               super(uri, identifier, verbosity , null, client, priorityClass, 
persistenceType, clientToken, global, getCHKOnly, dontCompress, maxRetries, 
earlyEncode);
+       public ClientPutDir(FCPClient client, FreenetURI uri, String 
identifier, int verbosity, short priorityClass, short persistenceType, String 
clientToken, boolean getCHKOnly, boolean dontCompress, int maxRetries, File 
dir, String defaultName, boolean allowUnreadableFiles, boolean global, boolean 
earlyEncode, FCPServer server) throws FileNotFoundException, 
IdentifierCollisionException, MalformedURLException {
+               super(uri, identifier, verbosity , null, client, priorityClass, 
persistenceType, clientToken, global, getCHKOnly, dontCompress, maxRetries, 
earlyEncode, server);

                wasDiskPut = true;
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
@@ -142,8 +142,8 @@



-       public ClientPutDir(SimpleFieldSet fs, FCPClient client) throws 
PersistenceParseException, IOException {
-               super(fs, client);
+       public ClientPutDir(SimpleFieldSet fs, FCPClient client, FCPServer 
server) throws PersistenceParseException, IOException {
+               super(fs, client, server);
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                SimpleFieldSet files = fs.subset("Files");
                defaultName = fs.get("DefaultName");

Modified: branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java   2008-06-14 
13:44:37 UTC (rev 20339)
+++ branches/db4o/freenet/src/freenet/node/fcp/FCPClient.java   2008-06-14 
13:51:33 UTC (rev 20340)
@@ -6,9 +6,6 @@
 import java.util.LinkedList;
 import java.util.Vector;

-import freenet.client.FetchContext;
-import freenet.client.HighLevelSimpleClient;
-import freenet.client.InsertContext;
 import freenet.node.NodeClientCore;
 import freenet.node.RequestClient;
 import freenet.support.Logger;
@@ -28,12 +25,9 @@
                this.clientRequestsByIdentifier = new HashMap();
                this.server = server;
                this.core = server.core;
-               HighLevelSimpleClient client = core.makeClient((short)0);
                this.isGlobalQueue = isGlobalQueue;
                this.persistenceType = persistenceType;
                assert(persistenceType == ClientRequest.PERSIST_FOREVER || 
persistenceType == ClientRequest.PERSIST_REBOOT);
-               defaultFetchContext = client.getFetchContext();
-               defaultInsertContext = client.getInsertContext(false);
                watchGlobalVerbosityMask = Integer.MAX_VALUE;
                toStart = new LinkedList();
                lowLevelClientPersistent = new RequestClient() {
@@ -62,8 +56,6 @@
        /** ClientRequest's by identifier */
        private final HashMap clientRequestsByIdentifier;
        /** Client (one FCPClient = one HighLevelSimpleClient = one round-robin 
slot) */
-       public final FetchContext defaultFetchContext;
-       public final InsertContext defaultInsertContext;
        public final NodeClientCore core;
        /** Are we the global queue? */
        public final boolean isGlobalQueue;

Modified: branches/db4o/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/FCPConnectionHandler.java        
2008-06-14 13:44:37 UTC (rev 20339)
+++ branches/db4o/freenet/src/freenet/node/fcp/FCPConnectionHandler.java        
2008-06-14 13:51:33 UTC (rev 20340)
@@ -173,7 +173,7 @@
                                success = !requestsByIdentifier.containsKey(id);
                        if(success) {
                                try {
-                                       cg = new ClientGet(this, message);
+                                       cg = new ClientGet(this, message, 
server);
                                        if(!persistent)
                                                requestsByIdentifier.put(id, 
cg);
                                } catch (IdentifierCollisionException e) {
@@ -267,7 +267,7 @@
                }
                if(success) {
                        try {
-                               cp = new ClientPutDir(this, message, buckets, 
wasDiskPut);
+                               cp = new ClientPutDir(this, message, buckets, 
wasDiskPut, server);
                        } catch (IdentifierCollisionException e) {
                                success = false;
                        } catch (MalformedURLException e) {


Reply via email to