Adding some javascript thrift code, so Blur ajax calls can now be made.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/39c899d2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/39c899d2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/39c899d2 Branch: refs/heads/0.1.5 Commit: 39c899d29af1f675ffef4e3e8af81d0ab9b99908 Parents: 4266a40 Author: Aaron McCurry <[email protected]> Authored: Tue Apr 16 21:26:09 2013 -0400 Committer: Aaron McCurry <[email protected]> Committed: Tue Apr 16 21:26:09 2013 -0400 ---------------------------------------------------------------------- .../apache/blur/thrift/ThriftBlurShardServer.java | 37 +- .../java/org/apache/blur/gui/HttpJettyServer.java | 12 +- src/blur-gui/src/main/webapp/d3.v2.js | 7033 --------------- src/blur-gui/src/main/webapp/d3.v2.min.js | 4 - .../org/apache/blur/thrift/generated/Blur.java | 384 +- .../blur/thrift/generated/TableDescriptor.java | 203 +- .../src/main/scripts/interface/gen-js/Blur.js | 4602 ++++++++++ .../main/scripts/interface/gen-js/Blur_types.js | 3099 +++++++ .../src/main/scripts/interface/genAndReplace.sh | 2 +- 9 files changed, 7939 insertions(+), 7437 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/39c899d2/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java ---------------------------------------------------------------------- diff --git a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java index 1beb382..699c6bd 100644 --- a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java +++ b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurShardServer.java @@ -62,14 +62,18 @@ import org.apache.blur.store.blockcache.BlockDirectory; import org.apache.blur.store.blockcache.BlockDirectoryCache; import org.apache.blur.store.blockcache.Cache; import org.apache.blur.store.buffer.BufferStore; +import org.apache.blur.thrift.generated.Blur; import org.apache.blur.thrift.generated.Blur.Iface; import org.apache.blur.utils.BlurUtil; import org.apache.blur.zookeeper.ZkUtils; import org.apache.hadoop.conf.Configuration; +import org.apache.thrift.protocol.TJSONProtocol; +import org.apache.thrift.server.TServlet; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.Code; import org.apache.zookeeper.ZooKeeper; - +import org.mortbay.jetty.servlet.ServletHolder; +import org.mortbay.jetty.webapp.WebAppContext; public class ThriftBlurShardServer extends ThriftServer { @@ -95,11 +99,11 @@ public class ThriftBlurShardServer extends ThriftServer { slabCount = getSlabCount(slabCount, numberOfBlocksPerSlab, blockSize); Cache cache; Configuration config = new Configuration(); - + String bindAddress = configuration.get(BLUR_SHARD_BIND_ADDRESS); int bindPort = configuration.getInt(BLUR_SHARD_BIND_PORT, -1); bindPort += serverIndex; - + int baseGuiPort = Integer.parseInt(configuration.get(BLUR_GUI_SHARD_PORT)); final HttpJettyServer httpServer; if (baseGuiPort > 0) { @@ -108,25 +112,27 @@ public class ThriftBlurShardServer extends ThriftServer { // TODO: this got ugly, there has to be a better way to handle all these // params // without reversing the mvn dependancy and making blur-gui on top. - httpServer = new HttpJettyServer(bindPort, webServerPort, configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1), configuration.getInt(BLUR_SHARD_BIND_PORT, -1), - configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1), configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "shard"); + httpServer = new HttpJettyServer(bindPort, webServerPort, configuration.getInt(BLUR_CONTROLLER_BIND_PORT, -1), + configuration.getInt(BLUR_SHARD_BIND_PORT, -1), configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1), + configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "shard"); } else { httpServer = null; } - - + if (slabCount >= 1) { BlockCache blockCache; boolean directAllocation = configuration.getBoolean(BLUR_SHARD_BLOCKCACHE_DIRECT_MEMORY_ALLOCATION, true); int slabSize = numberOfBlocksPerSlab * blockSize; - LOG.info("Number of slabs of block cache [{0}] with direct memory allocation set to [{1}]", slabCount, directAllocation); - LOG.info("Block cache target memory usage, slab size of [{0}] will allocate [{1}] slabs and use ~[{2}] bytes", slabSize, slabCount, ((long) slabCount * (long) slabSize)); + LOG.info("Number of slabs of block cache [{0}] with direct memory allocation set to [{1}]", slabCount, + directAllocation); + LOG.info("Block cache target memory usage, slab size of [{0}] will allocate [{1}] slabs and use ~[{2}] bytes", + slabSize, slabCount, ((long) slabCount * (long) slabSize)); int _1024Size = configuration.getInt("blur.shard.buffercache.1024", 8192); int _8192Size = configuration.getInt("blur.shard.buffercache.8192", 8192); BufferStore.init(_1024Size, _8192Size); - + try { long totalMemory = (long) slabCount * (long) numberOfBlocksPerSlab * (long) blockSize; blockCache = new BlockCache(directAllocation, totalMemory, slabSize); @@ -143,7 +149,6 @@ public class ThriftBlurShardServer extends ThriftServer { cache = BlockDirectory.NO_CACHE; } - LOG.info("Shard Server using index [{0}] bind address [{1}]", serverIndex, bindAddress + ":" + bindPort); String nodeNameHostName = getNodeName(configuration, BLUR_SHARD_HOSTNAME); @@ -203,6 +208,8 @@ public class ThriftBlurShardServer extends ThriftServer { shardServer.init(); Iface iface = BlurUtil.recordMethodCallsAndAverageTimes(shardServer, Iface.class); + WebAppContext context = httpServer.getContext(); + context.addServlet(new ServletHolder(new TServlet(new Blur.Processor<Blur.Iface>(iface), new TJSONProtocol.Factory())), "/blur"); int threadCount = configuration.getInt(BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT, 32); @@ -214,20 +221,20 @@ public class ThriftBlurShardServer extends ThriftServer { server.setIface(iface); server.setConfiguration(configuration); - // This will shutdown the server when the correct path is set in zk BlurShutdown shutdown = new BlurShutdown() { @Override public void shutdown() { ThreadWatcher threadWatcher = ThreadWatcher.instance(); - quietClose(refresher, server, shardServer, indexManager, indexServer, threadWatcher, clusterStatus, zooKeeper, httpServer); + quietClose(refresher, server, shardServer, indexManager, indexServer, threadWatcher, clusterStatus, zooKeeper, + httpServer); } }; server.setShutdown(shutdown); new BlurServerShutDown().register(shutdown, zooKeeper); return server; } - + private static int getSlabCount(int slabCount, int numberOfBlocksPerSlab, int blockSize) { if (slabCount < 0) { long slabSize = numberOfBlocksPerSlab * blockSize; @@ -243,7 +250,7 @@ public class ThriftBlurShardServer extends ThriftServer { } return slabCount; } - + private static long getMaxDirectMemorySize(String arg) { int index = arg.lastIndexOf('='); return parseNumber(arg.substring(index + 1).toLowerCase().replace(" ", "")); http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/39c899d2/src/blur-gui/src/main/java/org/apache/blur/gui/HttpJettyServer.java ---------------------------------------------------------------------- diff --git a/src/blur-gui/src/main/java/org/apache/blur/gui/HttpJettyServer.java b/src/blur-gui/src/main/java/org/apache/blur/gui/HttpJettyServer.java index 1b271ef..9360471 100644 --- a/src/blur-gui/src/main/java/org/apache/blur/gui/HttpJettyServer.java +++ b/src/blur-gui/src/main/java/org/apache/blur/gui/HttpJettyServer.java @@ -38,6 +38,8 @@ public class HttpJettyServer { private Server server = null; + private WebAppContext context; + /** * @param bindPort * port of the process that the gui is wrapping @@ -56,8 +58,8 @@ public class HttpJettyServer { * metrics object for using. * @throws IOException */ - public HttpJettyServer(int bindPort, int port, int baseControllerPort, int baseShardPort, int baseGuiControllerPort, int baseGuiShardPort, String base) - throws IOException { + public HttpJettyServer(int bindPort, int port, int baseControllerPort, int baseShardPort, int baseGuiControllerPort, + int baseGuiShardPort, String base) throws IOException { server = new Server(port); String logDir = System.getProperty("blur.logs.dir"); @@ -71,7 +73,7 @@ public class HttpJettyServer { System.setProperty("blur.gui.mode", base); LOG.info("System props:" + System.getProperties().toString()); - WebAppContext context = new WebAppContext(); + context = new WebAppContext(); String warPath = getWarFolder(); context.setWar(warPath); context.setContextPath("/"); @@ -93,6 +95,10 @@ public class HttpJettyServer { } LOG.info("WEB GUI up on port: " + port); } + + public WebAppContext getContext() { + return context; + } private static String findBlurGuiInClassPath() { Properties properties = System.getProperties();
