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


##########
core/src/main/scala/kafka/server/ClientQuotaManager.scala:
##########
@@ -451,6 +451,37 @@ class ClientQuotaManager(private val config: 
ClientQuotaManagerConfig,
     }
   }
 
+  /**
+   * 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(): Unit = {
+    quotaTypesEnabled =  if (clientQuotaCallbackPlugin.isDefined) {
+        QuotaTypes.CustomQuotas
+      } else {
+        QuotaTypes.NoQuotas
+      }
+
+    activeQuotaEntities.forEach { (entity, _) =>
+      entity match {
+        case KafkaQuotaEntity(Some(_), Some(_)) =>
+          quotaTypesEnabled |= QuotaTypes.UserClientIdQuotaEnabled
+        case KafkaQuotaEntity(Some(_), None) =>
+          quotaTypesEnabled |= QuotaTypes.UserQuotaEnabled
+        case KafkaQuotaEntity(None, Some(_)) =>
+          quotaTypesEnabled |= QuotaTypes.ClientIdQuotaEnabled
+        case _ => // Unexpected entity type
+      }
+    }
+
+    val activeEntities = if (activeQuotaEntities.isEmpty) "No active quota 
entities" else activeQuotaEntities.keys.asScala.map(_.toString).mkString(", ")
+    info(s"Quota types enabled changed to $quotaTypesEnabled with active quota 
entities: [$activeEntities]")

Review Comment:
   Here are a few examples of these logs. They show the number as well as the 
active quota types and names.
   
   - `[2025-05-26 16:52:45,304] INFO Quota types enabled changed to 5 with 
active quota entities: [client-id test-client, default client-id, default user 
client-id default]`
   - `[2025-05-26 16:55:55,669] INFO Quota types enabled changed to 0 with 
active quota entities: [No active quota entities]`
   - `[2025-05-26 16:53:16,833] INFO Quota types enabled changed to 7 with 
active quota entities: [default user, default client-id, default user client-id 
default] (kafka.server.ControllerMutationQuotaManager)`
   
   



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