apoorvmittal10 commented on code in PR #22601:
URL: https://github.com/apache/kafka/pull/22601#discussion_r3453296875


##########
server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:
##########
@@ -0,0 +1,281 @@
+/*
+ * 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 org.apache.kafka.server.share.dlq;
+
+import org.apache.kafka.common.TopicIdPartition;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.common.record.internal.MemoryRecords;
+import org.apache.kafka.common.record.internal.Record;
+import org.apache.kafka.common.record.internal.RecordBatch;
+import org.apache.kafka.common.record.internal.Records;
+import org.apache.kafka.common.requests.FetchRequest;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.server.share.LogReader;
+import org.apache.kafka.server.storage.log.FetchIsolation;
+import org.apache.kafka.server.storage.log.FetchParams;
+import org.apache.kafka.storage.internals.log.FetchDataInfo;
+import org.apache.kafka.storage.internals.log.LogReadResult;
+import org.apache.kafka.storage.internals.log.RemoteStorageFetchInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.OptionalLong;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+
+/**
+ * Reads the original source records for the offset range described by a 
{@link ShareGroupDLQRecordParameter}
+ * so they can be copied into a DLQ record. Local reads are performed inline 
in a loop; when an offset has
+ * been tiered off the local log the records are fetched asynchronously from 
the remote tier and the loop
+ * resumes once the read completes (so the caller's thread is never blocked on 
remote storage IO).
+ *
+ * <p>Best-effort: the returned future always completes normally with whatever 
records could be read.
+ * Offsets that cannot be read - locally or remotely - are simply absent from 
the map, leaving the caller
+ * to produce a DLQ record with headers only for them.
+ *
+ * <p>Instances are single-use: create one fetcher per {@link #fetch()} call.
+ */
+public class ShareGroupDLQRecordFetcher {

Review Comment:
   I can integrate the new changes in DelayedShareFetch but for this PR we 
should abstract the read from local or remote behind the readLog method itself. 



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