zongtanghu commented on a change in pull request #1144: [RIP-7] fix some issue
and Optimization code for multiple_disk_dir
URL: https://github.com/apache/rocketmq/pull/1144#discussion_r273312682
##########
File path: common/src/main/java/org/apache/rocketmq/common/UtilAll.java
##########
@@ -199,18 +199,20 @@ public static double
getDiskPartitionSpaceUsedPercent(final String path) {
if (null == path || path.isEmpty())
return -1;
+ String[] pathArr = path.trim().split(";");
try {
- File file = new File(path);
-
- if (!file.exists())
- return -1;
-
- long totalSpace = file.getTotalSpace();
-
+ long totalSpace = 0;
+ long freeSpace = 0;
+ for (int i = 0;i < pathArr.length;i++) {
+ File file = new File(pathArr[i]);
+ if (!file.exists()) {
+ continue;
+ }
+ totalSpace += file.getTotalSpace();
+ freeSpace += file.getFreeSpace();
+ }
if (totalSpace > 0) {
- long freeSpace = file.getFreeSpace();
long usedSpace = totalSpace - freeSpace;
-
return usedSpace / (double) totalSpace;
}
} catch (Exception e) {
Review comment:
Here,you can print the exception error info by using printStackTrace
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services