Skip to content

Commit

Permalink
HBASE-22878 Show table throttle quotas in table jsp
Browse files Browse the repository at this point in the history
  • Loading branch information
mymeiyi committed Aug 29, 2019
1 parent 56980fb commit 4888d54
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,15 @@ private static List<QuotaSettings> fromQuotas(final String userName, final Table
return settings;
}

protected static List<QuotaSettings> fromThrottle(final String userName,
public static List<ThrottleSettings> fromTableThrottles(final TableName tableName,
final QuotaProtos.Throttle throttle) {
return fromThrottle(null, tableName, null, null, throttle);
}

protected static List<ThrottleSettings> fromThrottle(final String userName,
final TableName tableName, final String namespace, final String regionServer,
final QuotaProtos.Throttle throttle) {
List<QuotaSettings> settings = new ArrayList<>();
List<ThrottleSettings> settings = new ArrayList<>();
if (throttle.hasReqNum()) {
settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer,
ThrottleType.REQUEST_NUMBER, throttle.getReqNum()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
38 changes: 36 additions & 2 deletions hbase-server/src/main/resources/hbase-webapps/master/table.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -358,6 +358,40 @@ if (fqtn != null && master.isInitialized()) {
</tr>
<%
}
if (quota.hasThrottle()) {
List<ThrottleSettings> throttles = QuotaSettingsFactory.fromTableThrottles(table.getName(), quota.getThrottle());
if (throttles.size() > 0) {
%>
<tr>
<td>Throttle Quota</td>
<td>
<table>
<tr>
<th>Limit</th>
<th>Type</th>
<th>TimeUnit</th>
<th>Scope</th>
</tr>
<%
for (ThrottleSettings throttle : throttles) {
%>
<tr>
<td><%= throttle.getSoftLimit() %></td>
<td><%= throttle.getThrottleType() %></td>
<td><%= throttle.getTimeUnit() %></td>
<td><%= throttle.getQuotaScope() %></td>
</tr>
<%
}
%>
</table>
</td>
<td>Information about a Throttle Quota on this table, if set.</td>
</tr>
<%
}
}
}
%>
</table>
Expand Down

0 comments on commit 4888d54

Please sign in to comment.