HADOOP-2316 Run REST servlet outside of master

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@600707 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2007-12-03 22:06:07 +00:00
parent 30eb660601
commit c7574f8f32
3 changed files with 66 additions and 6 deletions

View File

@ -3,11 +3,15 @@ HBase Change Log
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 @@ Trunk (unreleased changes)
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.

View File

@ -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 org.apache.hadoop.hbase.HBaseAdmin;
import org.apache.hadoop.hbase.HBaseConfiguration;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import org.mortbay.http.HttpContext;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.util.InfoServer;
/**
* Servlet implementation class for hbase REST interface.
@ -160,4 +168,54 @@ implements javax.servlet.Servlet {
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.");
}
}

View File

@ -100,7 +100,7 @@ public class InfoServer {
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);