[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/lava gzz/storm/IndexedPool.java gzz/storm/i...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/lava gzz/storm/IndexedPool.java gzz/storm/i... |
Date: |
Mon, 30 Dec 2002 08:48:23 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 02/12/30 08:48:23
Modified files:
lava/gzz/storm : IndexedPool.java
lava/gzz/storm/impl: AbstractLocalPool.java AbstractPool.java
DirPool.java TransientPool.java
ZipPool.java
lava/test/gzz/storm/impl: DirPool.test TransientPool.test
ZipPool.test
Log message:
Looks good
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/IndexedPool.java.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/AbstractLocalPool.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/AbstractPool.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/TransientPool.java.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/ZipPool.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/DirPool.test.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/TransientPool.test.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/storm/impl/ZipPool.test.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gzz/lava/gzz/storm/IndexedPool.java
diff -u gzz/lava/gzz/storm/IndexedPool.java:1.8
gzz/lava/gzz/storm/IndexedPool.java:1.9
--- gzz/lava/gzz/storm/IndexedPool.java:1.8 Mon Dec 30 08:26:42 2002
+++ gzz/lava/gzz/storm/IndexedPool.java Mon Dec 30 08:48:23 2002
@@ -52,6 +52,9 @@
interface DB {
/** Collect <code>IndexedPool.Mappings</code>s
* with the given key from this DB.
+ * The data may be requested from untrusted network sources,
+ * so code using this method must be robust
+ * in the face of corrupted data.
*/
Collector get(byte[] key);
}
Index: gzz/lava/gzz/storm/impl/AbstractLocalPool.java
diff -u gzz/lava/gzz/storm/impl/AbstractLocalPool.java:1.1
gzz/lava/gzz/storm/impl/AbstractLocalPool.java:1.2
--- gzz/lava/gzz/storm/impl/AbstractLocalPool.java:1.1 Sun Dec 22 22:20:59 2002
+++ gzz/lava/gzz/storm/impl/AbstractLocalPool.java Mon Dec 30 08:48:23 2002
@@ -2,6 +2,7 @@
package gzz.storm.impl;
import gzz.storm.*;
import java.io.*;
+import java.util.*;
/** An abstract implementation of a non-network <code>StormPool</code>.
* This provides default implementations of the
@@ -9,6 +10,10 @@
*/
public abstract class AbstractLocalPool extends AbstractPool {
+ public AbstractLocalPool(Set indexTypes) {
+ super(indexTypes);
+ }
+
public void request(BlockId id) {}
public void request(BlockId id, BlockListener listener) {
@@ -18,5 +23,10 @@
} catch(IOException e) {
listener.failure(id, e);
}
+ }
+
+ // XXX temporary, until subclasses have implementations
+ public DB getDB(String typeURI) {
+ return null;
}
}
Index: gzz/lava/gzz/storm/impl/AbstractPool.java
diff -u gzz/lava/gzz/storm/impl/AbstractPool.java:1.5
gzz/lava/gzz/storm/impl/AbstractPool.java:1.6
--- gzz/lava/gzz/storm/impl/AbstractPool.java:1.5 Sat Dec 28 21:01:41 2002
+++ gzz/lava/gzz/storm/impl/AbstractPool.java Mon Dec 30 08:48:23 2002
@@ -28,39 +28,43 @@
/** An abstract implementation of <code>IndexedPool</code>.
*/
-public abstract class AbstractPool implements StormPool {
+public abstract class AbstractPool implements IndexedPool {
- /***** IndexedPool stuff
- protected Set indexers;
+ protected Set indexTypes;
protected Map indices;
- protected AsyncMap indexCache;
- protected Map dbs;
- public AbstractPool(Set indexers, AsyncMap indexCache) {
- this.indexers = indexers;
- this.indexCache = indexCache;
+ /** Get a DB implementation associated with
+ * the given index type URI.
+ * The implementing pool has to make sure
+ * that this is updated when blocks are added
+ * or removed.
+ */
+ protected abstract DB getDB(String typeURI);
+ public AbstractPool(Set indexTypes) {
Map indices = new HashMap();
- this.indices = Collections.unmodifyableMap(indices);
- this.dbs = new HashSet();
- for(Iterator i=indexers.iterator(); i.hasNext();) {
- Indexer x = (Indexer)i.next();
+ for(Iterator i=indexTypes.iterator(); i.hasNext();) {
+ IndexType type = (IndexType)i.next();
- String uri = x.getIndexTypeURI();
- indices.put(uri, x.getIndex());
+ String uri = type.getIndexTypeURI();
+ indices.put(uri, type.createIndex(this, getDB(uri)));
}
+
+ this.indexTypes = indexTypes;
+ this.indices = Collections.unmodifiableMap(indices);
}
public Map getIndices() { return indices; }
- public Index getIndex(String indexTypeURI) {
- return (Index)getIndices().get(indexTypeURI);
+ public Object getIndex(String indexTypeURI) {
+ return getIndices().get(indexTypeURI);
+ }
public Pointer getPointer(String uri) {
- return
((PointerIndex)getIndex(Pointer.pointerIndexURI)).getPointer(uri);
+ Object index = getIndex(Pointer.pointerIndexURI);
+ return ((Pointer.PointerIndex)index).getPointer(uri);
}
- ************/
/**
* <code>block</code> must be set by <code>close()</code>.
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.15
gzz/lava/gzz/storm/impl/DirPool.java:1.16
--- gzz/lava/gzz/storm/impl/DirPool.java:1.15 Mon Dec 30 07:27:45 2002
+++ gzz/lava/gzz/storm/impl/DirPool.java Mon Dec 30 08:48:23 2002
@@ -104,7 +104,8 @@
* @throws IllegalArgumentException if the file isn't a directory
* or does not exist yet.
*/
- public DirPool(File dir) {
+ public DirPool(File dir, Set indexTypes) {
+ super(indexTypes);
this.dir = dir;
}
Index: gzz/lava/gzz/storm/impl/TransientPool.java
diff -u gzz/lava/gzz/storm/impl/TransientPool.java:1.20
gzz/lava/gzz/storm/impl/TransientPool.java:1.21
--- gzz/lava/gzz/storm/impl/TransientPool.java:1.20 Sun Dec 22 22:20:59 2002
+++ gzz/lava/gzz/storm/impl/TransientPool.java Mon Dec 30 08:48:23 2002
@@ -70,6 +70,10 @@
}
}
+ public TransientPool(Set indexTypes) {
+ super(indexTypes);
+ }
+
public Block get(BlockId id) throws FileNotFoundException {
if(!blocks.keySet().contains(id))
throw new FileNotFoundException("No such block: "+id);
Index: gzz/lava/gzz/storm/impl/ZipPool.java
diff -u gzz/lava/gzz/storm/impl/ZipPool.java:1.9
gzz/lava/gzz/storm/impl/ZipPool.java:1.10
--- gzz/lava/gzz/storm/impl/ZipPool.java:1.9 Mon Dec 30 07:27:45 2002
+++ gzz/lava/gzz/storm/impl/ZipPool.java Mon Dec 30 08:48:23 2002
@@ -56,8 +56,9 @@
}
}
- public ZipPool(ZipFile file){
- this.file = file;
+ public ZipPool(ZipFile file, Set indexTypes) {
+ super(indexTypes);
+ this.file = file;
}
public Block get(BlockId id) throws IOException {
Index: gzz/lava/test/gzz/storm/impl/DirPool.test
diff -u gzz/lava/test/gzz/storm/impl/DirPool.test:1.8
gzz/lava/test/gzz/storm/impl/DirPool.test:1.9
--- gzz/lava/test/gzz/storm/impl/DirPool.test:1.8 Mon Dec 30 07:27:45 2002
+++ gzz/lava/test/gzz/storm/impl/DirPool.test Mon Dec 30 08:48:23 2002
@@ -22,7 +22,7 @@
directory.mkdir();
s = gzz.storm.StormPoolTest()
-p = gzz.storm.impl.DirPool(directory)
+p = gzz.storm.impl.DirPool(directory, java.util.HashSet())
for name in dir(gzz.storm.StormPoolTest):
if name.startswith("test"):
Index: gzz/lava/test/gzz/storm/impl/TransientPool.test
diff -u gzz/lava/test/gzz/storm/impl/TransientPool.test:1.8
gzz/lava/test/gzz/storm/impl/TransientPool.test:1.9
--- gzz/lava/test/gzz/storm/impl/TransientPool.test:1.8 Mon Dec 30 07:27:45 2002
+++ gzz/lava/test/gzz/storm/impl/TransientPool.test Mon Dec 30 08:48:23 2002
@@ -19,7 +19,7 @@
import java, gzz
s = gzz.storm.StormPoolTest()
-p = gzz.storm.impl.TransientPool()
+p = gzz.storm.impl.TransientPool(java.util.HashSet())
for name in dir(gzz.storm.StormPoolTest):
if name.startswith("test"):
Index: gzz/lava/test/gzz/storm/impl/ZipPool.test
diff -u gzz/lava/test/gzz/storm/impl/ZipPool.test:1.5
gzz/lava/test/gzz/storm/impl/ZipPool.test:1.6
--- gzz/lava/test/gzz/storm/impl/ZipPool.test:1.5 Mon Dec 30 07:27:45 2002
+++ gzz/lava/test/gzz/storm/impl/ZipPool.test Mon Dec 30 08:48:23 2002
@@ -26,7 +26,7 @@
zipfile = java.util.zip.ZipFile(file)
s = gzz.storm.StormPoolTest()
-p = gzz.storm.impl.ZipPool(zipfile)
+p = gzz.storm.impl.ZipPool(zipfile, java.util.HashSet())
for name in dir(gzz.storm.StormPoolTest):
if name.startswith("test"):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/lava gzz/storm/IndexedPool.java gzz/storm/i...,
Benja Fallenstein <=