From 264d3e3b168169be88207478f51b23f0ba0c4e7a Mon Sep 17 00:00:00 2001 From: Karthik Palanisamy Date: Thu, 7 Nov 2019 17:55:57 -0800 Subject: [PATCH] HBASE-23263 NPE in Quotas.jsp (#800) Signed-off-by: Guangxu Cheng --- .../resources/hbase-webapps/master/quotas.jsp | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/hbase-server/src/main/resources/hbase-webapps/master/quotas.jsp b/hbase-server/src/main/resources/hbase-webapps/master/quotas.jsp index 4909ab63c36..780a8d4b360 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/quotas.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/quotas.jsp @@ -23,6 +23,7 @@ import="java.util.List" import="org.apache.hadoop.conf.Configuration" import="org.apache.hadoop.hbase.master.HMaster" + import="org.apache.hadoop.hbase.quotas.MasterQuotaManager" import="org.apache.hadoop.hbase.quotas.QuotaRetriever" import="org.apache.hadoop.hbase.quotas.QuotaSettings" import="org.apache.hadoop.hbase.quotas.ThrottleSettings" @@ -31,20 +32,24 @@ HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER); Configuration conf = master.getConfiguration(); pageContext.setAttribute("pageTitle", "HBase Master Quotas: " + master.getServerName()); - boolean exceedThrottleQuotaEnabled = master.getMasterQuotaManager().isExceedThrottleQuotaEnabled(); List regionServerThrottles = new ArrayList<>(); List namespaceThrottles = new ArrayList<>(); List userThrottles = new ArrayList<>(); - try (QuotaRetriever scanner = QuotaRetriever.open(conf, null)) { - for (QuotaSettings quota : scanner) { - if (quota instanceof ThrottleSettings) { - ThrottleSettings throttle = (ThrottleSettings) quota; - if (throttle.getUserName() != null) { - userThrottles.add(throttle); - } else if (throttle.getNamespace() != null) { - namespaceThrottles.add(throttle); - } else if (throttle.getRegionServer() != null) { - regionServerThrottles.add(throttle); + MasterQuotaManager quotaManager = master.getMasterQuotaManager(); + boolean exceedThrottleQuotaEnabled = false; + if (quotaManager != null) { + exceedThrottleQuotaEnabled = quotaManager.isExceedThrottleQuotaEnabled(); + try (QuotaRetriever scanner = QuotaRetriever.open(conf, null)) { + for (QuotaSettings quota : scanner) { + if (quota instanceof ThrottleSettings) { + ThrottleSettings throttle = (ThrottleSettings) quota; + if (throttle.getUserName() != null) { + userThrottles.add(throttle); + } else if (throttle.getNamespace() != null) { + namespaceThrottles.add(throttle); + } else if (throttle.getRegionServer() != null) { + regionServerThrottles.add(throttle); + } } } } @@ -61,13 +66,15 @@ +<%if (quotaManager != null) {%> +
- <%if (master.getMasterQuotaManager().isRpcThrottleEnabled()) {%> + <%if (quotaManager.isRpcThrottleEnabled()) {%>
Rpc throttle is enabled.
@@ -201,4 +208,6 @@ <% } %>
+<% } %> +