kuoche1712003 commented on code in PR #20399:
URL: https://github.com/apache/kafka/pull/20399#discussion_r2347193890
##########
core/src/main/scala/kafka/server/AbstractFetcherManager.scala:
##########
@@ -226,6 +228,10 @@ abstract class AbstractFetcherManager[T <:
AbstractFetcherThread](val name: Stri
fetcherThreadMap.clear()
}
}
+
+ def getMetricsClassName: String = {
Review Comment:
Do we really need to introduce this method just for testing purposes?
##########
core/src/test/scala/unit/kafka/server/AbstractFetcherManagerTest.scala:
##########
@@ -355,4 +356,22 @@ class AbstractFetcherManagerTest {
override protected def endOffsetForEpoch(topicPartition: TopicPartition,
epoch: Int): Optional[OffsetAndEpoch] = Optional.of(new OffsetAndEpoch(1, 0))
}
+ @Test
+ def testMetricsClassName(): Unit = {
+ val config = mock(classOf[KafkaConfig])
+ val replicaManager = mock(classOf[ReplicaManager])
+ val quotaManager = mock(classOf[ReplicationQuotaManager])
+ val brokerTopicStats = new BrokerTopicStats()
+ val directoryEventHandler = DirectoryEventHandler.NOOP
+ val metrics = new Metrics()
+ val time = new MockTime()
+ val metadataVersionSupplier = () => MetadataVersion.LATEST_PRODUCTION
+ val brokerEpochSupplier = () => 1L
+
+ val replicaAlterLogDirsManager = new ReplicaAlterLogDirsManager(config,
replicaManager, quotaManager, brokerTopicStats, directoryEventHandler)
+ val replicaFetcherManager = new ReplicaFetcherManager(config,
replicaManager, metrics, time, quotaManager, metadataVersionSupplier,
brokerEpochSupplier)
+
+ assertEquals("ReplicaAlterLogDirsManager",
replicaAlterLogDirsManager.getMetricsClassName)
+ assertEquals("ReplicaFetcherManager",
replicaFetcherManager.getMetricsClassName)
Review Comment:
Maybe you can use `KafkaYammerMetrics.defaultRegistry()` to get the target
metrics.
--
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]