HBASE-23208 Unit formatting in Master & RS UI
Signed-off-by: binlijin <binlijin@gmail.com> Signed-off-by: Sean Busbey <busbey@apache.org> (cherry picked from commit257ccad31c
) (cherry picked from commitfe23e3fd5b
)
This commit is contained in:
parent
54e46d2e1b
commit
090780c5bd
|
@ -56,10 +56,22 @@ public final class StringUtils {
|
|||
}
|
||||
|
||||
public static String humanSize(double size) {
|
||||
if (size >= (1L << 40)) return String.format("%.1fT", size / (1L << 40));
|
||||
if (size >= (1L << 30)) return String.format("%.1fG", size / (1L << 30));
|
||||
if (size >= (1L << 20)) return String.format("%.1fM", size / (1L << 20));
|
||||
if (size >= (1L << 10)) return String.format("%.1fK", size / (1L << 10));
|
||||
if (size >= (1L << 40)) {
|
||||
return String.format("%.1f T", size / (1L << 40));
|
||||
}
|
||||
|
||||
if (size >= (1L << 30)) {
|
||||
return String.format("%.1f G", size / (1L << 30));
|
||||
}
|
||||
|
||||
if (size >= (1L << 20)) {
|
||||
return String.format("%.1f M", size / (1L << 20));
|
||||
}
|
||||
|
||||
if (size >= (1L << 10)) {
|
||||
return String.format("%.1f K", size / (1L << 10));
|
||||
}
|
||||
|
||||
return String.format("%.0f", size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue