jsancio commented on a change in pull request #11054:
URL: https://github.com/apache/kafka/pull/11054#discussion_r670583303



##########
File path: raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java
##########
@@ -280,11 +280,19 @@ default long truncateToEndOffset(OffsetAndEpoch 
endOffset) {
     Optional<RawSnapshotReader> readSnapshot(OffsetAndEpoch snapshotId);
 
     /**
-     * Returns the latest snapshot id if one exists.
+     * Returns the latest readable snapshot if one exists.
      *
-     * @return an Optional snapshot id of the latest snashot if one exists, 
otherwise returns an
-     * empty Optional
+     * @return an Optional with the latest readable snapshot, if one exists, 
otherwise
+     *         returns an empty Optional
      */
+    Optional<RawSnapshotReader> latestSnapshot();

Review comment:
       `RawSnapshotReader` are not `Closeable` or `AutoCloseable`. The specific 
implementation `FileRawSnapshotReader` is `AutoCloseable`.
   
   This was done to match Kafka ownership model. For example, kraft sends the 
`FileChannel` owned by `RawSnapshotReader` to the networking layer when 
replying to `FetchSnapshot` requests.
   
   `FileRawSnapshotReader` are closed as part of the clean up process. 60 
seconds (if I remember correctly) after `maybeClean` has determine that they 
should be deleted.

##########
File path: raft/src/main/java/org/apache/kafka/snapshot/SnapshotReader.java
##########
@@ -84,7 +84,7 @@ public int lastContainedLogEpoch() {
      */
     public long lastContainedLogTimestamp() {
         if (!lastContainedLogTimestamp.isPresent()) {
-            // nextBatch is expected to be empty
+            // nextBatch is expected to be equal to Optional.empty() so just 
replace it

Review comment:
       Done.




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