From a093f8a638f1a1329b0c7567bf38e8590fa668f8 Mon Sep 17 00:00:00 2001 From: affe Date: Tue, 11 Aug 2020 10:49:30 +0800 Subject: [PATCH] [ISSUE #2067] Add logs when collecting disk space usage --- .../main/java/org/apache/rocketmq/common/UtilAll.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 2aab5b79..639a2009 100644 --- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java +++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java @@ -200,14 +200,20 @@ public class UtilAll { } public static double getDiskPartitionSpaceUsedPercent(final String path) { - if (null == path || path.isEmpty()) + if (null == path || path.isEmpty()) { + log.error("Error when measuring disk space usage, path is null or empty, path : {}", path); return -1; + } + try { File file = new File(path); - if (!file.exists()) + if (!file.exists()) { + log.error("Error when measuring disk space usage, file doesn't exist on this path: {}", path); return -1; + } + long totalSpace = file.getTotalSpace(); @@ -218,6 +224,7 @@ public class UtilAll { return usedSpace / (double) totalSpace; } } catch (Exception e) { + log.error("Error when measuring disk space usage, got exception: :", e); return -1; } -- GitLab