KAFKA-17108: Add EarliestPendingUpload offset spec in ListOffsets API#16584
Conversation
b4f63a6 to
d89d53b
Compare
| 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)) |
There was a problem hiding this comment.
| 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)) | |
| val epochResult = leaderEpochCache.flatMap(_.epochForOffset(earliestPendingUploadOffset).asScala) | |
| .asJava.asInstanceOf[Optional[Integer]] | |
| Some(new TimestampAndOffset(RecordBatch.NO_TIMESTAMP, earliestPendingUploadOffset, epochResult)) |
There was a problem hiding this comment.
Done. Thanks for the suggestion.
There was a problem hiding this comment.
There are other places in the same method can benefit from this refactor as well like line 1319 and 1298
There was a problem hiding this comment.
Made the requested changes. Also changed for LATEST_TIMESTAMP
e40dd55 to
5684997
Compare
| } else { | ||
| Some(new TimestampAndOffset(RecordBatch.NO_TIMESTAMP, -1L, Optional.of(-1))) | ||
| } | ||
| } else if (targetTimestamp == ListOffsetsRequest.EARLIEST_PENDING_UPLOAD_OFFSET_TIMESTAMP) { |
There was a problem hiding this comment.
Can we extract this into different method and call it from here especially that the logic here has too many if stataments ? I know the rest of fetchOffsetByTimestamp has been done in-place but the method has grown and it hard to follow.
kamalcph
left a comment
There was a problem hiding this comment.
Overall LGTM. Left one minor comment to address. Thanks for covering the patch with detailed unit tests!
bff7bf8 to
5e548a3
Compare
|
Please rebase this PR with trunk. |
|
This PR is being marked as stale since it has not had any activity in 90 days. If you If you are having difficulty finding a reviewer, please reach out on the [mailing list](https://kafka.apache.org/contact). If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed. |
|
This PR is being marked as stale since it has not had any activity in 90 days. If you If you are having difficulty finding a reviewer, please reach out on the [mailing list](https://kafka.apache.org/contact). If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed. |
|
This PR has been closed since it has not had any activity in 120 days. If you feel like this |
5e548a3 to
2e030b6
Compare
2e030b6 to
8644b22
Compare
8644b22 to
b9a0de9
Compare
kamalcph
left a comment
There was a problem hiding this comment.
Thanks for the patch! Please address the below comments:
- ListOffsetsRequest version needs a bump as a new targetTimestamp value is added . Previous comment and
- Also, could you add the EarliestPendingUploadSpec in OffsetSpec and cover with integration tests?
|
Could you follow this #16781 PR and handle similarly for EarliestPendingUploadSpec? Thanks! |
kamalcph
left a comment
There was a problem hiding this comment.
LGTM, thanks for the patch!
|
@abhijeetk88 Do you mind documenting these new APIs in |
| * <br/> | ||
| * Note: When tiered storage is not enabled, we will return unknown offset. | ||
| */ | ||
| public static OffsetSpec earliestPendingUpload() { |
There was a problem hiding this comment.
sure, will add.
…apache#16584) This is the first part of the implementation of [KIP-1023](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1023%3A+Follower+fetch+from+tiered+offset) The purpose of this pull request is for the broker to start returning the correct offset when it receives a -6 as a timestamp in a ListOffsets API request. Added unit tests for the new timestamp. Reviewers: Kamal Chandraprakash <kamal.chandraprakash@gmail.com>
This is the first part of the implementation of
KIP-1023
The purpose of this pull request is for the broker to start returning
the correct offset when it receives a -6 as a timestamp in a ListOffsets
API request.
Added unit tests for the new timestamp.
Reviewers: Kamal Chandraprakash kamal.chandraprakash@gmail.com