Tarun-kishore commented on code in PR #20235:
URL: https://github.com/apache/pinot/pull/20235#discussion_r4546376555


##########
pinot-broker/src/main/java/org/apache/pinot/broker/queryquota/HelixExternalViewBasedQueryQuotaManager.java:
##########
@@ -206,9 +208,38 @@ public void initOrUpdateTableQueryQuota(TableConfig 
tableConfig, ExternalView br
     String tableNameWithType = tableConfig.getTableName();
     LOGGER.info("Initializing rate limiter for table {}", tableNameWithType);
 
-    // Create rate limiter if query quota config is specified.
+    // Create rate limiter if query quota config is specified, by the table or 
its broker tenant.
     Stat stat = 
_propertyStore.getStat(constructTableConfigPath(tableNameWithType), 
AccessOption.PERSISTENT);
-    createOrUpdateRateLimiter(tableNameWithType, brokerResourceEV, 
tableConfig.getQuotaConfig(), stat);
+    createOrUpdateRateLimiter(tableNameWithType, brokerResourceEV, 
getEffectiveQuotaConfig(tableConfig), stat);
+  }
+
+  /// Rebuilds the rate limiters of the tables on the given broker tenant 
served by this broker, after the quota
+  /// defaults of the tenant changed. Tenant quota defaults do not change the 
table config stat version, so this must be
+  /// triggered explicitly (by a tenant config refresh message).
+  /// @param tenantName name of the tenant whose quota defaults changed.
+  public void refreshTenantQueryQuotas(String tenantName) {
+    ExternalView brokerResourceEV = getBrokerResource();
+    int numRefreshed = 0;
+    for (String physicalOrLogicalTableName : new 
ArrayList<>(_rateLimiterMap.keySet())) {
+      if 
(TableNameBuilder.getTableTypeFromTableName(physicalOrLogicalTableName) == 
null) {
+        // Logical tables do not inherit tenant quota defaults
+        continue;
+      }
+      TableConfig tableConfig = 
ZKMetadataProvider.getTableConfig(_propertyStore, physicalOrLogicalTableName);
+      if (tableConfig != null && 
QuotaConfigUtils.getBrokerTenantName(tableConfig).equals(tenantName)) {
+        initOrUpdateTableQueryQuota(tableConfig, brokerResourceEV);
+        numRefreshed++;
+      }
+    }
+    LOGGER.info("Refreshed query rate limiters of {} tables after quota 
defaults of tenant: {} changed", numRefreshed,
+        tenantName);
+  }
+
+  /// Returns the table's quota config with unset fields filled from the quota 
defaults of its tenants.
+  @Nullable
+  private QuotaConfig getEffectiveQuotaConfig(TableConfig tableConfig) {
+    return QuotaConfigUtils.getEffectiveQuotaConfig(tableConfig,
+        tenantName -> ZKMetadataProvider.getTenantQuotaConfig(_propertyStore, 
tenantName));

Review Comment:
   Done. The lookups are now per role: the controller reads only server tenant 
defaults and the broker only broker tenant defaults.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to