diff --git a/hbase-server/pom.xml b/hbase-server/pom.xml index 53c643b084d..d3befe01d65 100644 --- a/hbase-server/pom.xml +++ b/hbase-server/pom.xml @@ -114,6 +114,10 @@ + + + + diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java index 2cfd2206614..508aabbf84a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java @@ -32,6 +32,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.rest.filter.GzipFilter; import org.apache.hadoop.hbase.security.User; +import org.apache.hadoop.hbase.util.InfoServer; import org.apache.hadoop.hbase.util.Strings; import org.apache.hadoop.hbase.util.VersionInfo; import org.apache.hadoop.net.DNS; @@ -64,7 +65,7 @@ public class RESTServer implements Constants { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("bin/hbase rest start", "", options, "\nTo run the REST server as a daemon, execute " + - "bin/hbase-daemon.sh start|stop rest [-p ] [-ro]\n", true); + "bin/hbase-daemon.sh start|stop rest [--infoport ] [-p ] [-ro]\n", true); System.exit(exitCode); } @@ -84,6 +85,7 @@ public class RESTServer implements Constants { options.addOption("p", "port", true, "Port to bind to [default: 8080]"); options.addOption("ro", "readonly", false, "Respond only to GET HTTP " + "method requests [default: false]"); + options.addOption(null, "infoport", true, "Port for web UI"); CommandLine commandLine = null; try { @@ -107,6 +109,14 @@ public class RESTServer implements Constants { LOG.debug("readonly set to true"); } + // check for user-defined info server port setting, if so override the conf + if (commandLine != null && commandLine.hasOption("infoport")) { + String val = commandLine.getOptionValue("infoport"); + servlet.getConfiguration() + .setInt("hbase.rest.info.port", Integer.valueOf(val)); + LOG.debug("Web UI port set to " + val); + } + @SuppressWarnings("unchecked") List remainingArgs = commandLine != null ? commandLine.getArgList() : new ArrayList(); @@ -169,6 +179,16 @@ public class RESTServer implements Constants { machineName); } + // Put up info server. + int port = conf.getInt("hbase.rest.info.port", 8085); + if (port >= 0) { + conf.setLong("startcode", System.currentTimeMillis()); + String a = conf.get("hbase.rest.info.bindAddress", "0.0.0.0"); + InfoServer infoServer = new InfoServer("rest", a, port, false, conf); + infoServer.setAttribute("hbase.conf", conf); + infoServer.start(); + } + // start server server.start(); server.join(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java index 44c21af16d4..c1ac8f8a80b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java @@ -32,6 +32,7 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.thrift.ThriftServerRunner.ImplType; +import org.apache.hadoop.hbase.util.InfoServer; import org.apache.hadoop.hbase.util.VersionInfo; import org.apache.hadoop.util.Shell.ExitCodeException; @@ -60,6 +61,8 @@ public class ThriftServer { private Configuration conf; ThriftServerRunner serverRunner; + private InfoServer infoServer; + // // Main program and support routines // @@ -86,6 +89,16 @@ public class ThriftServer { void doMain(final String[] args) throws Exception { processOptions(args); serverRunner = new ThriftServerRunner(conf); + + // Put up info server. + int port = conf.getInt("hbase.thrift.info.port", 9095); + if (port >= 0) { + conf.setLong("startcode", System.currentTimeMillis()); + String a = conf.get("hbase.thrift.info.bindAddress", "0.0.0.0"); + infoServer = new InfoServer("thrift", a, port, false, conf); + infoServer.setAttribute("hbase.conf", conf); + infoServer.start(); + } serverRunner.run(); } @@ -101,6 +114,7 @@ public class ThriftServer { options.addOption("f", FRAMED_OPTION, false, "Use framed transport"); options.addOption("c", COMPACT_OPTION, false, "Use the compact protocol"); options.addOption("h", "help", false, "Print help information"); + options.addOption(null, "infoport", true, "Port for web UI"); options.addOption("m", MIN_WORKERS_OPTION, true, "The minimum number of worker threads for " + @@ -147,6 +161,18 @@ public class ThriftServer { printUsageAndExit(options, -1); } + // check for user-defined info server port setting, if so override the conf + try { + if (cmd.hasOption("infoport")) { + String val = cmd.getOptionValue("infoport"); + conf.setInt("hbase.thrift.info.port", Integer.valueOf(val)); + LOG.debug("Web UI port set to " + val); + } + } catch (NumberFormatException e) { + LOG.error("Could not parse the value provided for the infoport option", e); + printUsageAndExit(options, -1); + } + // Make optional changes to the configuration based on command-line options optionToConf(cmd, MIN_WORKERS_OPTION, conf, TBoundedThreadPoolServer.MIN_WORKER_THREADS_CONF_KEY); @@ -171,6 +197,14 @@ public class ThriftServer { } public void stop() { + if (this.infoServer != null) { + LOG.info("Stopping infoServer"); + try { + this.infoServer.stop(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } serverRunner.shutdown(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java index be9b9d06093..7a13ae46e4c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java @@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.thrift.CallQueue; import org.apache.hadoop.hbase.thrift.CallQueue.Call; import org.apache.hadoop.hbase.thrift.ThriftMetrics; import org.apache.hadoop.hbase.thrift2.generated.THBaseService; +import org.apache.hadoop.hbase.util.InfoServer; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TCompactProtocol; import org.apache.thrift.protocol.TProtocolFactory; @@ -66,6 +67,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; * HbaseClient.thrift IDL file. */ @InterfaceAudience.Private +@SuppressWarnings({ "rawtypes", "unchecked" }) public class ThriftServer { private static final Log log = LogFactory.getLog(ThriftServer.class); @@ -91,6 +93,7 @@ public class ThriftServer { options.addOption("f", "framed", false, "Use framed transport"); options.addOption("c", "compact", false, "Use the compact protocol"); options.addOption("h", "help", false, "Print help information"); + options.addOption(null, "infoport", true, "Port for web UI"); OptionGroup servers = new OptionGroup(); servers.addOption( @@ -225,15 +228,51 @@ public class ThriftServer { Configuration conf = HBaseConfiguration.create(); ThriftMetrics metrics = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.TWO); + String implType = "threadpool"; + if (nonblocking) { + implType = "nonblocking"; + } else if (hsha) { + implType = "hsha"; + } + + conf.set("hbase.regionserver.thrift.server.type", implType); + conf.setInt("hbase.regionserver.thrift.port", listenPort); + // Construct correct ProtocolFactory - TProtocolFactory protocolFactory = getTProtocolFactory(cmd.hasOption("compact")); + boolean compact = cmd.hasOption("compact"); + TProtocolFactory protocolFactory = getTProtocolFactory(compact); THBaseService.Iface handler = ThriftHBaseServiceHandler.newInstance(conf, metrics); THBaseService.Processor processor = new THBaseService.Processor(handler); + conf.setBoolean("hbase.regionserver.thrift.compact", compact); boolean framed = cmd.hasOption("framed") || nonblocking || hsha; TTransportFactory transportFactory = getTTransportFactory(framed); InetSocketAddress inetSocketAddress = bindToPort(cmd.getOptionValue("bind"), listenPort); + conf.setBoolean("hbase.regionserver.thrift.framed", framed); + + // check for user-defined info server port setting, if so override the conf + try { + if (cmd.hasOption("infoport")) { + String val = cmd.getOptionValue("infoport"); + conf.setInt("hbase.thrift.info.port", Integer.valueOf(val)); + log.debug("Web UI port set to " + val); + } + } catch (NumberFormatException e) { + log.error("Could not parse the value provided for the infoport option", e); + printUsage(); + System.exit(1); + } + + // Put up info server. + int port = conf.getInt("hbase.thrift.info.port", 9095); + if (port >= 0) { + conf.setLong("startcode", System.currentTimeMillis()); + String a = conf.get("hbase.thrift.info.bindAddress", "0.0.0.0"); + InfoServer infoServer = new InfoServer("thrift", a, port, false, conf); + infoServer.setAttribute("hbase.conf", conf); + infoServer.start(); + } if (nonblocking) { server = getTNonBlockingServer(protocolFactory, processor, transportFactory, inetSocketAddress); diff --git a/hbase-server/src/main/resources/hbase-webapps/rest/index.html b/hbase-server/src/main/resources/hbase-webapps/rest/index.html new file mode 100644 index 00000000000..e4084b7c488 --- /dev/null +++ b/hbase-server/src/main/resources/hbase-webapps/rest/index.html @@ -0,0 +1,20 @@ + + diff --git a/hbase-server/src/main/resources/hbase-webapps/rest/rest.jsp b/hbase-server/src/main/resources/hbase-webapps/rest/rest.jsp new file mode 100644 index 00000000000..9f82c3d5c32 --- /dev/null +++ b/hbase-server/src/main/resources/hbase-webapps/rest/rest.jsp @@ -0,0 +1,121 @@ +<%-- +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--%> +<%@ page contentType="text/html;charset=UTF-8" + import="org.apache.hadoop.conf.Configuration" + import="org.apache.hadoop.hbase.HBaseConfiguration" + import="org.apache.hadoop.hbase.util.VersionInfo" + import="java.util.Date" +%> + +<% +Configuration conf = (Configuration)getServletContext().getAttribute("hbase.conf"); +long startcode = conf.getLong("startcode", System.currentTimeMillis()); +String listenPort = conf.get("hbase.rest.port", "8080"); +%> + + + + + + HBase REST Server: <%= listenPort %> + + + + + + + + + + + + + +
+
+ +
+
+ +
+

Software Attributes

+ + + + + + + + + + + + + + + + + + + + + +
Attribute NameValueDescription
HBase Version<%= VersionInfo.getVersion() %>, r<%= VersionInfo.getRevision() %>HBase version and revision
HBase Compiled<%= VersionInfo.getDate() %>, <%= VersionInfo.getUser() %>When HBase version was compiled and by whom
REST Server Start Time<%= new Date(startcode) %>Date stamp of when this REST server was started
+
+
+ +
+ + + + + + diff --git a/hbase-server/src/main/resources/hbase-webapps/thrift/index.html b/hbase-server/src/main/resources/hbase-webapps/thrift/index.html new file mode 100644 index 00000000000..9925269e895 --- /dev/null +++ b/hbase-server/src/main/resources/hbase-webapps/thrift/index.html @@ -0,0 +1,20 @@ + + diff --git a/hbase-server/src/main/resources/hbase-webapps/thrift/thrift.jsp b/hbase-server/src/main/resources/hbase-webapps/thrift/thrift.jsp new file mode 100644 index 00000000000..6d406ca311c --- /dev/null +++ b/hbase-server/src/main/resources/hbase-webapps/thrift/thrift.jsp @@ -0,0 +1,139 @@ +<%-- +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--%> +<%@ page contentType="text/html;charset=UTF-8" + import="org.apache.hadoop.conf.Configuration" + import="org.apache.hadoop.hbase.HBaseConfiguration" + import="org.apache.hadoop.hbase.util.VersionInfo" + import="java.util.Date" +%> + +<% +Configuration conf = (Configuration)getServletContext().getAttribute("hbase.conf"); +long startcode = conf.getLong("startcode", System.currentTimeMillis()); +String listenPort = conf.get("hbase.regionserver.thrift.port", "9090"); +String serverInfo = listenPort + "," + String.valueOf(startcode); +String implType = conf.get("hbase.regionserver.thrift.server.type", "threadpool"); +String compact = conf.get("hbase.regionserver.thrift.compact", "false"); +String framed = conf.get("hbase.regionserver.thrift.framed", "false"); +%> + + + + + + HBase Thrift Server: <%= listenPort %> + + + + + + + + + + + + + +
+
+ +
+
+ +
+

Software Attributes

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Attribute NameValueDescription
HBase Version<%= VersionInfo.getVersion() %>, r<%= VersionInfo.getRevision() %>HBase version and revision
HBase Compiled<%= VersionInfo.getDate() %>, <%= VersionInfo.getUser() %>When HBase version was compiled and by whom
Thrift Server Start Time<%= new Date(startcode) %>Date stamp of when this Thrift server was started
Thrift Impl Type<%= implType %>Thrift RPC engine implementation type chosen by this Thrift server
Compact Protocol<%= compact %>Thrift RPC engine uses compact protocol
Framed Transport<%= framed %>Thrift RPC engine uses framed transport
+
+
+ +
+ + + + +