Skip to content

Commit 526bad7

Browse files
authored
HBASE-29028 Backport missing UI patches to branch-2.5 (#6542)
* HBASE-27406 Make /prometheus endpoint accessible from HBase UI (#4833) Signed-off-by: Andor Molnar <[email protected]> Signed-off-by: Balazs Meszaros <[email protected]> (cherry picked from commit dffc8e0) * HBASE-27814 Add support for dump and process metrics servlet in REST InfoServer (#5215) Other changes: - Ensure info server stops during stop() - Extract header and footer. This would fix the log level page layout for rest web UI (See HBASE-20693) - Add hostname in the landing page instead of just port similar to other web UIs Signed-off-by: Nick Dimiduk <[email protected]> (cherry picked from commit a683fcf) * HBASE-18382 add transport type info into Thrift UI (#880) Signed-off-by: Wellington Chevreuil <[email protected]> Signed-off-by: Bharath Vissapragada <[email protected]> Signed-off-by: Viraj Jasani <[email protected]> (cherry picked from commit 82e155e) * HBASE-20693 Refactor thrift jsp's and extract header and footer (#5732) - Fixes the way logLevel page renders in UI Signed-off-by: Nick Dimiduk <[email protected]> (cherry picked from commit ede4ccd) * HBASE-24624 Optimize table.jsp code (#1963) Signed-off-by: Guangxu Cheng <[email protected]> (cherry picked from commit 9ad16aa) * HBASE-25402 Sorting order by start key or end key is not considering empty start key/end key (#2955) Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Pankaj Kumar<[email protected]> (cherry picked from commit 157200e) * HBASE-27309 Add major compact table or region operation on master web table page (#4793) Co-authored-by: zhengsicheng <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit eb6b274) * HBASE-28778 NPE may occur when opening master-status or table.jsp or procedure.jsp while Master is initializing (#6152) Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 3caaf2d) * HBASE-28305 Add "Uncompressed StoreFileSize" column to the table.jsp (#5620) Co-authored-by: Haosen Chen <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit e3a0174) * HBASE-20452 Master UI: Table merge button should validate required fields before submit Signed-off-by: tedyu <[email protected]> (cherry picked from commit 6ce1136) * HBASE-29028 Removed Prometheus links from navbar as the feature (HBASE-20904) is not even supported by backend. --------- Co-authored-by: Luca Kovács <[email protected]> Co-authored-by: Nihal Jain <[email protected]> Co-authored-by: Beata Sudi <[email protected]> Co-authored-by: xincunSong <[email protected]> Co-authored-by: Akshay Sudheer <[email protected]> Co-authored-by: SiCheng-Zheng <[email protected]> Co-authored-by: Peng Lu <[email protected]> Co-authored-by: haosen chen <[email protected]> Co-authored-by: Nihal Jain <[email protected]> Signed-off-by: Andrew Purtell <[email protected]> Signed-off-by: Nihal Jain <[email protected]>
1 parent ef369dc commit 526bad7

File tree

14 files changed

+1548
-1074
lines changed

14 files changed

+1548
-1074
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hbase.rest;
19+
20+
import java.io.IOException;
21+
import java.io.OutputStream;
22+
import java.io.PrintStream;
23+
import java.io.PrintWriter;
24+
import java.util.Date;
25+
import javax.servlet.http.HttpServletRequest;
26+
import javax.servlet.http.HttpServletResponse;
27+
import org.apache.hadoop.conf.Configuration;
28+
import org.apache.hadoop.hbase.http.HttpServer;
29+
import org.apache.hadoop.hbase.monitoring.StateDumpServlet;
30+
import org.apache.hadoop.hbase.util.LogMonitoring;
31+
import org.apache.hadoop.hbase.util.Threads;
32+
import org.apache.yetus.audience.InterfaceAudience;
33+
34+
@InterfaceAudience.Private
35+
public class RESTDumpServlet extends StateDumpServlet {
36+
private static final long serialVersionUID = 1L;
37+
private static final String LINE = "===========================================================";
38+
39+
@Override
40+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
41+
if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) {
42+
return;
43+
}
44+
45+
RESTServer restServer = (RESTServer) getServletContext().getAttribute(RESTServer.REST_SERVER);
46+
assert restServer != null : "No REST Server in context!";
47+
48+
response.setContentType("text/plain");
49+
OutputStream os = response.getOutputStream();
50+
try (PrintWriter out = new PrintWriter(os)) {
51+
52+
out.println("REST Server status for " + restServer.getServerName() + " as of " + new Date());
53+
54+
out.println("\n\nVersion Info:");
55+
out.println(LINE);
56+
dumpVersionInfo(out);
57+
58+
out.println("\n\nStacks:");
59+
out.println(LINE);
60+
out.flush();
61+
PrintStream ps = new PrintStream(response.getOutputStream(), false, "UTF-8");
62+
Threads.printThreadInfo(ps, "");
63+
ps.flush();
64+
65+
out.println("\n\nREST Server configuration:");
66+
out.println(LINE);
67+
Configuration conf = restServer.conf;
68+
out.flush();
69+
conf.writeXml(os);
70+
os.flush();
71+
72+
out.println("\n\nLogs");
73+
out.println(LINE);
74+
long tailKb = getTailKbParam(request);
75+
LogMonitoring.dumpTailOfLogs(out, tailKb);
76+
77+
out.flush();
78+
}
79+
}
80+
}

hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/RESTServer.java

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.apache.hadoop.hbase.http.HttpServerUtil.PATH_SPEC_ANY;
2121

2222
import java.lang.management.ManagementFactory;
23+
import java.net.UnknownHostException;
2324
import java.util.ArrayList;
2425
import java.util.EnumSet;
2526
import java.util.List;
@@ -31,6 +32,7 @@
3132
import org.apache.hadoop.conf.Configuration;
3233
import org.apache.hadoop.hbase.HBaseConfiguration;
3334
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
35+
import org.apache.hadoop.hbase.ServerName;
3436
import org.apache.hadoop.hbase.http.HttpServerUtil;
3537
import org.apache.hadoop.hbase.http.InfoServer;
3638
import org.apache.hadoop.hbase.log.HBaseMarkers;
@@ -83,6 +85,7 @@
8385
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)
8486
public class RESTServer implements Constants {
8587
static Logger LOG = LoggerFactory.getLogger("RESTServer");
88+
public static final String REST_SERVER = "rest";
8689

8790
static final String REST_CSRF_ENABLED_KEY = "hbase.rest.csrf.enabled";
8891
static final boolean REST_CSRF_ENABLED_DEFAULT = false;
@@ -110,6 +113,7 @@ public class RESTServer implements Constants {
110113
private final UserProvider userProvider;
111114
private Server server;
112115
private InfoServer infoServer;
116+
private ServerName serverName;
113117

114118
public RESTServer(Configuration conf) {
115119
RESTServer.conf = conf;
@@ -143,8 +147,7 @@ void addCSRFFilter(ServletContextHandler ctxHandler, Configuration conf) {
143147
loginServerPrincipal(UserProvider userProvider, Configuration conf) throws Exception {
144148
Class<? extends ServletContainer> containerClass = ServletContainer.class;
145149
if (userProvider.isHadoopSecurityEnabled() && userProvider.isHBaseSecurityEnabled()) {
146-
String machineName = Strings.domainNamePointerToHostName(DNS.getDefaultHost(
147-
conf.get(REST_DNS_INTERFACE, "default"), conf.get(REST_DNS_NAMESERVER, "default")));
150+
String machineName = getHostName(conf);
148151
String keytabFilename = conf.get(REST_KEYTAB_FILE);
149152
Preconditions.checkArgument(keytabFilename != null && !keytabFilename.isEmpty(),
150153
REST_KEYTAB_FILE + " should be set if security is enabled");
@@ -385,24 +388,46 @@ public synchronized void run() throws Exception {
385388
// Put up info server.
386389
int port = conf.getInt("hbase.rest.info.port", 8085);
387390
if (port >= 0) {
388-
conf.setLong("startcode", EnvironmentEdgeManager.currentTime());
389-
String a = conf.get("hbase.rest.info.bindAddress", "0.0.0.0");
390-
this.infoServer = new InfoServer("rest", a, port, false, conf);
391+
final long startCode = EnvironmentEdgeManager.currentTime();
392+
conf.setLong("startcode", startCode);
393+
this.serverName = ServerName.valueOf(getHostName(conf), servicePort, startCode);
394+
395+
String addr = conf.get("hbase.rest.info.bindAddress", "0.0.0.0");
396+
this.infoServer = new InfoServer(REST_SERVER, addr, port, false, conf);
397+
this.infoServer.addPrivilegedServlet("dump", "/dump", RESTDumpServlet.class);
398+
this.infoServer.setAttribute(REST_SERVER, this);
391399
this.infoServer.setAttribute("hbase.conf", conf);
392400
this.infoServer.start();
393401
}
394402
// start server
395403
server.start();
396404
}
397405

406+
private static String getHostName(Configuration conf) throws UnknownHostException {
407+
return Strings.domainNamePointerToHostName(DNS.getDefaultHost(
408+
conf.get(REST_DNS_INTERFACE, "default"), conf.get(REST_DNS_NAMESERVER, "default")));
409+
}
410+
398411
public synchronized void join() throws Exception {
399412
if (server == null) {
400413
throw new IllegalStateException("Server is not running");
401414
}
402415
server.join();
403416
}
404417

418+
private void stopInfoServer() {
419+
if (this.infoServer != null) {
420+
LOG.info("Stop info server");
421+
try {
422+
this.infoServer.stop();
423+
} catch (Exception e) {
424+
LOG.error("Failed to stop infoServer", e);
425+
}
426+
}
427+
}
428+
405429
public synchronized void stop() throws Exception {
430+
stopInfoServer();
406431
if (server == null) {
407432
throw new IllegalStateException("Server is not running");
408433
}
@@ -426,6 +451,10 @@ public synchronized int getInfoPort() {
426451
return infoServer.getPort();
427452
}
428453

454+
public ServerName getServerName() {
455+
return serverName;
456+
}
457+
429458
public Configuration getConf() {
430459
return conf;
431460
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<%--
2+
/**
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
--%>
20+
21+
<script src="/static/js/jquery.min.js" type="text/javascript"></script>
22+
<script src="/static/js/bootstrap.min.js" type="text/javascript"></script>
23+
<script src="/static/js/tab.js" type="text/javascript"></script>
24+
<script type="text/javascript">
25+
$(document).ready(function() {
26+
$('div.navbar li.active').removeClass('active');
27+
$('a[href="' + location.pathname + '"]').closest('li').addClass('active');
28+
});
29+
</script>
30+
</body>
31+
</html>
32+
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<%--
2+
/**
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
--%>
20+
<%@ page contentType="text/html;charset=UTF-8"
21+
import="org.apache.hadoop.hbase.HBaseConfiguration"%>
22+
23+
<!DOCTYPE html>
24+
<?xml version="1.0" encoding="UTF-8" ?>
25+
<html lang="en">
26+
<head>
27+
<meta charset="utf-8">
28+
<title><%= request.getParameter("pageTitle")%></title>
29+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
30+
<meta name="description" content="">
31+
32+
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
33+
<link href="/static/css/bootstrap-theme.min.css" rel="stylesheet">
34+
<link href="/static/css/hbase.css" rel="stylesheet">
35+
</head>
36+
37+
<body>
38+
<div class="navbar navbar-fixed-top navbar-default">
39+
<div class="container-fluid">
40+
<div class="navbar-header">
41+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
42+
<span class="icon-bar"></span>
43+
<span class="icon-bar"></span>
44+
<span class="icon-bar"></span>
45+
</button>
46+
<a class="navbar-brand" href="/rest.jsp"><img src="/static/hbase_logo_small.png" alt="HBase Logo"/></a>
47+
</div>
48+
<div class="collapse navbar-collapse">
49+
<ul class="nav navbar-nav">
50+
<li class="active"><a href="/rest.jsp">Home</a></li>
51+
<li><a href="/logs/">Local logs</a></li>
52+
<li><a href="/processRest.jsp">Process Metrics</a></li>
53+
<li><a href="/logLevel">Log Level</a></li>
54+
<li><a href="/dump">Debug Dump</a></li>
55+
<li class="nav-item dropdown">
56+
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
57+
Metrics <span class="caret"></span>
58+
</a>
59+
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
60+
<li><a target="_blank" href="/jmx">JMX</a></li>
61+
<li><a target="_blank" href="/jmx?description=true">JMX with description</a></li>
62+
</ul>
63+
</li>
64+
<li><a href="/prof">Profiler</a></li>
65+
<% if (HBaseConfiguration.isShowConfInServlet()) { %>
66+
<li><a href="/conf">HBase Configuration</a></li>
67+
<% } %>
68+
</ul>
69+
</div><!--/.nav-collapse -->
70+
</div>
71+
</div>
72+

0 commit comments

Comments
 (0)