37 |
/** An HTTP server serving blocks from a Storm pool. |
/** An HTTP server serving blocks from a Storm pool. |
38 |
*/ |
*/ |
39 |
public class HTTPProxy implements Runnable { |
public class HTTPProxy implements Runnable { |
40 |
public static boolean dbg = true; |
public static boolean dbg = false; |
41 |
private static void p(String s) { System.out.println(s); } |
private static void p(String s) { System.out.println(s); } |
42 |
|
|
43 |
protected StormPool pool; |
protected StormPool pool; |
58 |
} |
} |
59 |
|
|
60 |
public void run() { |
public void run() { |
61 |
p("Starting server @ "+url+"."); |
if(dbg) p("Starting server @ "+url+"."); |
62 |
server.run(); |
server.run(); |
63 |
} |
} |
64 |
|
|
85 |
|
|
86 |
BlockId id = new BlockId(uri); |
BlockId id = new BlockId(uri); |
87 |
Block block = pool.get(id); |
Block block = pool.get(id); |
88 |
p("<"+port+"> Serve: "+id); |
if(dbg) p("<"+port+"> Serve: "+id); |
89 |
HTTPResponse resp = resf.makeResponse(200, "Ok"); |
HTTPResponse resp = resf.makeResponse(200, "Ok"); |
90 |
resp.setField("Content-Type", id.getContentType()); |
resp.setField("Content-Type", id.getContentType()); |
91 |
if(!rewrite || !id.getContentType().equals("text/html")) { |
if(!rewrite || !id.getContentType().equals("text/html")) { |
121 |
} |
} |
122 |
|
|
123 |
public static void main(String[] args) throws Exception { |
public static void main(String[] args) throws Exception { |
124 |
|
dbg = true; |
125 |
StormPool pool; |
StormPool pool; |
126 |
java.util.Set empty = java.util.Collections.EMPTY_SET; |
java.util.Set empty = java.util.Collections.EMPTY_SET; |
127 |
if(!args[0].equals("-gisp")) { |
if(!args[0].equals("-gisp")) { |