diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RSGroupTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RSGroupTableAccessor.java index 06a76049b47..406c41ee52c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RSGroupTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RSGroupTableAccessor.java @@ -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 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() { - } } diff --git a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp index d866008f42e..7a80c35efc3 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp @@ -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
rsGroupServers = new ArrayList<>(); - List rsGroupTables = new ArrayList<>(); + pageContext.setAttribute("pageTitle", "RSGroup: " + rsGroupName); +%> + + + +
+<% + 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())) { +%> +
+ +
+

Go Back, or wait for the redirect. +<% + } else if (rsGroupName == null || rsGroupName.isEmpty() || + (rsGroupInfo = RSGroupTableAccessor.getRSGroupInfo( + master.getConnection(), Bytes.toBytes(rsGroupName))) == null) { +%> +

+ +
+

Go Back, or wait for the redirect. +<% + } else { + List

rsGroupServers = new ArrayList<>(); + List 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 onlineServers = Collections.emptyMap(); - Map 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 onlineServers = Collections.emptyMap(); + Map 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)); + } %> - - - -
- <% if (rsGroupName == null || rsGroupName.isEmpty() || rsGroupInfo == null) { %> -
- -
-

Go Back, or wait for the redirect. - <% } else { %>