You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/07/22 18:23:55 UTC

[GitHub] [kafka] bob-barrett commented on a change in pull request #9054: KAFKA-10282: Remove Log metrics immediately when deleting log

bob-barrett commented on a change in pull request #9054:
URL: https://github.com/apache/kafka/pull/9054#discussion_r458994628



##########
File path: core/src/test/scala/unit/kafka/log/LogManagerTest.scala
##########
@@ -563,4 +565,39 @@ class LogManagerTest {
     logManager.topicConfigUpdated("test-topic")
     assertTrue(logManager.partitionsInitializing.isEmpty)
   }
+
+  @Test
+  def testMetricsExistWhenLogIsRecreatedBeforeDeletion(): Unit = {
+    val topicName = "metric-test"
+    def logMetrics = KafkaYammerMetrics.defaultRegistry.allMetrics.keySet.asScala.
+      filter(_.getType == "Log").filter(_.getScope.contains(topicName))
+
+    val tp = new TopicPartition(topicName, 0)
+    logManager.getOrCreateLog(tp, () => logConfig)
+
+    val metricTag = s"topic=${tp.topic},partition=${tp.partition}"
+
+    assertEquals(LogMetricNames.allMetricNames.size, logMetrics.size)
+    logMetrics.foreach { metric =>
+      assertTrue(metric.getMBeanName.contains(metricTag))
+    }
+
+    logManager.asyncDelete(tp)
+
+    assertTrue(logMetrics.isEmpty)
+
+    logManager.getOrCreateLog(tp, () => logConfig)
+
+    assertEquals(LogMetricNames.allMetricNames.size, logMetrics.size)
+    logMetrics.foreach { metric =>
+      assertTrue(metric.getMBeanName.contains(metricTag))
+    }
+
+    time.sleep(logConfig.fileDeleteDelayMs + 1)

Review comment:
       It causes enough "time" to elapse that the actual file deletion is triggered. Having it here tests that we still have metrics after the deletion occurs.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org