HBASE-20382 If RSGroups not enabled, rsgroup.jsp prints stack trace

This commit is contained in:
Balazs Meszaros 2018-04-11 15:53:58 +02:00 committed by Michael Stack
parent eb40e6dfaa
commit 35b4adf3ed
2 changed files with 51 additions and 37 deletions

View File

@ -45,6 +45,13 @@ public final class RSGroupTableAccessor {
private static final byte[] META_FAMILY_BYTES = Bytes.toBytes("m");
private static final byte[] META_QUALIFIER_BYTES = Bytes.toBytes("i");
private RSGroupTableAccessor() {
}
public static boolean isRSGroupsEnabled(Connection connection) throws IOException {
return connection.getAdmin().tableExists(RSGROUP_TABLE_NAME);
}
public static List<RSGroupInfo> getAllRSGroupInfo(Connection connection)
throws IOException {
try (Table rsGroupTable = connection.getTable(RSGROUP_TABLE_NAME)) {
@ -76,7 +83,4 @@ public final class RSGroupTableAccessor {
return getRSGroupInfo(result);
}
}
private RSGroupTableAccessor() {
}
}

View File

@ -45,20 +45,43 @@
<%@ page import="org.apache.hadoop.hbase.Size" %>
<%@ page import="org.apache.hadoop.hbase.RegionMetrics" %>
<%
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
String rsGroupName = request.getParameter("name");
List<Address> rsGroupServers = new ArrayList<>();
List<TableName> rsGroupTables = new ArrayList<>();
pageContext.setAttribute("pageTitle", "RSGroup: " + rsGroupName);
%>
<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>
<div class="container-fluid content">
<%
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
RSGroupInfo rsGroupInfo = null;
if (rsGroupName != null && !rsGroupName.isEmpty()) {
rsGroupInfo = RSGroupTableAccessor.getRSGroupInfo(
master.getConnection(), Bytes.toBytes(rsGroupName));
if (rsGroupInfo != null) {
rsGroupServers.addAll(rsGroupInfo.getServers());
rsGroupTables.addAll(rsGroupInfo.getTables());
}
}
Collections.sort(rsGroupServers);
if (!RSGroupTableAccessor.isRSGroupsEnabled(master.getConnection())) {
%>
<div class="row inner_header">
<div class="page-header">
<h1>RSGroups are not enabled</h1>
</div>
</div>
<p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.
<%
} else if (rsGroupName == null || rsGroupName.isEmpty() ||
(rsGroupInfo = RSGroupTableAccessor.getRSGroupInfo(
master.getConnection(), Bytes.toBytes(rsGroupName))) == null) {
%>
<div class="row inner_header">
<div class="page-header">
<h1>RSGroup: <%= rsGroupName %> does not exist</h1>
</div>
</div>
<p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.
<%
} else {
List<Address> rsGroupServers = new ArrayList<>();
List<TableName> rsGroupTables = new ArrayList<>();
rsGroupServers.addAll(rsGroupInfo.getServers());
rsGroupTables.addAll(rsGroupInfo.getTables());
Collections.sort(rsGroupServers);
rsGroupTables.sort((o1, o2) -> {
int compare = Bytes.compareTo(o1.getNamespace(), o2.getNamespace());
if (compare != 0)
@ -69,29 +92,16 @@
return 0;
});
Map<Address, ServerMetrics> onlineServers = Collections.emptyMap();
Map<Address, ServerName> serverMaping = Collections.emptyMap();
if (master.getServerManager() != null) {
onlineServers = master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getValue));
serverMaping =
master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getKey));
}
pageContext.setAttribute("pageTitle", "RSGroup: " + rsGroupName);
Map<Address, ServerMetrics> onlineServers = Collections.emptyMap();
Map<Address, ServerName> serverMaping = Collections.emptyMap();
if (master.getServerManager() != null) {
onlineServers = master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getValue));
serverMaping =
master.getServerManager().getOnlineServers().entrySet().stream()
.collect(Collectors.toMap(p -> p.getKey().getAddress(), Map.Entry::getKey));
}
%>
<jsp:include page="header.jsp">
<jsp:param name="pageTitle" value="${pageTitle}"/>
</jsp:include>
<div class="container-fluid content">
<% if (rsGroupName == null || rsGroupName.isEmpty() || rsGroupInfo == null) { %>
<div class="row inner_header">
<div class="page-header">
<h1>RSGroup: "<%= rsGroupName %>" does not exist</h1>
</div>
</div>
<p>Go <a href="javascript:history.back()">Back</a>, or wait for the redirect.
<% } else { %>
<div class="container-fluid content">
<div class="row">
<div class="page-header">