From 4888d54b9a2fcaadc072198cf31324dadfa37bc3 Mon Sep 17 00:00:00 2001 From: meiyi Date: Thu, 29 Aug 2019 15:45:57 +0800 Subject: [PATCH] HBASE-22878 Show table throttle quotas in table jsp --- .../hbase/quotas/QuotaSettingsFactory.java | 9 ++++- .../hadoop/hbase/quotas/ThrottleSettings.java | 7 +++- .../resources/hbase-webapps/master/table.jsp | 38 ++++++++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java index 4473b7323390..3e5bc16860fd 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaSettingsFactory.java @@ -123,10 +123,15 @@ private static List fromQuotas(final String userName, final Table return settings; } - protected static List fromThrottle(final String userName, + public static List fromTableThrottles(final TableName tableName, + final QuotaProtos.Throttle throttle) { + return fromThrottle(null, tableName, null, null, throttle); + } + + protected static List fromThrottle(final String userName, final TableName tableName, final String namespace, final String regionServer, final QuotaProtos.Throttle throttle) { - List settings = new ArrayList<>(); + List settings = new ArrayList<>(); if (throttle.hasReqNum()) { settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer, ThrottleType.REQUEST_NUMBER, throttle.getReqNum())); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/ThrottleSettings.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/ThrottleSettings.java index c6166207b15d..3c25d6e4f947 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/ThrottleSettings.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/ThrottleSettings.java @@ -32,7 +32,7 @@ @InterfaceAudience.Private @InterfaceStability.Evolving -class ThrottleSettings extends QuotaSettings { +public class ThrottleSettings extends QuotaSettings { final QuotaProtos.ThrottleRequest proto; ThrottleSettings(final String userName, final TableName tableName, final String namespace, @@ -62,6 +62,11 @@ public TimeUnit getTimeUnit() { ProtobufUtil.toTimeUnit(proto.getTimedQuota().getTimeUnit()) : null; } + public QuotaScope getQuotaScope() { + return proto.hasTimedQuota() ? ProtobufUtil.toQuotaScope(proto.getTimedQuota().getScope()) + : null; + } + @Override public QuotaType getQuotaType() { return QuotaType.THROTTLE; diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index fb1d513651de..b1d4ad4f6ccc 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -22,12 +22,10 @@ import="static org.apache.commons.lang3.StringEscapeUtils.escapeXml" import="java.util.ArrayList" import="java.util.Collection" - import="java.util.Collections" import="java.util.HashMap" import="java.util.LinkedHashMap" import="java.util.List" import="java.util.Map" - import="java.util.Objects" import="java.util.TreeMap" import=" java.util.concurrent.TimeUnit" import="org.apache.commons.lang3.StringEscapeUtils" @@ -51,8 +49,10 @@ import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.master.assignment.RegionStates" import="org.apache.hadoop.hbase.master.RegionState" + import="org.apache.hadoop.hbase.quotas.QuotaSettingsFactory" import="org.apache.hadoop.hbase.quotas.QuotaTableUtil" import="org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot" + import="org.apache.hadoop.hbase.quotas.ThrottleSettings" import="org.apache.hadoop.hbase.util.Bytes" import="org.apache.hadoop.hbase.util.FSUtils" import="org.apache.hadoop.hbase.zookeeper.MetaTableLocator" @@ -358,6 +358,40 @@ if (fqtn != null && master.isInitialized()) { <% } + + if (quota.hasThrottle()) { + List throttles = QuotaSettingsFactory.fromTableThrottles(table.getName(), quota.getThrottle()); + if (throttles.size() > 0) { +%> + + Throttle Quota + + + + + + + + +<% + for (ThrottleSettings throttle : throttles) { +%> + + + + + + +<% + } +%> +
LimitTypeTimeUnitScope
<%= throttle.getSoftLimit() %><%= throttle.getThrottleType() %><%= throttle.getTimeUnit() %><%= throttle.getQuotaScope() %>
+ + Information about a Throttle Quota on this table, if set. + +<% + } + } } %>