sjhajharia commented on code in PR #18671:
URL: https://github.com/apache/kafka/pull/18671#discussion_r1931910325


##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3185,9 +3187,87 @@ class KafkaApis(val requestChannel: RequestChannel,
 
   def handleDescribeShareGroupOffsetsRequest(request: RequestChannel.Request): 
Unit = {
     val describeShareGroupOffsetsRequest = 
request.body[DescribeShareGroupOffsetsRequest]
-    // TODO: Implement the DescribeShareGroupOffsetsRequest handling
-    requestHelper.sendMaybeThrottle(request, 
describeShareGroupOffsetsRequest.getErrorResponse(Errors.UNSUPPORTED_VERSION.exception))
-    CompletableFuture.completedFuture[Unit](())
+
+    if (!isShareGroupProtocolEnabled) {
+      requestHelper.sendMaybeThrottle(request, 
describeShareGroupOffsetsRequest.getErrorResponse(Errors.UNSUPPORTED_VERSION.exception))
+      CompletableFuture.completedFuture[Unit](())
+    } else if (!authHelper.authorize(request.context, READ, GROUP, 
describeShareGroupOffsetsRequest.data.groupId)) {
+      requestHelper.sendMaybeThrottle(request, 
describeShareGroupOffsetsRequest.getErrorResponse(Errors.GROUP_AUTHORIZATION_FAILED.exception))
+      CompletableFuture.completedFuture[Unit](())
+    } else {
+      val topicNamesToIds = metadataCache.topicNamesToIds()
+      val topicIdToNames = metadataCache.topicIdsToNames()
+
+      val readStateSummaryData = 
getReadShareGroupStateSummaryRequestFromDescribeShareGroupOffsetsRequest(
+        describeShareGroupOffsetsRequest.data(),
+        topicNamesToIds
+      )
+      groupCoordinator.describeShareGroupOffsets(
+        request.context,
+        readStateSummaryData,
+      ).handle[Unit] { (response, exception) =>
+        if (exception != null) {
+          requestHelper.sendMaybeThrottle(request, 
describeShareGroupOffsetsRequest.getErrorResponse(exception))
+        } else {
+          requestHelper.sendMaybeThrottle(
+            request,
+            new DescribeShareGroupOffsetsResponse(
+              
getDescribeShareGroupOffsetsResponseFromReadShareGroupStateSummaryResponse(response,
 topicIdToNames)
+            )
+          )
+        }
+      }
+    }
+  }
+
+  private def 
getReadShareGroupStateSummaryRequestFromDescribeShareGroupOffsetsRequest(describeShareGroupOffsetsRequestData:
 DescribeShareGroupOffsetsRequestData,
+                                                                               
        topicNamesId: util.Map[String, Uuid]
+                                                                               
       ): ReadShareGroupStateSummaryRequestData = {
+    val readStateSummaryTopics = 
describeShareGroupOffsetsRequestData.topics.asScala.map(
+      topic => {
+        val partitions = topic.partitions.asScala.map(
+          partitionIndex => {
+            new PartitionData()
+              .setPartition(partitionIndex)
+              .setLeaderEpoch(0)

Review Comment:
   I can get rid of that line where we explicitly set the Leader Epoch to 0. 
However, the default value which `new PartitionData()` would set is 0 as well. 
Given that `DescribeShareGroupOffsetsRequestTopic` doesn't have the Epoch 
information on it, it would always be set to default.



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