MahsaSeifikar commented on code in PR #19742:
URL: https://github.com/apache/kafka/pull/19742#discussion_r2107467714


##########
core/src/main/scala/kafka/server/ClientQuotaManager.scala:
##########
@@ -453,40 +452,34 @@ class ClientQuotaManager(private val config: 
ClientQuotaManagerConfig,
   }
 
   /**
-   * Helper method to update quota types counts and quotaTypesEnabled flag.
-   * @param quotaTypeKey The QuotaTypes constant (e.g., 
QuotaTypes.UserClientIdQuotaEnabled)
-   * @param increment True to increment count, false to decrement
+   * Helper method to update quotaTypesEnabled which is a bitwise OR 
combination of the enabled quota types.
+   * For example:
+   *  - If UserQuotaEnabled = 2 and ClientIdQuotaEnabled = 1, then 
quotaTypesEnabled = 3 (2 | 1 = 3)
+   *  - If UserClientIdQuotaEnabled = 4 and UserQuotaEnabled = 1, then 
quotaTypesEnabled =  (4 | 1 = 5)
+   *  - If UserClientIdQuotaEnabled = 4 and ClientIdQuotaEnabled = 2, then 
quotaTypesEnabled = 6 (4 | 2 = 6)
+   *  - If all three are enabled (1 | 2 | 4), then quotaTypesEnabled = 7
    */
-  private def updateQuotaTypes(quotaTypeKey: Int, increment: Boolean): Unit = {
-    if (quotaTypeKey == QuotaTypes.NoQuotas) {
-      return
-    }
-    val previousQuotaTypesEnabled = quotaTypesEnabled
-
-    // Update activeQuotaTypes counts
-    activeQuotaTypes.compute(quotaTypeKey, (_, count) =>
-      if (increment) Option(count).getOrElse(0) + 1
-      else if (Option(count).exists(_ > 1)) count - 1
-      else 0
-    )
+  private def updateQuotaTypes(): Unit = {
+    quotaTypesEnabled =  if (clientQuotaCallbackPlugin.isDefined) {
+        QuotaTypes.CustomQuotas

Review Comment:
   Based on 
[KIP-257](https://cwiki.apache.org/confluence/display/KAFKA/KIP-257+-+Configurable+Quota+Management),
 `CustomQuotas` type is used when a custom `ClientQuotaCallback` is configured 
which can be done by setting `client.quota.callback.class` to a user-defined 
class, such as 
[GroupedUserQuotaCallback](https://github.com/apache/kafka/blob/trunk/core/src/test/scala/integration/kafka/api/CustomQuotaCallbackTest.scala).
 By default,  DefaultQuotaCallback is used which supports quotas based on user, 
client-id, or (user, client-d). A custom callback controls which quota-related 
information such as user or client-id is included in metric tags through 
`quotaMetricTags` method.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to