kamalcph commented on code in PR #15060: URL: https://github.com/apache/kafka/pull/15060#discussion_r1440089289
########## core/src/main/java/kafka/log/remote/RemoteLogManager.java: ########## @@ -1340,6 +1346,10 @@ public FetchDataInfo read(RemoteStorageFetchInfo remoteStorageFetchInfo) throws Utils.closeQuietly(remoteSegInputStream, "RemoteLogSegmentInputStream"); } } + // for testing + public RemoteLogInputStream getRemoteLogInputStream(InputStream in) { Review Comment: can we reduce the method access specifier to package-private? I would suggest to remove this method and return the actual stream instead of mockStream for `remoteStorageManager.fetchLogSegment`: ```java new ByteArrayInputStream(records(ts, startOffset, targetLeaderEpoch).buffer().array()) ``` ########## core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java: ########## @@ -2161,6 +2167,85 @@ RecordBatch findFirstBatch(RemoteLogInputStream remoteLogInputStream, long offse } } + @Test + public void testReadForFirstBatchInLogCompaction() throws RemoteStorageException, IOException { + FileInputStream fileInputStream = mock(FileInputStream.class); + RemoteLogInputStream remoteLogInputStream = mock(RemoteLogInputStream.class); + ClassLoaderAwareRemoteStorageManager rsmManager = mock(ClassLoaderAwareRemoteStorageManager.class); + RemoteLogSegmentMetadata segmentMetadata = mock(RemoteLogSegmentMetadata.class); + LeaderEpochFileCache cache = mock(LeaderEpochFileCache.class); + when(cache.epochForOffset(anyLong())).thenReturn(OptionalInt.of(1)); + + when(remoteStorageManager.fetchLogSegment(any(RemoteLogSegmentMetadata.class), anyInt())) Review Comment: There are two remote-storage-manager: `rsmManager` (local) and `remoteStorageManager` (global). Can we discard the latter one? ########## core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java: ########## @@ -2065,6 +2066,11 @@ public Optional<RemoteLogSegmentMetadata> fetchRemoteLogSegmentMetadata(TopicPar return Optional.of(segmentMetadata); } + public Optional<RemoteLogSegmentMetadata> findNextSegmentMetadata(RemoteLogSegmentMetadata segmentMetadata, + Option<LeaderEpochFileCache> leaderEpochFileCacheOption) { + return Optional.ofNullable(null); Review Comment: Can we use `Optional.empty()` instead? -- 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