Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;
Expand Down Expand Up @@ -137,51 +138,79 @@ private static void triggerCacheRefresh(HBaseTestingUtil testUtil, boolean bypas
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()));
Expand Down