ChenSammi commented on code in PR #8827:
URL: https://github.com/apache/ozone/pull/8827#discussion_r2287729587
##########
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:
Priyesh, you can just pass the conf into ContainerSet constructor, instead
of iterating container map.
--
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]