dongnuo123 commented on code in PR #14408: URL: https://github.com/apache/kafka/pull/14408#discussion_r1331969154
########## 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 + ) throws ApiException { + + CoordinatorResult<DeleteGroupsResponseData.DeletableGroupResultCollection, Record> groupDeleteCoordinatorResult = + groupMetadataManager.groupDelete(context, groupIds); + + List<String> validGroupIds = new ArrayList<>(); + for (DeleteGroupsResponseData.DeletableGroupResult result : groupDeleteCoordinatorResult.response()) { + if (result.errorCode() == Errors.NONE.code()) { + validGroupIds.add(result.groupId()); + } + } + + CoordinatorResult<OffsetDeleteResponseData, Record> deleteOffsetCoordinatorResult = + offsetMetadataManager.deleteAllOffsets(context, validGroupIds); + + final List<Record> records = groupDeleteCoordinatorResult.records(); + records.addAll(deleteOffsetCoordinatorResult.records()); + return new CoordinatorResult<>(records, groupDeleteCoordinatorResult.response()); Review Comment: I rearranged this part. Now we loop over the group ids and process them one by one -- validate, populate record list with offset tombstones, add group tombstone, and add response. ########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java: ########## @@ -3071,6 +3072,41 @@ private void removeCurrentMemberFromGenericGroup( group.remove(member.memberId()); } + public CoordinatorResult<DeleteGroupsResponseData.DeletableGroupResultCollection, Record> groupDelete( + RequestContext context, + List<String> groupIds + ) throws ApiException { + final DeleteGroupsResponseData.DeletableGroupResultCollection resultCollection = + new DeleteGroupsResponseData.DeletableGroupResultCollection(); + final List<Record> records = new ArrayList<>(); + + groupIds.forEach(groupId -> { + DeleteGroupsResponseData.DeletableGroupResult result = + new DeleteGroupsResponseData.DeletableGroupResult().setGroupId(groupId); + try { + validateGroupDelete(groupId); + records.add(RecordHelpers.newGroupMetadataTombstoneRecord(groupId)); Review Comment: done -- 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