adixitconfluent commented on code in PR #16969:
URL: https://github.com/apache/kafka/pull/16969#discussion_r1754440143


##########
core/src/main/java/kafka/server/share/ShareFetchUtils.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package kafka.server.share;
+
+import kafka.server.ReplicaManager;
+
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.message.ShareFetchResponseData;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.common.record.FileRecords;
+import org.apache.kafka.common.requests.ListOffsetsRequest;
+import org.apache.kafka.storage.internals.log.FetchPartitionData;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import scala.Option;
+
+/**
+ * Utility class for post-processing of share fetch operations.
+ */
+public class ShareFetchUtils {
+    private static final Logger log = 
LoggerFactory.getLogger(ShareFetchUtils.class);
+
+    // Process the replica manager fetch response to update share partitions 
and futures.
+    static CompletableFuture<Map<TopicIdPartition, 
ShareFetchResponseData.PartitionData>> processFetchResponse(
+            SharePartitionManager.ShareFetchPartitionData 
shareFetchPartitionData,
+            Map<TopicIdPartition, FetchPartitionData> responseData,
+            Map<SharePartitionManager.SharePartitionKey, SharePartition> 
partitionCacheMap,
+            ReplicaManager replicaManager
+    ) {
+        Map<TopicIdPartition, 
CompletableFuture<ShareFetchResponseData.PartitionData>> futures = new 
HashMap<>();
+        responseData.forEach((topicIdPartition, fetchPartitionData) -> {
+
+            SharePartition sharePartition = partitionCacheMap.get(new 
SharePartitionManager.SharePartitionKey(
+                    shareFetchPartitionData.groupId(), topicIdPartition));
+            futures.put(topicIdPartition, 
sharePartition.acquire(shareFetchPartitionData.memberId(), fetchPartitionData)

Review Comment:
   @junrao , I think we can get rid of the future as you mentioned. I have 
logged a jira https://issues.apache.org/jira/browse/KAFKA-17522 and assigned it 
to @apoorvmittal10. He mentioned he'll take a look. Thanks.



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