This is an automated email from the ASF dual-hosted git repository.

rmattingly pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 7abd663d998 HBASE-29281 Atomic request throttles are missing 
QuotaSettingsFactory support (#6953) (#6958)
7abd663d998 is described below

commit 7abd663d9987f434c1e752b6d7d993ce9f76d0d8
Author: Ray Mattingly <[email protected]>
AuthorDate: Fri May 2 11:00:20 2025 -0400

    HBASE-29281 Atomic request throttles are missing QuotaSettingsFactory 
support (#6953) (#6958)
    
    Signed-off-by: Nick Dimiduk <[email protected]>
    Co-authored-by: Ray Mattingly <[email protected]>
---
 .../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 1cfd133a5bc..5ae9de1fbf1 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.HBaseTestingUtility;
@@ -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));
+  }
+
 }

Reply via email to