This is an automated email from the ASF dual-hosted git repository.

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 79d2c3c62a3 KAFKA-19406 Remove 
BrokerTopicStats#removeOldFollowerMetrics (#19962)
79d2c3c62a3 is described below

commit 79d2c3c62a3a448a9aae77f3e8a549438a9ad6bd
Author: Xuan-Zhang Gong <[email protected]>
AuthorDate: Thu Jun 19 17:57:22 2025 +0800

    KAFKA-19406 Remove BrokerTopicStats#removeOldFollowerMetrics (#19962)
    
    BTW: whether we should rename
    `ReplicaManager#updateLeaderAndFollowerMetrics`
    
    Reviewers: Ken Huang <[email protected]>, PoAn Yang
     <[email protected]>, TengYao Chi <[email protected]>, Lan Ding
     <[email protected]>, Chia-Ping Tsai <[email protected]>
---
 core/src/main/scala/kafka/server/ReplicaManager.scala         |  4 +---
 .../apache/kafka/storage/log/metrics/BrokerTopicStats.java    | 11 -----------
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/core/src/main/scala/kafka/server/ReplicaManager.scala 
b/core/src/main/scala/kafka/server/ReplicaManager.scala
index 7c1b13b798c..78268af5891 100644
--- a/core/src/main/scala/kafka/server/ReplicaManager.scala
+++ b/core/src/main/scala/kafka/server/ReplicaManager.scala
@@ -2201,9 +2201,7 @@ class ReplicaManager(val config: KafkaConfig,
   private def updateLeaderAndFollowerMetrics(newFollowerTopics: Set[String]): 
Unit = {
     val leaderTopicSet = leaderPartitionsIterator.map(_.topic).toSet
     
newFollowerTopics.diff(leaderTopicSet).foreach(brokerTopicStats.removeOldLeaderMetrics)
-
-    // remove metrics for brokers which are not followers of a topic
-    
leaderTopicSet.diff(newFollowerTopics).foreach(brokerTopicStats.removeOldFollowerMetrics)
+    // Currently, there are no follower metrics that need to be updated.
   }
 
   protected[server] def maybeAddLogDirFetchers(partitions: Set[Partition],
diff --git 
a/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java
 
b/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java
index 3c6f2f909e6..ba562219fa9 100644
--- 
a/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java
+++ 
b/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java
@@ -76,8 +76,6 @@ public class BrokerTopicStats implements AutoCloseable {
             
topicMetrics.closeMetric(BrokerTopicMetrics.FAILED_PRODUCE_REQUESTS_PER_SEC);
             
topicMetrics.closeMetric(BrokerTopicMetrics.TOTAL_PRODUCE_REQUESTS_PER_SEC);
             
topicMetrics.closeMetric(BrokerTopicMetrics.PRODUCE_MESSAGE_CONVERSIONS_PER_SEC);
-            
topicMetrics.closeMetric(BrokerTopicMetrics.REPLICATION_BYTES_OUT_PER_SEC);
-            
topicMetrics.closeMetric(BrokerTopicMetrics.REASSIGNMENT_BYTES_OUT_PER_SEC);
             
topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_COPY_BYTES_PER_SEC_METRIC.getName());
             
topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_FETCH_BYTES_PER_SEC_METRIC.getName());
             
topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_FETCH_REQUESTS_PER_SEC_METRIC.getName());
@@ -99,15 +97,6 @@ public class BrokerTopicStats implements AutoCloseable {
         }
     }
 
-    // This method only removes metrics only used for follower
-    public void removeOldFollowerMetrics(String topic) {
-        BrokerTopicMetrics topicMetrics = topicStats(topic);
-        if (topicMetrics != null) {
-            
topicMetrics.closeMetric(BrokerTopicMetrics.REPLICATION_BYTES_IN_PER_SEC);
-            
topicMetrics.closeMetric(BrokerTopicMetrics.REASSIGNMENT_BYTES_IN_PER_SEC);
-        }
-    }
-
     public void removeMetrics(String topic) {
         BrokerTopicMetrics metrics = stats.remove(topic);
         if (metrics != null) {

Reply via email to