ChenSammi commented on code in PR #8827:
URL: https://github.com/apache/ozone/pull/8827#discussion_r2281848776
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -469,6 +471,35 @@ 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;
+ List<Container<?>> containers = new ArrayList<>(containerMap.values());
+ for (Container<?> container : containers) {
Review Comment:
Please use containerMap.values() directly in the for loop, instead of create
a new List to hold it, to reduce the memory required.
--
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]