提交 255a2028 编写于 作者: J Jiang Haiting

add path empty check to avoid error log in...

add path empty check to avoid error log in org.apache.rocketmq.store.DefaultMessageStore#getRuntimeInfo
上级 466bb98e
...@@ -198,6 +198,11 @@ public class UtilAll { ...@@ -198,6 +198,11 @@ public class UtilAll {
cal.get(Calendar.SECOND)); cal.get(Calendar.SECOND));
} }
public static boolean isPathExists(final String path) {
File file = new File(path);
return file.exists();
}
public static double getDiskPartitionSpaceUsedPercent(final String path) { 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); log.error("Error when measuring disk space usage, path is null or empty, path : {}", path);
......
...@@ -788,21 +788,23 @@ public class DefaultMessageStore implements MessageStore { ...@@ -788,21 +788,23 @@ public class DefaultMessageStore implements MessageStore {
double minPhysicsUsedRatio = Double.MAX_VALUE; double minPhysicsUsedRatio = Double.MAX_VALUE;
String[] paths = commitLogStorePath.trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER); String[] paths = commitLogStorePath.trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
for (String clPath : paths) { for (String clPath : paths) {
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(clPath); double physicRatio = UtilAll.isPathExists(clPath) ?
UtilAll.getDiskPartitionSpaceUsedPercent(clPath) : -1;
result.put(RunningStats.commitLogDiskRatio.name() + "_" + clPath, String.valueOf(physicRatio)); result.put(RunningStats.commitLogDiskRatio.name() + "_" + clPath, String.valueOf(physicRatio));
minPhysicsUsedRatio = Math.min(minPhysicsUsedRatio, physicRatio); minPhysicsUsedRatio = Math.min(minPhysicsUsedRatio, physicRatio);
} }
result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(minPhysicsUsedRatio)); result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(minPhysicsUsedRatio));
} else { } else {
String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog(); String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog();
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic); double physicRatio = UtilAll.isPathExists(storePathPhysic) ?
UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic) : -1;
result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(physicRatio)); result.put(RunningStats.commitLogDiskRatio.name(), String.valueOf(physicRatio));
} }
{ {
String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()); String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir());
double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics); double logicsRatio = UtilAll.isPathExists(storePathLogics) ?
UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics) : -1;
result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio)); result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册