dongnuo123 commented on code in PR #14408:
URL: https://github.com/apache/kafka/pull/14408#discussion_r1332010169


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/OffsetMetadataManager.java:
##########
@@ -333,6 +348,98 @@ public CoordinatorResult<OffsetCommitResponseData, Record> 
commitOffset(
         return new CoordinatorResult<>(records, response);
     }
 
+    /**
+     * Handles an OffsetDelete request.
+     *
+     * @param context The request context.
+     * @param request The OffsetDelete request.
+     *
+     * @return A Result containing the OffsetDeleteResponseData response and
+     *         a list of records to update the state machine.
+     */
+    public CoordinatorResult<OffsetDeleteResponseData, Record> deleteOffsets(
+            RequestContext context,
+            OffsetDeleteRequestData request
+    ) throws ApiException {
+        final List<Record> records = new ArrayList<>();
+        final OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection 
responseTopicCollection =
+                new 
OffsetDeleteResponseData.OffsetDeleteResponseTopicCollection();
+        OffsetDeleteResponseData response = new OffsetDeleteResponseData();
+        try {
+            Group group = validateOffsetDelete(request);
+
+            request.topics().forEach(topic -> {
+                final 
OffsetDeleteResponseData.OffsetDeleteResponsePartitionCollection 
responsePartitionCollection =
+                        new 
OffsetDeleteResponseData.OffsetDeleteResponsePartitionCollection();
+                final boolean subscribedToTopic = 
group.isSubscribedToTopic(topic.name());
+
+                topic.partitions().forEach(partition -> {
+                    records.add(RecordHelpers.newOffsetCommitTombstoneRecord(
+                            request.groupId(),
+                            topic.name(),
+                            partition.partitionIndex()
+                    ));
+
+                    OffsetDeleteResponseData.OffsetDeleteResponsePartition 
responsePartition =
+                            new 
OffsetDeleteResponseData.OffsetDeleteResponsePartition().setPartitionIndex(partition.partitionIndex());
+                    if (subscribedToTopic) {
+                        responsePartition = 
responsePartition.setErrorCode(Errors.GROUP_SUBSCRIBED_TO_TOPIC.code());
+                    }
+                    responsePartitionCollection.add(responsePartition);
+                });
+
+                final OffsetDeleteResponseData.OffsetDeleteResponseTopic 
responseTopic =
+                        new 
OffsetDeleteResponseData.OffsetDeleteResponseTopic().setPartitions(responsePartitionCollection);
+                responseTopicCollection.add(responseTopic);
+            });
+            response = response.setTopics(responseTopicCollection);
+        } catch (ApiException ex) {
+            response = response.setErrorCode(Errors.forException(ex).code());
+        }
+        return new CoordinatorResult<>(records, response);
+    }
+
+    /**
+     * Deletes all the offsets of the given groups to handle a GroupDelete 
request.
+     * Validations are done in groupDelete method in GroupMetadataManager.
+     *
+     * @param context The request context.
+     * @param groupIds The list of group ids of the given groups.
+     * @return A Result containing the OffsetDeleteResponseData response and
+     *         a list of records to update the state machine.
+     */
+    public CoordinatorResult<OffsetDeleteResponseData, Record> 
deleteAllOffsets(

Review Comment:
   Fixed



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorShard.java:
##########
@@ -262,6 +267,29 @@ public HeartbeatResponseData genericGroupHeartbeat(
         );
     }
 
+    public 
CoordinatorResult<DeleteGroupsResponseData.DeletableGroupResultCollection, 
Record> deleteGroups(
+            RequestContext context,
+            List<String> groupIds

Review Comment:
   Fixed



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