From 17ea99c83dac5f0c946b0b5be90ebc3aa44564ba Mon Sep 17 00:00:00 2001 From: meiyi Date: Mon, 3 Jun 2019 16:55:23 +0800 Subject: [PATCH] HBASE-22513 Admin#getQuota does not work correctly if exceedThrottleQuota is set --- .../java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java | 6 ++++++ .../java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java | 1 + 2 files changed, 7 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java index d8dd50b94ca..a48ce71d607 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/quotas/QuotaRetriever.java @@ -26,6 +26,7 @@ import java.util.Objects; import java.util.Queue; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.util.Bytes; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -102,6 +103,11 @@ public class QuotaRetriever implements Closeable, Iterable { public QuotaSettings next() throws IOException { if (cache.isEmpty()) { Result result = scanner.next(); + // Skip exceedThrottleQuota row key because this is not a QuotaSettings + if (result != null + && Bytes.equals(result.getRow(), QuotaTableUtil.getExceedThrottleQuotaRowKey())) { + result = scanner.next(); + } if (result == null) { return null; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java index 6c5ebdf72db..0045ec8f825 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java @@ -636,6 +636,7 @@ public class TestQuotaAdmin { assertTrue(admin.exceedThrottleQuotaSwitch(true)); assertTrue(admin.exceedThrottleQuotaSwitch(false)); assertFalse(admin.exceedThrottleQuotaSwitch(false)); + assertEquals(2, admin.getQuota(new QuotaFilter()).size()); admin.setQuota(QuotaSettingsFactory.unthrottleRegionServer(regionServer)); }