diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java index 776c991c27ebd0a72c51f792ec6c3306b5920ae3..6318be078fd2a9691bb156f722fe9c85f574fae8 100644 --- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java @@ -218,10 +218,15 @@ public class UtilAll { long totalSpace = file.getTotalSpace(); if (totalSpace > 0) { - long freeSpace = file.getFreeSpace(); - long usedSpace = totalSpace - freeSpace; - - return usedSpace / (double) totalSpace; + long usedSpace = totalSpace - file.getFreeSpace(); + long usableSpace = file.getUsableSpace(); + long entireSpace = usedSpace + usableSpace; + long roundNum = 0; + if (usedSpace * 100 % entireSpace != 0) { + roundNum = 1; + } + long result = usedSpace * 100 / entireSpace + roundNum; + return result / 100.0; } } catch (Exception e) { log.error("Error when measuring disk space usage, got exception: :", e);