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 2023/01/14 00:09:49 UTC

[GitHub] [kafka] jeffkbkim commented on a diff in pull request #12902: KAFKA-14367; Add `OffsetDelete` to the new `GroupCoordinator` interface

jeffkbkim commented on code in PR #12902:
URL: https://github.com/apache/kafka/pull/12902#discussion_r1070170859


##########
core/src/test/scala/unit/kafka/server/KafkaApisTest.scala:
##########
@@ -2764,37 +2763,170 @@ class KafkaApisTest {
     val request = buildRequest(offsetDeleteRequest)
 
     val requestLocal = RequestLocal.withThreadConfinedCaching
-    when(clientRequestQuotaManager.maybeRecordAndGetThrottleTimeMs(any[RequestChannel.Request](),
-      any[Long])).thenReturn(0)
-    when(groupCoordinator.handleDeleteOffsets(
-      ArgumentMatchers.eq(group),
-      ArgumentMatchers.eq(Seq(
-        new TopicPartition("topic-1", 0),
-        new TopicPartition("topic-1", 1),
-        new TopicPartition("topic-2", 0),
-        new TopicPartition("topic-2", 1)
-      )),
-      ArgumentMatchers.eq(requestLocal)
-    )).thenReturn((Errors.NONE, Map(
-      new TopicPartition("topic-1", 0) -> Errors.NONE,
-      new TopicPartition("topic-1", 1) -> Errors.NONE,
-      new TopicPartition("topic-2", 0) -> Errors.NONE,
-      new TopicPartition("topic-2", 1) -> Errors.NONE,
-    )))
+    val future = new CompletableFuture[OffsetDeleteResponseData]()
+    when(newGroupCoordinator.deleteOffsets(
+      request.context,
+      offsetDeleteRequest.data,
+      requestLocal.bufferSupplier
+    )).thenReturn(future)
 
     createKafkaApis().handleOffsetDeleteRequest(request, requestLocal)
 
+    val offsetDeleteResponseData = new OffsetDeleteResponseData()
+      .setTopics(new OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection(List(
+        new OffsetDeleteResponseData.OffsetDeleteResponseTopic()
+          .setName("topic-1")

Review Comment:
   shouldn't we expect 
   topic-1 (partition-0, partition-1)
   topic-2 (partition-0, partition-1)
   
   in the response? why are we expecting
   topic-1 (partition-0, partition-0)?



##########
core/src/main/scala/kafka/coordinator/group/GroupCoordinatorAdapter.scala:
##########
@@ -470,4 +470,45 @@ class GroupCoordinatorAdapter(
       expireTimestamp = expireTimestamp
     )
   }
+
+  override def deleteOffsets(
+    context: RequestContext,
+    request: OffsetDeleteRequestData,
+    bufferSupplier: BufferSupplier
+  ): CompletableFuture[OffsetDeleteResponseData] = {
+    val future = new CompletableFuture[OffsetDeleteResponseData]()
+
+    val partitions = mutable.ArrayBuffer[TopicPartition]()
+    request.topics.forEach { topic =>
+      topic.partitions.forEach { partition =>
+        partitions += new TopicPartition(topic.name, partition.partitionIndex)
+      }
+    }
+
+    val (groupError, topicPartitionResults) = coordinator.handleDeleteOffsets(
+      request.groupId,
+      partitions,
+      RequestLocal(bufferSupplier)
+    )
+
+    if (groupError != Errors.NONE) {
+      future.completeExceptionally(groupError.exception)
+    } else {
+      val response = new OffsetDeleteResponseData()
+      topicPartitionResults.forKeyValue { (topicPartition, error) =>
+        var topic = response.topics.find(topicPartition.topic)

Review Comment:
   i'm still confused on the reason behind using ImplicitLinkedHashMultiCollection - what do you mean by map key? 



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org