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 2021/03/03 23:58:39 UTC

[GitHub] [kafka] junrao commented on a change in pull request #10184: MINOR: enable topic deletion in the KIP-500 controller

junrao commented on a change in pull request #10184:
URL: https://github.com/apache/kafka/pull/10184#discussion_r586880128



##########
File path: core/src/test/scala/unit/kafka/server/ControllerApisTest.scala
##########
@@ -18,19 +18,26 @@
 package unit.kafka.server

Review comment:
       This is an existing issue, but we don't need unit in package name.

##########
File path: metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java
##########
@@ -349,6 +359,29 @@ public void replay(PartitionChangeRecord record) {
         log.debug("Applied ISR change record: {}", record.toString());
     }
 
+    public void replay(RemoveTopicRecord record) {
+        // Remove this topic from the topics map and the topicsByName map.
+        TopicControlInfo topic = topics.remove(record.topicId());
+        if (topic == null) {
+            throw new RuntimeException("Can't find topic with ID " + record.topicId() +
+                " to remove.");
+        }
+        topicsByName.remove(topic.name);
+
+        // Delete the configurations associated with this topic.
+        configurationControl.deleteTopicConfigs(topic.name);
+
+        // Remove the entries for this topic in brokersToIsrs.
+        for (PartitionControlInfo partition : topic.parts.values()) {
+            for (int i = 0; i < partition.isr.length; i++) {
+                brokersToIsrs.removeTopicEntryForBroker(topic.id, partition.isr[i]);
+            }
+        }
+        brokersToIsrs.removeTopicEntryForBroker(topic.id, NO_LEADER);

Review comment:
       Hmm, why do we need to remove for -1 broker? It doesn't seem that brokersToIsrs tracks that.
   




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