You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/12/15 06:14:00 UTC
(hbase) branch master updated: HBASE-28031 Add timeout for ThrottleQuotaTestUtil.triggerCacheRefresh (#5582)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 29cf51d8391 HBASE-28031 Add timeout for ThrottleQuotaTestUtil.triggerCacheRefresh (#5582)
29cf51d8391 is described below
commit 29cf51d8391099f5628a52d2c3306932758d4108
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Fri Dec 15 14:13:54 2023 +0800
HBASE-28031 Add timeout for ThrottleQuotaTestUtil.triggerCacheRefresh (#5582)
Signed-off-by: Bryan Beaudreault <bb...@apache.org>
---
.../hadoop/hbase/quotas/ThrottleQuotaTestUtil.java | 103 +++++++++++++--------
1 file changed, 66 insertions(+), 37 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/ThrottleQuotaTestUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/ThrottleQuotaTestUtil.java
index a6e93b663c0..de6f5653ad2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/ThrottleQuotaTestUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/ThrottleQuotaTestUtil.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Objects;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter.ExplainingPredicate;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
@@ -137,51 +138,79 @@ public final class ThrottleQuotaTestUtil {
RegionServerRpcQuotaManager quotaManager =
rst.getRegionServer().getRegionServerRpcQuotaManager();
QuotaCache quotaCache = quotaManager.getQuotaCache();
-
quotaCache.triggerCacheRefresh();
- // sleep for cache update
Thread.sleep(250);
-
- for (TableName table : tables) {
- quotaCache.getTableLimiter(table);
- }
-
- boolean isUpdated = false;
- while (!isUpdated) {
- quotaCache.triggerCacheRefresh();
- isUpdated = true;
- for (TableName table : tables) {
- boolean isBypass = true;
- if (userLimiter) {
- isBypass = quotaCache.getUserLimiter(User.getCurrent().getUGI(), table).isBypass();
+ testUtil.waitFor(60000, 250, new ExplainingPredicate<Exception>() {
+
+ @Override
+ public boolean evaluate() throws Exception {
+ boolean isUpdated = true;
+ for (TableName table : tables) {
+ if (userLimiter) {
+ boolean isUserBypass =
+ quotaCache.getUserLimiter(User.getCurrent().getUGI(), table).isBypass();
+ if (isUserBypass != bypass) {
+ LOG.info(
+ "User limiter for user={}, table={} not refreshed, bypass expected {}, actual {}",
+ User.getCurrent(), table, bypass, isUserBypass);
+ envEdge.incValue(100);
+ isUpdated = false;
+ break;
+ }
+ }
+ if (tableLimiter) {
+ boolean isTableBypass = quotaCache.getTableLimiter(table).isBypass();
+ if (isTableBypass != bypass) {
+ LOG.info("Table limiter for table={} not refreshed, bypass expected {}, actual {}",
+ table, bypass, isTableBypass);
+ envEdge.incValue(100);
+ isUpdated = false;
+ break;
+ }
+ }
+ if (nsLimiter) {
+ boolean isNsBypass =
+ quotaCache.getNamespaceLimiter(table.getNamespaceAsString()).isBypass();
+ if (isNsBypass != bypass) {
+ LOG.info(
+ "Namespace limiter for namespace={} not refreshed, bypass expected {}, actual {}",
+ table.getNamespaceAsString(), bypass, isNsBypass);
+ envEdge.incValue(100);
+ isUpdated = false;
+ break;
+ }
+ }
}
- if (tableLimiter) {
- isBypass &= quotaCache.getTableLimiter(table).isBypass();
+ if (rsLimiter) {
+ boolean rsIsBypass = quotaCache
+ .getRegionServerQuotaLimiter(QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY).isBypass();
+ if (rsIsBypass != bypass) {
+ LOG.info("RegionServer limiter not refreshed, bypass expected {}, actual {}", bypass,
+ rsIsBypass);
+ envEdge.incValue(100);
+ isUpdated = false;
+ }
}
- if (nsLimiter) {
- isBypass &= quotaCache.getNamespaceLimiter(table.getNamespaceAsString()).isBypass();
+ if (exceedThrottleQuota) {
+ if (quotaCache.isExceedThrottleQuotaEnabled() != bypass) {
+ LOG.info("ExceedThrottleQuotaEnabled not refreshed, bypass expected {}, actual {}",
+ bypass, quotaCache.isExceedThrottleQuotaEnabled());
+ envEdge.incValue(100);
+ isUpdated = false;
+ }
}
- if (isBypass != bypass) {
- envEdge.incValue(100);
- isUpdated = false;
- break;
+ if (isUpdated) {
+ return true;
}
+ quotaCache.triggerCacheRefresh();
+ return false;
}
- if (rsLimiter) {
- boolean rsIsBypass = quotaCache
- .getRegionServerQuotaLimiter(QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY).isBypass();
- if (rsIsBypass != bypass) {
- envEdge.incValue(100);
- isUpdated = false;
- }
- }
- if (exceedThrottleQuota) {
- if (quotaCache.isExceedThrottleQuotaEnabled() != bypass) {
- envEdge.incValue(100);
- isUpdated = false;
- }
+
+ @Override
+ public String explainFailure() throws Exception {
+ return "Quota cache is still not refreshed";
}
- }
+ });
LOG.debug("QuotaCache");
LOG.debug(Objects.toString(quotaCache.getNamespaceQuotaCache()));