showuon commented on code in PR #14128:
URL: https://github.com/apache/kafka/pull/14128#discussion_r1278842588
##########
core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java:
##########
@@ -269,15 +269,38 @@ void testStartup() {
void testCopyLogSegmentsToRemoteShouldCopyExpectedLogSegment() throws
Exception {
long oldSegmentStartOffset = 0L;
long nextSegmentStartOffset = 150L;
- long oldSegmentEndOffset = nextSegmentStartOffset - 1;
+ long lso = 250L;
+ long leo = 300L;
+ assertCopyExpectedLogSegmentsToRemote(oldSegmentStartOffset,
nextSegmentStartOffset, lso, leo);
+ }
+
+ /**
+ * The following values will be equal when the active segment gets rotated
to passive when there are no new messages:
Review Comment:
nit: The following values will be equal when the active segment gets rotated
to passive [and] there are no new messages:
##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -525,6 +524,26 @@ private void maybeUpdateReadOffset(UnifiedLog log) throws
RemoteStorageException
}
}
+ List<EnrichedLogSegment> enrichedLogSegments(UnifiedLog log, Long
fromOffset, Long lastStableOffset) {
+ List<EnrichedLogSegment> enrichedLogSegments = new ArrayList<>();
+ List<LogSegment> segments =
JavaConverters.seqAsJavaList(log.nonActiveLogSegmentsFrom(fromOffset).toSeq());
+ if (!segments.isEmpty()) {
+ int idx = 1;
+ for (; idx < segments.size(); idx++) {
+ LogSegment previous = segments.get(idx - 1);
+ LogSegment current = segments.get(idx);
+ enrichedLogSegments.add(new EnrichedLogSegment(previous,
current.baseOffset()));
+ }
+ // LogSegment#readNextOffset() is an expensive call, so we
only call it when necessary.
+ int lastIdx = idx - 1;
+ if (segments.get(lastIdx).baseOffset() < lastStableOffset) {
+ LogSegment last = segments.get(lastIdx);
+ enrichedLogSegments.add(new EnrichedLogSegment(last,
last.readNextOffset()));
+ }
Review Comment:
Why can't we use the active segment's baseOffset here like the above did?
Also, I'm not very familiar with this, what's the difference between
`readNextOffset` and `baseOffset of next segment`?
--
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]