kerneltime commented on code in PR #6381:
URL: https://github.com/apache/ozone/pull/6381#discussion_r1532601591
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeUsage.java:
##########
@@ -133,6 +133,46 @@ public void setReserved(long reserved) {
this.reservedInBytes = reserved;
}
+ /**
+ * Convenience class to calculate minimum free space.
+ */
+ public static class MinFreeSpaceCalculator {
+ private final boolean minFreeSpaceConfigured;
+ private final boolean minFreeSpacePercentConfigured;
+ private final long freeSpace;
+ private float freeSpacePercent;
+ public MinFreeSpaceCalculator(ConfigurationSource conf) {
+ minFreeSpaceConfigured =
conf.isConfigured(HDDS_DATANODE_VOLUME_MIN_FREE_SPACE);
+ minFreeSpacePercentConfigured =
conf.isConfigured(HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_PERCENT);
+ freeSpace =
(long)conf.getStorageSize(HDDS_DATANODE_VOLUME_MIN_FREE_SPACE,
+ HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_DEFAULT, StorageUnit.BYTES);
+ if (minFreeSpacePercentConfigured) {
+ freeSpacePercent = Float.parseFloat(
+ conf.get(HDDS_DATANODE_VOLUME_MIN_FREE_SPACE_PERCENT));
+ }
+ }
+
+ public long get(long capacity) {
Review Comment:
Minor nit: It is useful to have some sanity tests for these calculations.
--
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]