jolshan commented on code in PR #12901:
URL: https://github.com/apache/kafka/pull/12901#discussion_r1067525498


##########
core/src/main/scala/kafka/coordinator/group/GroupCoordinatorAdapter.scala:
##########
@@ -234,4 +240,67 @@ class GroupCoordinatorAdapter(
     }
     CompletableFuture.completedFuture(results)
   }
+
+  override def commitTransactionalOffsets(
+    context: RequestContext,
+    request: TxnOffsetCommitRequestData,
+    bufferSupplier: BufferSupplier
+  ): CompletableFuture[TxnOffsetCommitResponseData] = {
+    val future = new CompletableFuture[TxnOffsetCommitResponseData]()
+
+    def callback(results: Map[TopicPartition, Errors]): Unit = {
+      val response = new TxnOffsetCommitResponseData()
+      val byTopics = new util.HashMap[String, 
TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic]()
+
+      results.forKeyValue { (tp, error) =>
+        var topic = byTopics.get(tp.topic)
+        if (topic == null) {
+          topic = new 
TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic().setName(tp.topic)
+          byTopics.put(tp.topic, topic)
+          response.topics.add(topic)
+        }
+        topic.partitions.add(new 
TxnOffsetCommitResponseData.TxnOffsetCommitResponsePartition()
+          .setPartitionIndex(tp.partition)
+          .setErrorCode(error.code))
+      }
+
+      future.complete(response)
+    }
+
+    val currentTimestamp = time.milliseconds
+    val partitions = new mutable.HashMap[TopicPartition, OffsetAndMetadata]()
+
+    request.topics.forEach { topic =>
+      topic.partitions.forEach { partition =>
+        val tp = new TopicPartition(topic.name, partition.partitionIndex)
+        partitions += tp -> new OffsetAndMetadata(
+          offset = partition.committedOffset,
+          leaderEpoch = partition.committedLeaderEpoch match {
+            case RecordBatch.NO_PARTITION_LEADER_EPOCH => 
Optional.empty[Integer]

Review Comment:
   Oh didn't see this. Thanks for sharing 😅 I like that both are handled in the 
same place now.



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

Reply via email to