UserQuotaState userQuotaState = quotaCache.getUserQuotaState(ugi); QuotaLimiter userLimiter = userQuotaState.getTableLimiter(table); boolean useNoop = userLimiter.isBypass(); QuotaLimiter nsLimiter = quotaCache.getNamespaceLimiter(table.getNamespaceAsString()); QuotaLimiter tableLimiter = quotaCache.getTableLimiter(table); QuotaLimiter rsLimiter = quotaCache .getRegionServerQuotaLimiter(QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY); useNoop &= tableLimiter.isBypass() && nsLimiter.isBypass() && rsLimiter.isBypass(); if (LOG.isTraceEnabled()) {
public void start(final RpcScheduler rpcScheduler) throws IOException { if (!QuotaUtil.isQuotaEnabled(rsServices.getConfiguration())) { LOG.info("Quota support disabled"); return; } LOG.info("Initializing RPC quota support"); // Initialize quota cache quotaCache = new QuotaCache(rsServices); quotaCache.start(); rpcThrottleEnabled = rpcThrottleStorage.isRpcThrottleEnabled(); LOG.info("Start rpc quota manager and rpc throttle enabled is {}", rpcThrottleEnabled); }
/** * Returns the limiter associated to the specified namespace. * * @param namespace the namespace to limit * @return the limiter associated to the specified namespace */ public QuotaLimiter getNamespaceLimiter(final String namespace) { return getQuotaState(this.namespaceQuotaCache, namespace).getGlobalLimiter(); }
QuotaCache quotaCache = quotaManager.getQuotaCache(); quotaCache.triggerCacheRefresh(); quotaCache.getTableLimiter(table); quotaCache.triggerCacheRefresh(); isUpdated = true; for (TableName table: tables) { boolean isBypass = true; if (userLimiter) { isBypass &= quotaCache.getUserLimiter(User.getCurrent().getUGI(), table).isBypass(); isBypass &= quotaCache.getTableLimiter(table).isBypass(); isBypass &= quotaCache.getNamespaceLimiter(table.getNamespaceAsString()).isBypass(); .getRegionServerQuotaLimiter(QuotaTableUtil.QUOTA_REGION_SERVER_ROW_KEY) .isBypass(); LOG.debug(Objects.toString(quotaCache.getNamespaceQuotaCache())); LOG.debug(Objects.toString(quotaCache.getTableQuotaCache())); LOG.debug(Objects.toString(quotaCache.getUserQuotaCache())); LOG.debug(Objects.toString(quotaCache.getRegionServerQuotaCache()));
QuotaCache quotaCache = quotaManager.getQuotaCache(); quotaCache.triggerCacheRefresh(); quotaCache.getTableLimiter(table); quotaCache.triggerCacheRefresh(); isUpdated = true; for (TableName table: tables) { boolean isBypass = true; if (userLimiter) { isBypass &= quotaCache.getUserLimiter(User.getCurrent().getUGI(), table).isBypass(); isBypass &= quotaCache.getTableLimiter(table).isBypass(); isBypass &= quotaCache.getNamespaceLimiter(table.getNamespaceAsString()).isBypass(); LOG.debug(Objects.toString(quotaCache.getNamespaceQuotaCache())); LOG.debug(Objects.toString(quotaCache.getTableQuotaCache())); LOG.debug(Objects.toString(quotaCache.getUserQuotaCache()));
UserQuotaState userQuotaState = quotaCache.getUserQuotaState(ugi); QuotaLimiter userLimiter = userQuotaState.getTableLimiter(table); boolean useNoop = userLimiter.isBypass(); QuotaLimiter nsLimiter = quotaCache.getNamespaceLimiter(table.getNamespaceAsString()); QuotaLimiter tableLimiter = quotaCache.getTableLimiter(table); useNoop &= tableLimiter.isBypass() && nsLimiter.isBypass(); if (LOG.isTraceEnabled()) {
getQuotaCache().triggerCacheRefresh(); Thread.sleep(1000);
public void stop() { if (isQuotaEnabled()) { quotaCache.stop("shutdown"); } }
/** * Returns the limiter associated to the specified user/table. * * @param ugi the user to limit * @param table the table to limit * @return the limiter associated to the specified user/table */ public QuotaLimiter getUserLimiter(final UserGroupInformation ugi, final TableName table) { if (table.isSystemTable()) { return NoopQuotaLimiter.get(); } return getUserQuotaState(ugi).getTableLimiter(table); }
/** * Returns the QuotaState requested. If the quota info is not in cache an empty one will be * returned and the quota request will be enqueued for the next cache refresh. */ private <K> QuotaState getQuotaState(final ConcurrentHashMap<K, QuotaState> quotasMap, final K key) { QuotaState quotaInfo = quotasMap.get(key); if (quotaInfo == null) { quotaInfo = new QuotaState(); if (quotasMap.putIfAbsent(key, quotaInfo) == null) { triggerCacheRefresh(); } } return quotaInfo; }
public void stop() { if (isQuotaEnabled()) { quotaCache.stop("shutdown"); } }
/** * Returns the limiter associated to the specified user/table. * @param ugi the user to limit * @param table the table to limit * @return the limiter associated to the specified user/table */ public QuotaLimiter getUserLimiter(final UserGroupInformation ugi, final TableName table) { if (table.isSystemTable()) { return NoopQuotaLimiter.get(); } return getUserQuotaState(ugi).getTableLimiter(table); }
public void start(final RpcScheduler rpcScheduler) throws IOException { if (!QuotaUtil.isQuotaEnabled(rsServices.getConfiguration())) { LOG.info("Quota support disabled"); return; } LOG.info("Initializing quota support"); // Initialize quota cache quotaCache = new QuotaCache(rsServices); quotaCache.start(); }
/** * Returns the limiter associated to the specified table. * * @param table the table to limit * @return the limiter associated to the specified table */ public QuotaLimiter getTableLimiter(final TableName table) { return getQuotaState(this.tableQuotaCache, table).getGlobalLimiter(); }
/** * Returns the QuotaState associated to the specified user. * @param ugi the user * @return the quota info associated to specified user */ public UserQuotaState getUserQuotaState(final UserGroupInformation ugi) { String key = ugi.getShortUserName(); UserQuotaState quotaInfo = userQuotaCache.get(key); if (quotaInfo == null) { quotaInfo = new UserQuotaState(); if (userQuotaCache.putIfAbsent(key, quotaInfo) == null) { triggerCacheRefresh(); } } return quotaInfo; }
/** * Returns the limiter associated to the specified region server. * * @param regionServer the region server to limit * @return the limiter associated to the specified region server */ public QuotaLimiter getRegionServerQuotaLimiter(final String regionServer) { return getQuotaState(this.regionServerQuotaCache, regionServer).getGlobalLimiter(); }
getQuotaCache().triggerCacheRefresh(); Thread.sleep(1000);
/** * Returns the limiter associated to the specified table. * @param table the table to limit * @return the limiter associated to the specified table */ public QuotaLimiter getTableLimiter(final TableName table) { return getQuotaState(this.tableQuotaCache, table).getGlobalLimiter(); }
/** * Returns the limiter associated to the specified namespace. * @param namespace the namespace to limit * @return the limiter associated to the specified namespace */ public QuotaLimiter getNamespaceLimiter(final String namespace) { return getQuotaState(this.namespaceQuotaCache, namespace).getGlobalLimiter(); }