Skip to content

Commit 33befbf

Browse files
committed
HBASE-22878 Show table throttle quotas in table jsp
1 parent 7697d48 commit 33befbf

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/ThrottleSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
@InterfaceAudience.Private
3434
@InterfaceStability.Evolving
35-
class ThrottleSettings extends QuotaSettings {
35+
public class ThrottleSettings extends QuotaSettings {
3636
final QuotaProtos.ThrottleRequest proto;
3737

3838
ThrottleSettings(final String userName, final TableName tableName, final String namespace,

hbase-server/src/main/resources/hbase-webapps/master/table.jsp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
<%@page import="java.net.URLEncoder"%>
2121
<%@ page contentType="text/html;charset=UTF-8"
2222
import="static org.apache.commons.lang3.StringEscapeUtils.escapeXml"
23+
import="java.io.IOException"
2324
import="java.util.ArrayList"
2425
import="java.util.Collection"
25-
import="java.util.Collections"
2626
import="java.util.HashMap"
2727
import="java.util.LinkedHashMap"
2828
import="java.util.List"
2929
import="java.util.Map"
30-
import="java.util.Objects"
3130
import="java.util.TreeMap"
3231
import=" java.util.concurrent.TimeUnit"
3332
import="org.apache.commons.lang3.StringEscapeUtils"
@@ -51,8 +50,12 @@
5150
import="org.apache.hadoop.hbase.master.HMaster"
5251
import="org.apache.hadoop.hbase.master.assignment.RegionStates"
5352
import="org.apache.hadoop.hbase.master.RegionState"
53+
import="org.apache.hadoop.hbase.quotas.QuotaFilter"
54+
import="org.apache.hadoop.hbase.quotas.QuotaRetriever"
55+
import="org.apache.hadoop.hbase.quotas.QuotaSettings"
5456
import="org.apache.hadoop.hbase.quotas.QuotaTableUtil"
5557
import="org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot"
58+
import="org.apache.hadoop.hbase.quotas.ThrottleSettings"
5659
import="org.apache.hadoop.hbase.util.Bytes"
5760
import="org.apache.hadoop.hbase.util.FSUtils"
5861
import="org.apache.hadoop.hbase.zookeeper.MetaTableLocator"
@@ -77,6 +80,20 @@
7780
setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME).
7881
setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build());
7982
}
83+
84+
private List<ThrottleSettings> getThrottles(Configuration conf, QuotaFilter filter)
85+
throws IOException {
86+
List<ThrottleSettings> throttles = new ArrayList<>();
87+
try (QuotaRetriever scanner = QuotaRetriever.open(conf, filter)) {
88+
for (QuotaSettings quota : scanner) {
89+
if (quota instanceof ThrottleSettings) {
90+
ThrottleSettings throttle = (ThrottleSettings) quota;
91+
throttles.add(throttle);
92+
}
93+
}
94+
}
95+
return throttles;
96+
}
8097
%>
8198
<%
8299
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
@@ -356,6 +373,37 @@ if (fqtn != null && master.isInitialized()) {
356373
</td>
357374
<td>Information about a Space Quota on this table, if set.</td>
358375
</tr>
376+
<%
377+
}
378+
379+
List<ThrottleSettings> throttles = new ArrayList<>();
380+
throttles.addAll(getThrottles(conf, new QuotaFilter().setTableFilter(tn.getNameAsString())));
381+
throttles.addAll(getThrottles(conf, new QuotaFilter().setUserFilter(".*")
382+
.setTableFilter(tn.getNameAsString())));
383+
if (throttles.size() > 0) {
384+
%>
385+
<tr>
386+
<td>Throttle Quota</td>
387+
<td>
388+
<table>
389+
<tr>
390+
<th>User</th>
391+
<th>Throttle</th>
392+
</tr>
393+
<%
394+
for (ThrottleSettings throttle : throttles) {
395+
%>
396+
<tr>
397+
<td><%= throttle.getUserName() == null ? "" : throttle.getUserName()%></td>
398+
<td><%= throttle.toString() %></td>
399+
</tr>
400+
<%
401+
}
402+
%>
403+
</table>
404+
</td>
405+
<td>Information about a Throttle Quota on this table, if set.</td>
406+
</tr>
359407
<%
360408
}
361409
}

0 commit comments

Comments
 (0)