ChenSammi commented on code in PR #8845:
URL: https://github.com/apache/ozone/pull/8845#discussion_r2238167255


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -229,13 +246,23 @@ private int resetRetryCount(List<Long> txIDs) throws 
IOException {
   }
 
   private DeletedBlocksTransaction constructNewTransaction(
-      long txID, long containerID, List<Long> blocks) {
-    return DeletedBlocksTransaction.newBuilder()
+      long txID, long containerID, List<DeletedBlock> blocks) {
+    List<Long> localIdList = blocks.stream().map(b -> 
b.getBlockID().getLocalID()).collect(Collectors.toList());
+    DeletedBlocksTransaction.Builder builder = 
DeletedBlocksTransaction.newBuilder()
         .setTxID(txID)
         .setContainerID(containerID)
-        .addAllLocalID(blocks)
-        .setCount(0)
-        .build();
+        .addAllLocalID(localIdList)
+        .setCount(0);
+
+    if 
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.DATA_DISTRIBUTION)) {
+      long replicatedSize = 
blocks.stream().mapToLong(DeletedBlock::getReplicatedSize).sum();
+      // even when HDDSLayoutFeature.DATA_DISTRIBUTION is finalized, old OM 
can still call the old API
+      if (replicatedSize >= 0) {
+        builder.setTotalBlockReplicatedSize(replicatedSize);
+        
builder.setTotalBlockSize(blocks.stream().mapToLong(DeletedBlock::getSize).sum());

Review Comment:
   Can you explain a bit further while it will give wrong value? If receiving 
requests before SCM finalize, it will not run into this branch. If receiving 
old requests after SCM finalized,  replicatedSize will be negative.  There is 
only one case that replicatedSize could be inaccurate, is that the blocks are 
mixed with old format and new format, which doesn't exist, because for 
KeyBlocks, we either use blocks list, or use deletedBlocks list. 



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