Author: toad
Date: 2008-12-18 00:27:20 +0000 (Thu, 18 Dec 2008)
New Revision: 24497

Modified:
   branches/db4o/freenet/src/freenet/client/FetchContext.java
   branches/db4o/freenet/src/freenet/client/async/BlockSet.java
   branches/db4o/freenet/src/freenet/client/async/SimpleBlockSet.java
   branches/db4o/freenet/src/freenet/keys/CHKBlock.java
   branches/db4o/freenet/src/freenet/keys/KeyBlock.java
   branches/db4o/freenet/src/freenet/keys/SSKBlock.java
Log:
Storing a BlockSet is not supported atm.


Modified: branches/db4o/freenet/src/freenet/client/FetchContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FetchContext.java  2008-12-17 
23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/client/FetchContext.java  2008-12-18 
00:27:20 UTC (rev 24497)
@@ -46,7 +46,6 @@
        public final BlockSet blocks;
        public Set allowedMIMETypes;
        private final boolean hasOwnEventProducer;
-       private final boolean hasOwnBlocks;
        
        public FetchContext(long curMaxLength, 
                        long curMaxTempLength, int maxMetadataSize, int 
maxRecursionLevel, int maxArchiveRestarts, int maxArchiveLevels,
@@ -57,7 +56,6 @@
                        BucketFactory bucketFactory,
                        ClientEventProducer producer, boolean 
cacheLocalRequests, 
                        boolean ignoreTooManyPathComponents) {
-               hasOwnBlocks = false;
                this.blocks = null;
                this.maxOutputLength = curMaxLength;
                this.maxTempLength = curMaxTempLength;
@@ -80,6 +78,12 @@
                hasOwnEventProducer = true;
        }
 
+       /** Copy a FetchContext.
+        * @param ctx
+        * @param maskID
+        * @param keepProducer
+        * @param blocks Storing a BlockSet to the database is not supported, 
see comments on SimpleBlockSet.objectCanNew().
+        */
        public FetchContext(FetchContext ctx, int maskID, boolean keepProducer, 
BlockSet blocks) {
                if(keepProducer)
                        this.eventProducer = ctx.eventProducer;
@@ -87,7 +91,6 @@
                        this.eventProducer = new SimpleEventProducer();
                hasOwnEventProducer = !keepProducer;
                this.ignoreTooManyPathComponents = 
ctx.ignoreTooManyPathComponents;
-               hasOwnBlocks = blocks != null;
                if(blocks != null)
                        this.blocks = blocks;
                else
@@ -182,7 +185,7 @@
 
        public void removeFrom(ObjectContainer container) {
                if(hasOwnEventProducer) eventProducer.removeFrom(container);
-               if(hasOwnBlocks) blocks.removeFrom(container);
+               // Storing a BlockSet to the database is not supported, see 
comments on SimpleBlockSet.objectCanNew().
                container.delete(this);
        }
        

Modified: branches/db4o/freenet/src/freenet/client/async/BlockSet.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/BlockSet.java        
2008-12-17 23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/client/async/BlockSet.java        
2008-12-18 00:27:20 UTC (rev 24497)
@@ -41,6 +41,4 @@
        /** Get a high level block, given a high level key */
        public ClientKeyBlock get(ClientKey key);
 
-       public void removeFrom(ObjectContainer container);
-       
 }

Modified: branches/db4o/freenet/src/freenet/client/async/SimpleBlockSet.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleBlockSet.java  
2008-12-17 23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleBlockSet.java  
2008-12-18 00:27:20 UTC (rev 24497)
@@ -43,18 +43,23 @@
                        return null;
                }
        }
-
-       public void removeFrom(ObjectContainer container) {
-               Key[] keys;
-               KeyBlock[] blocks;
-               synchronized(this) {
-                       keys = (Key[]) blocksByKey.keySet().toArray(new 
Key[blocksByKey.size()]);
-                       blocks = (KeyBlock[]) blocksByKey.values().toArray(new 
KeyBlock[blocksByKey.size()]);
-               }
-               for(Key key : keys)
-                       key.removeFrom(container);
-               for(KeyBlock block : blocks)
-                       block.removeFrom(container);
+       
+       public boolean objectCanNew(ObjectContainer container) {
+               /* Storing a BlockSet is not supported. There are some 
complications, so lets
+                * not implement this until FCP supports it (currently we can't 
do fetch-from-blob,
+                * we can only do fetch-to-blob and insert-blob).
+                * 
+                * The major problems are:
+                * - In both CHKBlock and SSKBlock, who is responsible for 
deleting the node keys? We
+                *   have to have them in the objects.
+                * - In SSKBlock, who is responsible for deleting the 
DSAPublicKey? And the DSAGroup?
+                *   A group might be unique or might be shared between very 
many SSKs...
+                * 
+                * Especially in the second case, we don't want to just copy 
every time even for
+                * transient uses ... the best solution may be to copy in 
objectCanNew(), but even
+                * then callers to the relevant getter methods may be a worry.
+                */
+               throw new UnsupportedOperationException("Block set storage in 
database not supported");
        }
 
 }

Modified: branches/db4o/freenet/src/freenet/keys/CHKBlock.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/CHKBlock.java        2008-12-17 
23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/keys/CHKBlock.java        2008-12-18 
00:27:20 UTC (rev 24497)
@@ -116,8 +116,4 @@
                return getKey().getRoutingKey();
        }
 
-       public void removeFrom(ObjectContainer container) {
-               container.delete(this);
-               // FIXME who is responsible for deleting chk ??
-       }
 }

Modified: branches/db4o/freenet/src/freenet/keys/KeyBlock.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/KeyBlock.java        2008-12-17 
23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/keys/KeyBlock.java        2008-12-18 
00:27:20 UTC (rev 24497)
@@ -19,6 +19,5 @@
     public byte[] getRawHeaders();
     public byte[] getRawData();
        public byte[] getPubkeyBytes();
-       public void removeFrom(ObjectContainer container);
 
 }

Modified: branches/db4o/freenet/src/freenet/keys/SSKBlock.java
===================================================================
--- branches/db4o/freenet/src/freenet/keys/SSKBlock.java        2008-12-17 
23:56:49 UTC (rev 24496)
+++ branches/db4o/freenet/src/freenet/keys/SSKBlock.java        2008-12-18 
00:27:20 UTC (rev 24497)
@@ -179,11 +179,4 @@
                return getKey().getRoutingKey();
        }
 
-       public void removeFrom(ObjectContainer container) {
-               if(pubKey != null)
-                       pubKey.removeFrom(container);
-               container.delete(this);
-               // FIXME what to do about nodeKey???
-       }
-
 }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to