cmccabe commented on code in PR #14719: URL: https://github.com/apache/kafka/pull/14719#discussion_r1394827643
########## core/src/main/scala/kafka/server/metadata/ZkMetadataCache.scala: ########## @@ -55,6 +56,64 @@ trait ZkFinalizedFeatureCache { def getFeatureOption: Option[Features] } +case class MetadataSnapshot(partitionStates: mutable.AnyRefMap[String, mutable.LongMap[UpdateMetadataPartitionState]], + topicIds: Map[String, Uuid], + controllerId: Option[CachedControllerId], + aliveBrokers: mutable.LongMap[Broker], + aliveNodes: mutable.LongMap[collection.Map[ListenerName, Node]]) { + val topicNames: Map[Uuid, String] = topicIds.map { case (topicName, topicId) => (topicId, topicName) } +} + +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. + */ + def maybeInjectDeletedPartitions( + currentMetadata: MetadataSnapshot, + updateMetadataRequest: UpdateMetadataRequest + ): Seq[Uuid] = { + if (updateMetadataRequest.isKRaftController && updateMetadataRequest.updateType() == AbstractControlRequest.Type.FULL) { Review Comment: This seems to duplicate the check below, where we only invoke this function if `updateType == FULL`. If we are going to check this here (not sure if we even should) seems like we should just throw an exception if `updateType != FULL` here? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org