incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: The thrift over http via json is now mapped to /rpc on the 40090 http port.
Date Wed, 06 Mar 2013 20:39:13 GMT
Updated Branches:
  refs/heads/0.2-dev e3a319d98 -> 6cb3402f2


The thrift over http via json is now mapped to /rpc on the 40090 http port.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/6cb3402f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/6cb3402f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/6cb3402f

Branch: refs/heads/0.2-dev
Commit: 6cb3402f26c0081ceddaf7079d2c0aabee02046d
Parents: cdbe70f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Mar 6 15:38:02 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Mar 6 15:38:02 2013 -0500

----------------------------------------------------------------------
 .../org/apache/blur/thrift/ThriftBlurServer.java   |   31 ++++++--------
 .../java/org/apache/blur/gui/HttpJettyServer.java  |   15 ++-----
 2 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6cb3402f/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
index 1880436..a54a6e9 100644
--- a/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/thrift/ThriftBlurServer.java
@@ -26,7 +26,6 @@ import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_DIRECT_M
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_BLOCKCACHE_SLAB_COUNT;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_FILTER_CACHE_CLASS;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_HOSTNAME;
-import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_INDEX_WARMUP_CLASS;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_OPENER_THREAD_COUNT;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_SAFEMODEDELAY;
 import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT;
@@ -52,10 +51,8 @@ import org.apache.blur.log.LogFactory;
 import org.apache.blur.manager.BlurFilterCache;
 import org.apache.blur.manager.DefaultBlurFilterCache;
 import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
-import org.apache.blur.manager.indexserver.BlurIndexWarmup;
 import org.apache.blur.manager.indexserver.BlurServerShutDown;
 import org.apache.blur.manager.indexserver.BlurServerShutDown.BlurShutdown;
-import org.apache.blur.manager.indexserver.DefaultBlurIndexWarmup;
 import org.apache.blur.manager.indexserver.DistributedIndexServer;
 import org.apache.blur.manager.indexserver.DistributedLayoutManager;
 import org.apache.blur.manager.writer.BlurIndexRefresher;
@@ -72,9 +69,14 @@ import org.apache.blur.utils.BlurConstants;
 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.protocol.TProtocolFactory;
+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 ThriftBlurServer extends AbstractThriftServer {
 
@@ -128,13 +130,15 @@ public class ThriftBlurServer extends AbstractThriftServer {
 
     int baseGuiPort = Integer.parseInt(configuration.get(BLUR_GUI_SHARD_PORT));
     final HttpJettyServer httpServer;
+    WebAppContext context = null;
     if (baseGuiPort > 0) {
       int webServerPort = baseGuiPort + serverIndex;
 
       // 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_SHARD_BIND_PORT,
-1), configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1),
-          configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "blur", null);
+      httpServer = new HttpJettyServer();
+      context = httpServer.init(bindPort, webServerPort, configuration.getInt(BLUR_SHARD_BIND_PORT,
-1), configuration.getInt(BLUR_GUI_CONTROLLER_PORT, -1),
+          configuration.getInt(BLUR_GUI_SHARD_PORT, -1), "blur");
     } else {
       httpServer = null;
     }
@@ -245,6 +249,10 @@ public class ThriftBlurServer extends AbstractThriftServer {
     int threadCount = configuration.getInt(BLUR_SHARD_SERVER_THRIFT_THREAD_COUNT, 32);
 
     Processor<Iface> processor = new Processor<Iface>(iface);
+    
+    if (context != null) {
+      context.addServlet(new ServletHolder(new TServlet(processor, new TJSONProtocol.Factory())),
"/rpc");
+    }
 
     final ThriftBlurServer server = new ThriftBlurServer();
     server.setNodeName(nodeName);
@@ -279,17 +287,4 @@ public class ThriftBlurServer extends AbstractThriftServer {
     }
     return new DefaultBlurFilterCache();
   }
-
-  private static BlurIndexWarmup getIndexWarmup(BlurConfiguration configuration) {
-    String _blurFilterCacheClass = configuration.get(BLUR_SHARD_INDEX_WARMUP_CLASS);
-    if (_blurFilterCacheClass != null) {
-      try {
-        Class<?> clazz = Class.forName(_blurFilterCacheClass);
-        return (BlurIndexWarmup) clazz.newInstance();
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-    return new DefaultBlurIndexWarmup();
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/6cb3402f/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 e29a13f..35be06c 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
@@ -22,10 +22,6 @@ import java.util.Properties;
 
 import org.apache.blur.log.Log;
 import org.apache.blur.log.LogFactory;
-import org.apache.thrift.TProcessor;
-import org.apache.thrift.protocol.TJSONProtocol;
-import org.apache.thrift.protocol.TProtocolFactory;
-import org.apache.thrift.server.TServlet;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.servlet.ServletHolder;
 import org.mortbay.jetty.webapp.WebAppContext;
@@ -41,7 +37,7 @@ public class HttpJettyServer {
   private static final Log LOG = LogFactory.getLog(HttpJettyServer.class);
 
   private Server server = null;
-
+  
   /**
    * @param bindPort
    *          port of the process that the gui is wrapping
@@ -59,10 +55,10 @@ public class HttpJettyServer {
    * @param bm
    *          metrics object for using.
    * @param processor
+   * @return 
    * @throws IOException
    */
-  public HttpJettyServer(int bindPort, int port, int baseRpcPort, int baseGuiControllerPort,
int baseGuiShardPort, String base, TProcessor processor)
-      throws IOException {
+  public WebAppContext init(int bindPort, int port, int baseRpcPort, int baseGuiControllerPort,
int baseGuiShardPort, String base) throws IOException {
     server = new Server(port);
 
     String logDir = System.getProperty("blur.logs.dir");
@@ -80,10 +76,6 @@ public class HttpJettyServer {
     context.setWar(warPath);
     context.setContextPath("/");
     context.setParentLoaderPriority(true);
-    TProtocolFactory protocolFactory = new TJSONProtocol.Factory();
-    if (processor != null) {
-      context.addServlet(new ServletHolder(new TServlet(processor, protocolFactory)), "/rpc");
-    }
     context.addServlet(new ServletHolder(new LiveMetricsServlet()), "/livemetrics");
     context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
     context.addServlet(new ServletHolder(new LogServlet(blurLogFile)), "/logs");
@@ -100,6 +92,7 @@ public class HttpJettyServer {
       throw new IOException("cannot start Http server for " + base, e);
     }
     LOG.info("WEB GUI up on port: " + port);
+    return context;
   }
 
   private static String findBlurGuiInClassPath() {


Mime
View raw message