chia7712 commented on code in PR #18627:
URL: https://github.com/apache/kafka/pull/18627#discussion_r1927226359


##########
core/src/test/scala/unit/kafka/log/LogCleanerTest.scala:
##########
@@ -2070,18 +2071,55 @@ class LogCleanerTest extends Logging {
     cleaner3.lastStats.bufferUtilization = 0.65
     cleaners += cleaner3
 
-    assertEquals(0, 
logCleaner.maxOverCleanerThreads(_.lastStats.bufferUtilization))
+    assertEquals(0.85, 
logCleaner.maxOverCleanerThreads(_.lastStats.bufferUtilization))
+  }
+
+  @Test
+  def testMaxBufferUtilizationPercentMetric(): Unit = {

Review Comment:
   It seems this new unit test is similar to `testMaxOverCleanerThreads`, 
right? If so, could you please remove `testMaxOverCleanerThreads`?



##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -116,14 +116,14 @@ class LogCleaner(initialConfig: CleanerConfig,
 
   /**
    * @param f to compute the result
-   * @return the max value (int value) or 0 if there is no cleaner
+   * @return the max value or 0 if there is no cleaner
    */
-  private[log] def maxOverCleanerThreads(f: CleanerThread => Double): Int =
-    cleaners.map(f).maxOption.getOrElse(0.0d).toInt
+  private[log] def maxOverCleanerThreads(f: CleanerThread => Double): Double =
+    cleaners.map(f).maxOption.getOrElse(0.0d)
 
   /* a metric to track the maximum utilization of any thread's buffer in the 
last cleaning */
   metricsGroup.newGauge(MaxBufferUtilizationPercentMetricName,
-    () => maxOverCleanerThreads(_.lastStats.bufferUtilization) * 100)
+    () => (maxOverCleanerThreads(_.lastStats.bufferUtilization) * 100).toInt)

Review Comment:
   Could you please add unit test for other impacted 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]

Reply via email to