hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r600707 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/rest/Dispatcher.java src/java/org/apache/hadoop/hbase/util/InfoServer.java
Date Mon, 03 Dec 2007 22:06:23 GMT
Author: stack
Date: Mon Dec  3 14:06:07 2007
New Revision: 600707

URL: http://svn.apache.org/viewvc?rev=600707&view=rev
Log:
HADOOP-2316 Run REST servlet outside of master

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/util/InfoServer.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=600707&r1=600706&r2=600707&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Mon Dec  3 14:06:07 2007
@@ -3,11 +3,15 @@
 
 Trunk (unreleased changes)
   INCOMPATIBLE CHANGES
+   HADOOP-2056 A table with row keys containing colon fails to split regions
+   HADOOP-2079 Fix generated HLog, HRegion names
 
   NEW FEATURES
     HADOOP-2061 Add new Base64 dialects
     HADOOP-2084 Add a LocalHBaseCluster
     HADOOP-2068 RESTful interface (Bryan Duxbury via Stack)
+    HADOOP-2316 Run REST servlet outside of master
+                (Bryan Duxbury via Stack)
 
   OPTIMIZATIONS
 
@@ -15,8 +19,6 @@
    HADOOP-2059 In tests, exceptions in min dfs shutdown should not fail test
                (e.g. nightly #272)
    HADOOP-2064 TestSplit assertion and NPE failures (Patch build #952 and #953)
-   HADOOP-2056 A table with row keys containing colon fails to split regions
-   HADOOP-2079 HADOOP-2056 Fix generated HLog, HRegion names
    HADOOP-2124 Use of `hostname` does not work on Cygwin in some cases
    HADOOP-2083 TestTableIndex failed in #970 and #956
    HADOOP-2109 Fixed race condition in processing server lease timeout.

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java?rev=600707&r1=600706&r2=600707&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/rest/Dispatcher.java
Mon Dec  3 14:06:07 2007
@@ -19,15 +19,23 @@
  */
 package org.apache.hadoop.hbase.rest;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.io.IOException;
-
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import org.mortbay.http.SocketListener;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import java.net.URL;
+import org.mortbay.http.HttpContext;
 
-import org.apache.hadoop.hbase.HBaseAdmin;
-import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.util.InfoServer;
 
 /**
  * Servlet implementation class for hbase REST interface.
@@ -159,5 +167,55 @@
   private String [] getPathSegments(final HttpServletRequest request) {
     int context_len = request.getContextPath().length() + 1;
     return request.getRequestURI().substring(context_len).split("/");
+  }
+
+
+  /*
+   * Start up the REST servlet in standalone mode.
+   */
+  public static void main(String[] args) throws Exception{
+    int port = 60050;
+    String bindAddress = "0.0.0.0";
+    
+    // grab the port and bind addresses from the command line if supplied
+    for(int i = 0; i < args.length; i++){
+      if(args[i].equals("--port")){
+        port = Integer.parseInt(args[++i]);
+      } else if(args[i].equals("--bind")){
+        bindAddress = args[++i];
+      } else if(args[i].equals("--help")){
+        printUsage();
+        return;
+      } else {
+        System.out.println("Unrecognized switch " + args[i]);
+        printUsage();
+        return;
+      }
+    }
+    
+    org.mortbay.jetty.Server webServer = new org.mortbay.jetty.Server();
+
+    SocketListener listener = new SocketListener();
+    listener.setPort(port);
+    listener.setHost(bindAddress);
+    webServer.addListener(listener);
+  
+    webServer.addWebApplication("/api", InfoServer.getWebAppDir("rest"));
+    
+    webServer.start();
+  }  
+  
+  /*
+   * Print out the usage of this class from the command line.
+   */ 
+  private static void printUsage(){
+    System.out.println("Start up the HBase REST servlet.");
+    System.out.println("Options:");
+    System.out.println("--port [port]");
+    System.out.println("\tPort to listen on. Defaults to 60050.");
+    System.out.println("--bind [addr]");
+    System.out.println("\tAddress to bind on. Defaults to 0.0.0.0.");
+    System.out.println("--help");
+    System.out.println("\tPrint this message and exit.");
   }
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/util/InfoServer.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/util/InfoServer.java?rev=600707&r1=600706&r2=600707&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/util/InfoServer.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/util/InfoServer.java
Mon Dec  3 14:06:07 2007
@@ -100,7 +100,7 @@
     addServlet("logLevel", "/logLevel", org.apache.hadoop.log.LogLevel.Servlet.class);
   }
   
-  private String getWebAppDir(final String webappName) throws IOException {
+  public static String getWebAppDir(final String webappName) throws IOException {
     String webappDir = null;
     try {
       webappDir = getWebAppsPath("webapps" + File.separator + webappName);



Mime
View raw message