adoroszlai commented on code in PR #8167: URL: https://github.com/apache/ozone/pull/8167#discussion_r2015781199
########## hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/AvailableSpaceFilter.java: ########## @@ -39,14 +39,11 @@ public class AvailableSpaceFilter implements Predicate<HddsVolume> { @Override public boolean test(HddsVolume vol) { - SpaceUsageSource usage = vol.getCurrentUsage(); - long volumeCapacity = usage.getCapacity(); - long free = usage.getAvailable(); + StorageLocationReport report = vol.getReport(); + long free = report.getRemaining(); long committed = vol.getCommittedBytes(); long available = free - committed; - long volumeFreeSpaceToSpare = vol.getFreeSpaceToSpare(volumeCapacity); - boolean hasEnoughSpace = VolumeUsage.hasVolumeEnoughSpace(free, committed, - requiredSpace, volumeFreeSpaceToSpare); + boolean hasEnoughSpace = VolumeUsage.hasVolumeEnoughSpace(report, requiredSpace); mostAvailableSpace = Math.max(available, mostAvailableSpace); Review Comment: Thanks @ChenSammi for the review, that's a good idea. I have updated the patch: - Refactor `hasVolumeEnoughSpace` to `getUsableSpace`, which does not accept `requiredSpace` parameter, rather returns the calculated space. The caller can compare, and further use if needed. Since this value has `volumeFreeSpaceToSpare` deducted, `mostAvailable` now does, too. This also allows removing all calculation from `AvailableSpaceFilter`. - Change the `AvailableSpace` helper class to get values from the report. In a follow-up I think we can get rid of this helper class, and change the map to store the report directly (need to implement `toString()` in `StorageLocationReport`). Converted to draft until tests pass in CI. -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org