HBASE-5483 Allow configurable host to bind to for starting REST server from commandline

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1294229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-02-27 17:01:04 +00:00
parent c176d41582
commit 4ef6cb8bc9
1 changed files with 9 additions and 2 deletions

View File

@ -39,7 +39,9 @@ import org.apache.hadoop.net.DNS;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server; import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder; import org.mortbay.jetty.servlet.ServletHolder;
@ -129,9 +131,14 @@ public class Main implements Constants {
// set up Jetty and run the embedded server // set up Jetty and run the embedded server
int port = servlet.getConfiguration().getInt("hbase.rest.port", 8080); Server server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(servlet.getConfiguration().getInt("hbase.rest.port", 8080));
connector.setHost(servlet.getConfiguration().get("hbase.rest.host", "0.0.0.0"));
server.addConnector(connector);
Server server = new Server(port);
server.setSendServerVersion(false); server.setSendServerVersion(false);
server.setSendDateHeader(false); server.setSendDateHeader(false);
server.setStopAtShutdown(true); server.setStopAtShutdown(true);