gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] storm ./Makefile org/nongnu/storm/modules/gispm...


From: Benja Fallenstein
Subject: [Gzz-commits] storm ./Makefile org/nongnu/storm/modules/gispm...
Date: Fri, 09 May 2003 11:52:49 -0400

CVSROOT:        /cvsroot/storm
Module name:    storm
Changes by:     Benja Fallenstein <address@hidden>      03/05/09 11:52:47

Modified files:
        .              : Makefile 
        org/nongnu/storm/modules/gispmap: GispPeer.java 
        org/nongnu/storm/pointers: PointerId.java PointerIndex.java 
                                   SetPointer.java 
        org/nongnu/storm/util: HTTPProxy.java 

Log message:
        make accessible from httpproxy, some fixes (not fully functional yet)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/Makefile.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/modules/gispmap/GispPeer.java.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/PointerId.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/PointerIndex.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/SetPointer.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/util/HTTPProxy.java.diff?tr1=1.28&tr2=1.29&r1=text&r2=text

Patches:
Index: storm/Makefile
diff -u storm/Makefile:1.15 storm/Makefile:1.16
--- storm/Makefile:1.15 Mon Apr 28 05:10:10 2003
+++ storm/Makefile      Fri May  9 11:52:47 2003
@@ -39,6 +39,9 @@
 import:
        $(JAVA) $(DEBUG) $(PYTHONPATH) org.python.util.jython import.py $(POOL) 
$(CT) $(FILES)
 
+pointer:
+       $(JAVA) $(DEBUG) org.nongnu.storm.pointers.SetPointer $(KEYFILE) 
$(POOL) $(POINTER) $(TARGET)
+
 run-jython:
        $(JAVA) $(DEBUG) $(PYTHONPATH) org.python.util.jython
 
Index: storm/org/nongnu/storm/modules/gispmap/GispPeer.java
diff -u storm/org/nongnu/storm/modules/gispmap/GispPeer.java:1.6 
storm/org/nongnu/storm/modules/gispmap/GispPeer.java:1.7
--- storm/org/nongnu/storm/modules/gispmap/GispPeer.java:1.6    Thu May  8 
07:11:47 2003
+++ storm/org/nongnu/storm/modules/gispmap/GispPeer.java        Fri May  9 
11:52:47 2003
@@ -29,6 +29,7 @@
 import org.nongnu.storm.*;
 import org.nongnu.storm.impl.*;
 import org.nongnu.storm.impl.p2p.*;
+import org.nongnu.storm.pointers.PointerIndex;
 import org.nongnu.storm.util.HTTPProxy;
 import org.nongnu.storm.util.HtmlLinkIndex;
 
@@ -53,7 +54,9 @@
        IndexedPool publishedPool = null;
        int gisp_port = GispP2PMap.PORT;
        int gateway_port = -1;
-       Set indexTypes = Collections.singleton(HtmlLinkIndex.type);
+       Set indexTypes = new HashSet();
+       indexTypes.add(HtmlLinkIndex.type);
+       indexTypes.add(PointerIndex.type);
 
        int i=0;
        while(i<argv.length) {
Index: storm/org/nongnu/storm/pointers/PointerId.java
diff -u storm/org/nongnu/storm/pointers/PointerId.java:1.1 
storm/org/nongnu/storm/pointers/PointerId.java:1.2
--- storm/org/nongnu/storm/pointers/PointerId.java:1.1  Fri May  9 11:23:11 2003
+++ storm/org/nongnu/storm/pointers/PointerId.java      Fri May  9 11:52:47 2003
@@ -65,7 +65,7 @@
        int colon = uri.indexOf(':', PREFIX_LEN);
 
        if(!uri.startsWith(PREFIX))
-           throw new IllegalArgumentException("Storm URN must start "+PREFIX);
+           throw new IllegalArgumentException("Storm URN must start "+PREFIX+" 
[[ was "+uri+" ]]");
        if(colon < 0)
             throw new IllegalArgumentException("URN must contain random part");
            
Index: storm/org/nongnu/storm/pointers/PointerIndex.java
diff -u storm/org/nongnu/storm/pointers/PointerIndex.java:1.1 
storm/org/nongnu/storm/pointers/PointerIndex.java:1.2
--- storm/org/nongnu/storm/pointers/PointerIndex.java:1.1       Fri May  9 
11:23:11 2003
+++ storm/org/nongnu/storm/pointers/PointerIndex.java   Fri May  9 11:52:47 2003
@@ -33,6 +33,9 @@
 import java.security.*;
 
 public class PointerIndex {
+    public static boolean dbg = true;
+    private static void p(String s) { System.out.println("PointerIndex:: "+s); 
}
+
     public static final String uri =
        "http://fenfire.org/2003/05/pointer-index-0.1";;
 
@@ -43,11 +46,15 @@
 
     public BlockId get(PointerId id) 
        throws IOException, GeneralSecurityException {
+       if(dbg) p("Get: "+id);
+
        Collector c = db.get(id.toString()).block();
        long maxstamp = 0;
        BlockId result = null;
        for(Iterator i=c.iterator(); i.hasNext();) {
            IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();
+           if(dbg) p("Process: "+m.block+" "+m.value);
+
            long timestamp;
            try {
                timestamp = Long.parseLong(m.value);
@@ -97,7 +104,7 @@
        BlockOutputStream bos = pool.getBlockOutputStream("text/plain");
        String header = 
            PointerBlock.COOKIE + "\n" +
-           Base32.encode(signature);
+           Base32.encode(signature) + "\n";
        bos.write(header.getBytes("US-ASCII"));
        bos.write(data.getBytes("US-ASCII"));
        bos.close();
@@ -109,6 +116,7 @@
            try {
                p = new PointerBlock(block);
            } catch(Throwable _) {
+               if(dbg) _.printStackTrace();
                return Collections.EMPTY_SET;
            }
 
Index: storm/org/nongnu/storm/pointers/SetPointer.java
diff -u storm/org/nongnu/storm/pointers/SetPointer.java:1.1 
storm/org/nongnu/storm/pointers/SetPointer.java:1.2
--- storm/org/nongnu/storm/pointers/SetPointer.java:1.1 Fri May  9 11:23:11 2003
+++ storm/org/nongnu/storm/pointers/SetPointer.java     Fri May  9 11:52:47 2003
@@ -40,6 +40,8 @@
      *  If the key file doesn't exist, it's created.
      */
     public static void main(String[] argv) throws Exception {
+       System.out.println("Please wait, may need to initialize random number 
generator...");
+
        File keyFile = new File(argv[0]);
        KeyPair keys;
 
Index: storm/org/nongnu/storm/util/HTTPProxy.java
diff -u storm/org/nongnu/storm/util/HTTPProxy.java:1.28 
storm/org/nongnu/storm/util/HTTPProxy.java:1.29
--- storm/org/nongnu/storm/util/HTTPProxy.java:1.28     Fri May  9 06:54:56 2003
+++ storm/org/nongnu/storm/util/HTTPProxy.java  Fri May  9 11:52:47 2003
@@ -31,6 +31,7 @@
 import org.nongnu.storm.impl.p2p.*;
 import org.nongnu.storm.http.*;
 import org.nongnu.storm.http.server.*;
+import org.nongnu.storm.pointers.*;
 import java.io.*;
 import java.net.*;
 import java.util.Iterator;
@@ -116,7 +117,7 @@
 
                /* At this point, only the block URN is left of URL */
 
-               BlockId id = new BlockId(uri);
+               BlockId id = getBlockId(uri);
 
                if((!rewrite && !backlinks) || 
                   !id.getContentType().equals("text/html"))
@@ -229,7 +230,7 @@
        protected HTTPResponse serveBlock(String uri, 
                                          HTTPResponse.Factory resf) 
            throws Exception {
-               BlockId id = new BlockId(uri);
+               BlockId id = getBlockId(uri);
                Block block = pool.get(id);
                
                HTTPResponse resp = resf.makeResponse(200, "Ok");
@@ -317,6 +318,24 @@
        }
     }    
 
+    protected BlockId getBlockId(String uri) {
+       uri = uri.toLowerCase();
+       if(uri.startsWith("urn:x-storm:1.0:"))
+           return new BlockId(uri);
+       else if(uri.startsWith("urn:x-storm:pointer-0.1:")) {
+           PointerIndex idx = 
+               (PointerIndex)pool.getIndex(PointerIndex.uri);
+           try {
+               return idx.get(new PointerId(uri));
+           } catch(Exception _) {
+               _.printStackTrace();
+               throw new Error("Exception while getting key XXX");
+           }
+       } else {
+           throw new Error("Malformed Storm URN: "+uri);
+       }
+    }
+
     protected class Factory extends HTTPConnection.Factory {
         public HTTPConnection newConnection(Socket s) throws IOException {
             return new StormConnection(s);
@@ -326,8 +345,9 @@
     public static void main(String[] args) throws Exception {
        dbg = true;
        IndexedPool pool;
-       java.util.Set empty = java.util.Collections.EMPTY_SET;
-       pool = new DirPool(new File(args[0]), empty);
+       java.util.Set indexTypes = 
+           java.util.Collections.singleton(PointerIndex.type);
+       pool = new DirPool(new File(args[0]), indexTypes);
 
        new HTTPProxy(pool, 5555).run();
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]