kamalcph commented on code in PR #14727:
URL: https://github.com/apache/kafka/pull/14727#discussion_r1392226674


##########
core/src/test/java/kafka/log/remote/RemoteLogManagerTest.java:
##########
@@ -1652,22 +1679,23 @@ public void 
testDeleteLogSegmentDueToRetentionSizeBreach(int segmentCount,
         
when(mockLog.onlyLocalLogSegmentsSize()).thenReturn(localLogSegmentsSize);
 
         List<RemoteLogSegmentMetadata> segmentMetadataList = 
listRemoteLogSegmentMetadata(
-                leaderTopicIdPartition, segmentCount, recordsPerSegment, 
segmentSize, epochEntries);
+            leaderTopicIdPartition, segmentCount, recordsPerSegment, 
segmentSize, epochEntries, state);
         verifyDeleteLogSegment(segmentMetadataList, deletableSegmentCount, 
currentLeaderEpoch);
     }
 
     @ParameterizedTest(name = "testDeleteLogSegmentDueToRetentionTimeBreach 
segmentCount={0} deletableSegmentCount={1}")
-    @CsvSource(value = {"50, 0", "50, 1", "50, 23", "50, 50"})
+    @CsvSource(value = {"50, 0, DELETE_SEGMENT_STARTED", "50, 1, 
COPY_SEGMENT_FINISHED", "50, 23, DELETE_SEGMENT_STARTED", "50, 50, 
COPY_SEGMENT_FINISHED"})

Review Comment:
   can we skip updating the existing tests? 
   
   There is already a test (testDeleteRetentionMsBeforeSegmentReady) to verify 
that if the state is DELETE_SEGMENT_FINISHED, no interaction is expected with 
the RemoteStorageManager.



##########
core/src/main/java/kafka/log/remote/RemoteLogManager.java:
##########
@@ -988,6 +998,10 @@ void cleanupExpiredRemoteLogSegments() throws 
RemoteStorageException, ExecutionE
                         return;
                     }
                     RemoteLogSegmentMetadata metadata = 
segmentsIterator.next();
+
+                    if 
(!SEGMENT_DELETION_VALID_STATES.contains(metadata.state())) {

Review Comment:
   Can this condition be simplified to?
   
   ```
   if (RemoteLogSegmentState.DELETE_SEGMENT_FINISHED.equals(metadata.state())) {
       continue;
   }
   ```
   
   If we want to add/remove state, we can change the logic later.



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

Reply via email to