abhijeetk88 commented on code in PR #16584: URL: https://github.com/apache/kafka/pull/16584#discussion_r1719981712
########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -1334,6 +1334,37 @@ class UnifiedLog(@volatile var logStartOffset: Long, } else { Some(new TimestampAndOffset(RecordBatch.NO_TIMESTAMP, -1L, Optional.of(-1))) } + } else if (targetTimestamp == ListOffsetsRequest.EARLIEST_PENDING_UPLOAD_OFFSET_TIMESTAMP) { + if (remoteLogEnabled()) { + val curHighestRemoteOffset = highestOffsetInRemoteStorage() + + if (curHighestRemoteOffset == -1) { + if (localLogStartOffset() == logStartOffset) { + // No segments have been uploaded yet + fetchOffsetByTimestamp(ListOffsetsRequest.EARLIEST_TIMESTAMP, remoteLogManager) + } else { + // Leader currently does not know about the already uploaded segments + Some(new TimestampAndOffset(RecordBatch.NO_TIMESTAMP, -1L, Optional.of(-1))) + } + } else { + val earliestPendingUploadOffset = math.max(curHighestRemoteOffset + 1, logStartOffset) + + val epochResult: Optional[Integer] = + if (leaderEpochCache.isDefined) { + val epochOpt = leaderEpochCache.get.epochForOffset(earliestPendingUploadOffset) + if (epochOpt.isPresent) { + Optional.of(epochOpt.getAsInt) + } else { + Optional.empty() + } + } else { + Optional.empty() + } + Some(new TimestampAndOffset(RecordBatch.NO_TIMESTAMP, earliestPendingUploadOffset, epochResult)) Review Comment: Made the requested changes. Also changed for LATEST_TIMESTAMP -- 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