gortiz commented on code in PR #14226: URL: https://github.com/apache/pinot/pull/14226#discussion_r1808259077
########## pinot-broker/src/main/java/org/apache/pinot/broker/queryquota/HelixExternalViewBasedQueryQuotaManager.java: ########## @@ -264,52 +317,109 @@ public void updateDatabaseRateLimiter(String databaseName) { createOrUpdateDatabaseRateLimiter(Collections.singletonList(databaseName)); } + /** + * Updates the application rate limiter if it already exists. It won't create a new rate limiter. + * + * @param applicationName application name for which rate limiter needs to be updated + */ + public void updateApplicationRateLimiter(String applicationName) { + if (!_applicationRateLimiterMap.containsKey(applicationName)) { + return; + } + createOrUpdateApplicationRateLimiter(applicationName); + } + // Caller method need not worry about getting lock on _databaseRateLimiterMap // as this method will do idempotent updates to the database rate limiters private synchronized void createOrUpdateDatabaseRateLimiter(List<String> databaseNames) { - ExternalView brokerResource = HelixHelper - .getExternalViewForResource(_helixManager.getClusterManagmentTool(), _helixManager.getClusterName(), - CommonConstants.Helix.BROKER_RESOURCE_INSTANCE); + ExternalView brokerResource = getBrokerResource(); for (String databaseName : databaseNames) { - double databaseQpsQuota = getEffectiveQueryQuotaOnDatabase(databaseName); - if (databaseQpsQuota < 0) { + double qpsQuota = getEffectiveQueryQuotaOnDatabase(databaseName); + if (qpsQuota < 0) { buildEmptyOrResetDatabaseRateLimiter(databaseName); continue; } int numOnlineBrokers = getNumOnlineBrokers(databaseName, brokerResource); - double perBrokerQpsQuota = databaseQpsQuota / numOnlineBrokers; - QueryQuotaEntity oldQueryQuotaEntity = _databaseRateLimiterMap.get(databaseName); - if (oldQueryQuotaEntity == null) { + double perBrokerQpsQuota = qpsQuota / numOnlineBrokers; + QueryQuotaEntity oldEntity = _databaseRateLimiterMap.get(databaseName); + if (oldEntity == null) { LOGGER.info("Adding new query rate limiter for database {} with rate {}.", databaseName, perBrokerQpsQuota); - QueryQuotaEntity queryQuotaEntity = new QueryQuotaEntity(RateLimiter.create(perBrokerQpsQuota), + QueryQuotaEntity queryQuotaEntity = new QueryQuotaEntity(createRateLimiter(perBrokerQpsQuota), new HitCounter(ONE_SECOND_TIME_RANGE_IN_SECOND), new MaxHitRateTracker(ONE_MINUTE_TIME_RANGE_IN_SECOND), - numOnlineBrokers, databaseQpsQuota, -1); + numOnlineBrokers, qpsQuota, -1); Review Comment: It looks like you are aligning these params with `new MaxHitRateTracker` instead of the other `QueryQuotaEntity` constructor arguments -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org