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


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java:
##########
@@ -238,4 +238,14 @@ private static long getReserved(ConfigurationSource conf, 
String rootDir,
 
     return (long) Math.ceil(capacity * percentage);
   }
+
+  public boolean isReservedUsagesInRange() {
+    SpaceUsageSource spaceUsageSource = realUsage();
+    long reservedUsed = getOtherUsed(spaceUsageSource);
+    if (reservedInBytes > 0 && reservedUsed > reservedInBytes) {
+      LOG.warn("Reserved usages {} is higher than actual allocated reserved 
space {}.", reservedInBytes, reservedUsed);

Review Comment:
   The log message parameter order appears reversed: the message implies that 
the actual usage exceeded the configured reserved space, so consider switching 
the order to log the actual reserved usage first and the reserved allocation 
second.
   ```suggestion
         LOG.warn("Reserved usages {} is higher than actual allocated reserved 
space {}.", reservedUsed, reservedInBytes);
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/HddsVolume.java:
##########
@@ -346,6 +349,31 @@ public VolumeCheckResult checkDbHealth(File dbFile) throws 
InterruptedException
     return VolumeCheckResult.HEALTHY;
   }
 
+  @VisibleForTesting
+  public void checkVolumeUsages() {
+    boolean isEnoughSpaceAvailable = true;
+    SpaceUsageSource currentUsage = getCurrentUsage();
+    long getFreeSpaceToSpare = getFreeSpaceToSpare(currentUsage.getCapacity());
+    if (currentUsage.getAvailable() < getFreeSpaceToSpare) {
+      LOG.warn("Volume {} has insufficient space for write operation. 
Available: {}, Free space to spare: {}",
+          getStorageDir(), currentUsage.getAvailable(), getFreeSpaceToSpare);
+      isEnoughSpaceAvailable = false;
+    } else if (committedBytes.get() > 0 && currentUsage.getAvailable() < 
committedBytes.get() + getFreeSpaceToSpare) {
+      LOG.warn("Volume {} has insufficient space for on-going container write 
operation. " +
+              "Committed: {}, Available: {}, Free space to spare: {}",
+          getStorageDir(), committedBytes, currentUsage.getAvailable(), 
getFreeSpaceToSpare);

Review Comment:
   [nitpick] For improved clarity, consider using committedBytes.get() (instead 
of the AtomicLong reference) when logging the committed bytes value.
   ```suggestion
             getStorageDir(), committedBytes.get(), 
currentUsage.getAvailable(), getFreeSpaceToSpare);
   ```



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