You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by rm...@apache.org on 2025/05/01 12:16:16 UTC
(hbase) 01/01: HBASE-29281 Atomic request throttles are missing QuotaSettingsFactory support (#6953)
This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a commit to branch HBASE-29281-branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 2e0cc5eebbe5279c09915a5dfb6dea3ee68e23c5
Author: Ray Mattingly <rm...@apache.org>
AuthorDate: Thu May 1 08:03:04 2025 -0400
HBASE-29281 Atomic request throttles are missing QuotaSettingsFactory support (#6953)
Co-authored-by: Ray Mattingly <rm...@hubspot.com>
Signed-off-by: Nick Dimiduk <nd...@apache.org>
---
.../hadoop/hbase/quotas/QuotaSettingsFactory.java | 12 +++++++
.../hadoop/hbase/quotas/TestQuotaThrottle.java | 38 ++++++++++++++++++++++
2 files changed, 50 insertions(+)
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 1f3ebc7c07d..67f85da1d51 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
@@ -168,6 +168,18 @@ public class QuotaSettingsFactory {
settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer,
ThrottleType.WRITE_CAPACITY_UNIT, throttle.getWriteCapacityUnit()));
}
+ if (throttle.hasAtomicReadSize()) {
+ settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer,
+ ThrottleType.ATOMIC_READ_SIZE, throttle.getAtomicReadSize()));
+ }
+ if (throttle.hasAtomicWriteSize()) {
+ settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer,
+ ThrottleType.ATOMIC_WRITE_SIZE, throttle.getAtomicWriteSize()));
+ }
+ if (throttle.hasAtomicReqNum()) {
+ settings.add(ThrottleSettings.fromTimedQuota(userName, tableName, namespace, regionServer,
+ ThrottleType.ATOMIC_REQUEST_NUMBER, throttle.getAtomicReqNum()));
+ }
return settings;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
index 5a47572570c..391b7a08869 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java
@@ -26,7 +26,10 @@ import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerTableC
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerUserCacheRefresh;
import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuota;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -652,4 +655,39 @@ public class TestQuotaThrottle {
admin.setQuota(QuotaSettingsFactory.unthrottleTable(TABLE_NAMES[0]));
triggerTableCacheRefresh(TEST_UTIL, true, TABLE_NAMES[0]);
}
+
+ @Test
+ public void testSetAndGetAllThrottleTypes() throws Exception {
+ for (ThrottleType throttleType : ThrottleType.values()) {
+ canSetAndGetUserThrottle(throttleType);
+ }
+ }
+
+ private void canSetAndGetUserThrottle(ThrottleType throttleType) throws IOException {
+ final Admin admin = TEST_UTIL.getAdmin();
+ final String userName = User.getCurrent().getShortName();
+
+ QuotaSettings setQuota =
+ QuotaSettingsFactory.throttleUser(userName, throttleType, 123, TimeUnit.SECONDS);
+ admin.setQuota(setQuota);
+
+ boolean found = false;
+ List<QuotaSettings> quotaSettings = admin.getQuota(new QuotaFilter().setUserFilter(userName));
+ for (QuotaSettings settings : quotaSettings) {
+ if (settings instanceof ThrottleSettings) {
+ ThrottleSettings throttle = (ThrottleSettings) settings;
+ if (
+ userName.equals(throttle.getUserName()) && throttle.getThrottleType() == throttleType
+ && throttle.getSoftLimit() == 123 && throttle.getTimeUnit() == TimeUnit.SECONDS
+ ) {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ assertTrue("Expected to find " + throttleType.name() + " quota for user " + userName, found);
+ admin.setQuota(QuotaSettingsFactory.unthrottleUserByThrottleType(userName, throttleType));
+ }
+
}