HDFS-12176. dfsadmin shows DFS Used%: NaN% if the cluster has zero block. Contributed by Weiwei Yang.
This commit is contained in:
parent
e315328428
commit
770cc46228
|
@ -520,8 +520,12 @@ public class DFSAdmin extends FsShell {
|
||||||
+ " (" + StringUtils.byteDesc(remaining) + ")");
|
+ " (" + StringUtils.byteDesc(remaining) + ")");
|
||||||
System.out.println("DFS Used: " + used
|
System.out.println("DFS Used: " + used
|
||||||
+ " (" + StringUtils.byteDesc(used) + ")");
|
+ " (" + StringUtils.byteDesc(used) + ")");
|
||||||
|
double dfsUsedPercent = 0;
|
||||||
|
if (presentCapacity != 0) {
|
||||||
|
dfsUsedPercent = used/(double)presentCapacity;
|
||||||
|
}
|
||||||
System.out.println("DFS Used%: "
|
System.out.println("DFS Used%: "
|
||||||
+ StringUtils.formatPercent(used/(double)presentCapacity, 2));
|
+ StringUtils.formatPercent(dfsUsedPercent, 2));
|
||||||
|
|
||||||
/* These counts are not always upto date. They are updated after
|
/* These counts are not always upto date. They are updated after
|
||||||
* iteration of an internal list. Should be updated in a few seconds to
|
* iteration of an internal list. Should be updated in a few seconds to
|
||||||
|
|
Loading…
Reference in New Issue