Copilot commented on code in PR #8903:
URL: https://github.com/apache/ozone/pull/8903#discussion_r2298644456


##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestContainerReconciliationWithMockDatanodes.java:
##########
@@ -226,6 +228,62 @@ public void testContainerReconciliation(int 
numBlocksToDelete, int numChunksToCo
     assertEquals(healthyDataChecksum, repairedDataChecksum);
   }
 
+  /**
+   * Test that during reconciliation, the BCSID is taken from the peer's 
merkle tree instead of getting it from the
+   * peer block data.
+   */
+  @Test
+  public void testReconciliationUsesBcsIdFromPeerMerkleTree() throws Exception 
{
+    MockDatanode sourceDatanode = datanodes.get(0);
+    MockDatanode targetDatanode = datanodes.get(1);
+    
+    // Delete a few blocks from the target datanode to create missing blocks 
scenario
+    targetDatanode.introduceCorruption(CONTAINER_ID, 2, 0, false);
+    
+    // Get a reference block that exists in source but not in target
+    KeyValueContainer sourceContainer = 
sourceDatanode.getContainer(CONTAINER_ID);
+    KeyValueContainer targetContainer = 
targetDatanode.getContainer(CONTAINER_ID);
+    
+    List<BlockData> sourceBlocks = 
sourceDatanode.getSortedBlocks(sourceContainer);
+    List<BlockData> targetBlocks = 
targetDatanode.getSortedBlocks(targetContainer);
+    
+    Set<Long> targetBlockIds = targetBlocks.stream()
+        .map(BlockData::getLocalID)
+        .collect(Collectors.toSet());

Review Comment:
   [nitpick] Consider using a more efficient collection approach. Instead of 
creating a Set from a stream, you could iterate through sourceBlocks and check 
containment directly in targetBlocks if targetBlocks is small, or use a HashSet 
constructor if the stream approach is preferred.
   ```suggestion
       Set<Long> targetBlockIds = new HashSet<>();
       for (BlockData block : targetBlocks) {
           targetBlockIds.add(block.getLocalID());
       }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to