Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagediff
titleAdd new method to ClientQuotaCallackHandlerClientQuotaCallack.java
@@ -101,13 +114,82 @@ public interface ClientQuotaCallback extends Configurable {
      * This is useful if quota computation takes partitions into account.
      * Topics that are being deleted will not be included in `cluster`.
      *
+     * @deprecated please use {@link ClientQuotaCallback#updateClusterMetadata(ClusterMetadata)} instead
      * @param cluster Cluster metadata including partitions and their leaders if known
      * @return true if quotas have changed and metric configs may need to be updated
      */
+    @Deprecated
     boolean updateClusterMetadata(Cluster cluster);

+    /**
+     * This callback is invoked whenever there are changes in the cluster metadata, such as
+     * brokers being added or removed, topics being created or deleted, or partition leadership updates.
+     * This is useful if quota computation takes partitions into account.
+     * Topics that are being deleted will not be included in `cluster`.
+     *
+     * @param clusterMetadata Cluster metadata including partitions and their leaders if known
+     * @return true if quotas have changed and metric configs may need to be updated
+     */
+    default boolean updateClusterMetadata(ClusterMetadata clusterMetadata) {
+        return updateClusterMetadata(toCluster(clusterMetadata));
+    }
+
     /**
      * Closes this instance.
      */
     void close();
+
+    static Cluster toCluster(ClusterMetadata clusterMetadata) {
+        // ... skip the implementation here ...
+    }

...