shounakmk219 commented on code in PR #13544: URL: https://github.com/apache/pinot/pull/13544#discussion_r1679329428
########## pinot-broker/src/main/java/org/apache/pinot/broker/queryquota/HelixExternalViewBasedQueryQuotaManager.java: ########## @@ -230,6 +248,72 @@ private void createOrUpdateRateLimiter(String tableNameWithType, ExternalView br } } + /** + * Updates the database rate limiter if it already exists. Will not create a new database rate limiter. + * @param databaseName database name for which rate limiter needs to be updated + */ + public void updateDatabaseRateLimiter(String databaseName) { + if (!_databaseRateLimiterMap.containsKey(databaseName)) { + return; + } + createOrUpdateDatabaseRateLimiter(Collections.singletonList(databaseName)); + } + + private void createOrUpdateDatabaseRateLimiter(List<String> databaseNames) { + double databaseQpsQuota = _defaultQpsQuotaForDatabase; + ExternalView brokerResource = HelixHelper + .getExternalViewForResource(_helixManager.getClusterManagmentTool(), _helixManager.getClusterName(), + CommonConstants.Helix.BROKER_RESOURCE_INSTANCE); + // Tables in database can span across broker tags as we don't maintain a broker tag to database mapping as of now. + // Hence, we consider all online brokers for the rate distribution. + int onlineBrokers = HelixHelper.getOnlineInstanceFromExternalView(brokerResource).size(); + for (String databaseName : databaseNames) { + DatabaseConfig databaseConfig = + ZKMetadataProvider.getDatabaseConfig(_helixManager.getHelixPropertyStore(), databaseName); + if (databaseConfig != null && databaseConfig.getQuotaConfig() != null + && databaseConfig.getQuotaConfig().getMaxQPS() != -1) { + databaseQpsQuota = databaseConfig.getQuotaConfig().getMaxQPS(); + } + if (databaseQpsQuota < 0) { + buildEmptyOrResetRateLimiterInDatabaseQueryQuotaEntity(databaseName); + continue; + } + double perBrokerQpsQuota = databaseQpsQuota / onlineBrokers; Review Comment: Yes that's correct @vrajat -- 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