priyeshkaratha commented on code in PR #8827:
URL: https://github.com/apache/ozone/pull/8827#discussion_r2289925092


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -469,6 +474,46 @@ public void listContainer(long startContainerId, long 
count,
     }
   }
 
+  /**
+   * This method can be used to get total bytes pending for deletion
+   * in cached interval of time. This can be utilized by either storage
+   * report or other services.
+   */
+  public long getPendingDeletionBytes() {
+
+    CachedPendingDeletion currentCache = cachedPendingDeletion;
+    if (currentCache != null && !currentCache.isExpired()) {
+      return currentCache.getSize();
+    }
+
+    synchronized (cacheLock) {
+      currentCache = cachedPendingDeletion;
+      if (currentCache != null && !currentCache.isExpired()) {
+        return currentCache.getSize();
+      }
+      long total = 0L;
+      for (Container<?> container : containerMap.values()) {
+        total += container.getContainerData()
+            .getStatistics()
+            .getBlockPendingDeletionBytes();
+      }
+      long cacheDurationMillis = getSafeHeartbeatInterval(containerMap);
+      cachedPendingDeletion = new CachedPendingDeletion(total, 
cacheDurationMillis);
+      return total;
+    }
+  }
+
+  private long getSafeHeartbeatInterval(Map<Long, Container<?>> containers) {

Review Comment:
   Thanks Sammi, The calculation is already there in BlockDeletingService and 
it can be accessed at storageReport via  BlockDeletingServiceMetrics.



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java:
##########
@@ -639,8 +639,17 @@ private void updateMetaData(KeyValueContainerData 
containerData,
 
       // update pending deletion blocks count and delete transaction ID in
       // in-memory container status
-      containerData.updateDeleteTransactionId(delTX.getTxID());
-      containerData.incrPendingDeletionBlocks(newDeletionBlocks);
+      long pendingBytes = delTX.getTotalBlockSize();
+      metadataTable
+          .putWithBatch(batchOperation,
+              containerData.getPendingDeleteBlockBytesKey(),
+              pendingBytes);

Review Comment:
   Yes, Updated the logic



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