jackjlli commented on a change in pull request #6898:
URL: https://github.com/apache/incubator-pinot/pull/6898#discussion_r630568935



##########
File path: 
pinot-broker/src/main/java/org/apache/pinot/broker/queryquota/HelixExternalViewBasedQueryQuotaManager.java
##########
@@ -194,15 +195,30 @@ private void createRateLimiter(String tableNameWithType, 
ExternalView brokerReso
     // Get stat from property store
     String tableConfigPath = constructTableConfigPath(tableNameWithType);
     Stat stat = _propertyStore.getStat(tableConfigPath, 
AccessOption.PERSISTENT);
-
     double perBrokerRate = overallRate / onlineCount;
-    QueryQuotaEntity queryQuotaEntity =
-        new QueryQuotaEntity(RateLimiter.create(perBrokerRate), new 
HitCounter(ONE_SECOND_TIME_RANGE_IN_SECOND),
-            new MaxHitRateTracker(ONE_MINUTE_TIME_RANGE_IN_SECOND), 
onlineCount, overallRate, stat.getVersion());
-    _rateLimiterMap.put(tableNameWithType, queryQuotaEntity);
-    LOGGER.info(
-        "Rate limiter for table: {} has been initialized. Overall rate: {}. 
Per-broker rate: {}. Number of online broker instances: {}. Table config stat 
version: {}",
-        tableNameWithType, overallRate, perBrokerRate, onlineCount, 
stat.getVersion());
+
+    QueryQuotaEntity queryQuotaEntity = _rateLimiterMap.get(tableNameWithType);
+    if (queryQuotaEntity == null) {
+      queryQuotaEntity =
+          new QueryQuotaEntity(RateLimiter.create(perBrokerRate), new 
HitCounter(ONE_SECOND_TIME_RANGE_IN_SECOND),
+              new MaxHitRateTracker(ONE_MINUTE_TIME_RANGE_IN_SECOND), 
onlineCount, overallRate, stat.getVersion());
+      _rateLimiterMap.put(tableNameWithType, queryQuotaEntity);
+      LOGGER.info(
+          "Rate limiter for table: {} has been initialized. Overall rate: {}. 
Per-broker rate: {}. Number of online broker instances: {}. Table config stat 
version: {}",
+          tableNameWithType, overallRate, perBrokerRate, onlineCount, 
stat.getVersion());
+    } else {
+      queryQuotaEntity.getRateLimiter().setRate(perBrokerRate);
+      queryQuotaEntity.setNumOnlineBrokers(onlineCount);
+      queryQuotaEntity.setOverallRate(overallRate);
+      queryQuotaEntity.setTableConfigStatVersion(stat.getVersion());
+      LOGGER.info(
+          "Rate limiter for table: {} has been updated. Overall rate: {}. 
Per-broker rate: {}. Number of online broker instances: {}. Table config stat 
version: {}",
+          tableNameWithType, overallRate, perBrokerRate, onlineCount, 
stat.getVersion());
+    }
+
+    final QueryQuotaEntity finalQueryQuotaEntity = queryQuotaEntity;
+    _brokerMetrics.addCallbackTableGaugeIfNeeded(tableNameWithType, 
BrokerGauge.MAX_BURST_QPS,

Review comment:
       I think your question is more on why callback gauge is used instead of a 
regular gauge?
   The purpose of using callback gauge is that the value is not directly set 
into the metric system but instead calculated from a object (in this case it's 
`(long) finalQueryQuotaEntity.getMaxQpsTracker().getMaxCountPerBucket()`).
   That's why we need a call back gauge here.




-- 
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.

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

Reply via email to