cmccabe commented on code in PR #15293:
URL: https://github.com/apache/kafka/pull/15293#discussion_r1475200369


##########
core/src/main/scala/kafka/server/metadata/ZkMetadataCache.scala:
##########
@@ -65,48 +65,84 @@ case class MetadataSnapshot(partitionStates: 
mutable.AnyRefMap[String, mutable.L
 }
 
 object ZkMetadataCache {
-  /**
-   * Create topic deletions (leader=-2) for topics that are missing in a FULL 
UpdateMetadataRequest coming from a
-   * KRaft controller during a ZK migration. This will modify the 
UpdateMetadataRequest object passed into this method.
-   */
-  def maybeInjectDeletedPartitionsFromFullMetadataRequest(
+  def transformKRaftControllerFullMetadataRequest(
     currentMetadata: MetadataSnapshot,
     requestControllerEpoch: Int,
     requestTopicStates: util.List[UpdateMetadataTopicState],
-  ): Seq[Uuid] = {
-    val prevTopicIds = currentMetadata.topicIds.values.toSet
-    val requestTopics = requestTopicStates.asScala.map { topicState =>
-      topicState.topicName() -> topicState.topicId()
-    }.toMap
-
-    val deleteTopics = prevTopicIds -- requestTopics.values.toSet
-    if (deleteTopics.isEmpty) {
-      return Seq.empty
+  ): (util.List[UpdateMetadataTopicState], util.List[String]) = {
+    val topicIdToNewState = new util.HashMap[Uuid, UpdateMetadataTopicState]()
+    requestTopicStates.forEach(state => topicIdToNewState.put(state.topicId(), 
state))
+    val logMessages = new util.ArrayList[String]
+    val newRequestTopicStates = new util.ArrayList[UpdateMetadataTopicState]()
+    currentMetadata.topicNames.forKeyValue((id, name) => {

Review Comment:
   ok



##########
core/src/main/scala/kafka/server/metadata/ZkMetadataCache.scala:
##########
@@ -516,9 +587,10 @@ class ZkMetadataCache(
             if (traceEnabled)
               stateChangeLogger.trace(s"Deleted partition $tp from metadata 
cache in response to UpdateMetadata " +
                 s"request sent by controller $controllerId epoch 
$controllerEpoch with correlation id $correlationId")
-            deletedPartitions += tp
+            deletedPartitions.add(tp)
           } else {
             addOrUpdatePartitionInfo(partitionStates, tp.topic, tp.partition, 
state)
+            deletedPartitions.remove(tp)
             if (traceEnabled)

Review Comment:
   yes



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