chirag-wadhwa5 commented on code in PR #16792: URL: https://github.com/apache/kafka/pull/16792#discussion_r1708889640
########## core/src/main/scala/kafka/server/KafkaApis.scala: ########## @@ -4396,14 +4511,70 @@ class KafkaApis(val requestChannel: RequestChannel, batch.acknowledgeTypes() )) } - acknowledgeBatchesMap += topicIdPartition -> acknowledgeBatches + if (acknowledgeBatches.size() > 0) { + acknowledgeBatchesMap += topicIdPartition -> acknowledgeBatches + } } } } acknowledgeBatchesMap } - private def validateAcknowledgementBatches(acknowledgementDataFromRequest: mutable.Map[TopicIdPartition, util.List[ShareAcknowledgementBatch]], + // the callback for processing a share acknowledge response, invoked before throttling + def processShareAcknowledgeResponse(responseAcknowledgeData: Map[TopicIdPartition, ShareAcknowledgeResponseData.PartitionData], + request : RequestChannel.Request, + topicNames : util.Map[Uuid, String]): ShareAcknowledgeResponse = { + val partitions = new util.LinkedHashMap[TopicIdPartition, ShareAcknowledgeResponseData.PartitionData] + val nodeEndpoints = new mutable.HashMap[Int, Node] + responseAcknowledgeData.foreach{ case(tp, partitionData) => + partitionData.errorCode() match { + case errCode if errCode == Errors.NOT_LEADER_OR_FOLLOWER.code | errCode == Errors.FENCED_LEADER_EPOCH.code => + val leaderNode = getCurrentLeader(tp.topicPartition(), request.context.listenerName) + leaderNode.node.foreach { node => + nodeEndpoints.put(node.id(), node) + } + partitionData.currentLeader() + .setLeaderId(leaderNode.leaderId) + .setLeaderEpoch(leaderNode.leaderEpoch) + case _ => + } + partitions.put(tp, partitionData) + } + + var shareAcknowledgeResponse: ShareAcknowledgeResponse = null + + def createResponse(): ShareAcknowledgeResponse = { Review Comment: Thanks for the review. You are correct here, in fact the use of `var shareAcknowledgeResponse: ShareAcknowledgeResponse = null` is not needed entirely. I have the changes, pls let me know if anything else is needed here. Thanks ! -- 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