Skip to content

Commit 090780c

Browse files
karthikhwbusbey
authored andcommitted
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 commit 257ccad) (cherry picked from commit fe23e3f)
1 parent 54e46d2 commit 090780c

File tree

1 file changed

+22
-10
lines changed
  • hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util

1 file changed

+22
-10
lines changed

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/util/StringUtils.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private StringUtils() {}
2828

2929
public static String humanTimeDiff(long timeDiff) {
3030
if (timeDiff < 1000) {
31-
return String.format("%dmsec", timeDiff);
31+
return String.format("%d msec", timeDiff);
3232
}
3333

3434
StringBuilder buf = new StringBuilder();
@@ -40,26 +40,38 @@ public static String humanTimeDiff(long timeDiff) {
4040

4141
if (hours != 0){
4242
buf.append(hours);
43-
buf.append("hrs, ");
43+
buf.append(" hrs, ");
4444
}
4545
if (minutes != 0){
4646
buf.append(minutes);
47-
buf.append("mins, ");
47+
buf.append(" mins, ");
4848
}
4949
if (hours > 0 || minutes > 0) {
5050
buf.append(seconds);
51-
buf.append("sec");
51+
buf.append(" sec");
5252
} else {
53-
buf.append(String.format("%.4fsec", seconds));
53+
buf.append(String.format("%.4f sec", seconds));
5454
}
5555
return buf.toString();
5656
}
5757

5858
public static String humanSize(double size) {
59-
if (size >= (1L << 40)) return String.format("%.1fT", size / (1L << 40));
60-
if (size >= (1L << 30)) return String.format("%.1fG", size / (1L << 30));
61-
if (size >= (1L << 20)) return String.format("%.1fM", size / (1L << 20));
62-
if (size >= (1L << 10)) return String.format("%.1fK", size / (1L << 10));
59+
if (size >= (1L << 40)) {
60+
return String.format("%.1f T", size / (1L << 40));
61+
}
62+
63+
if (size >= (1L << 30)) {
64+
return String.format("%.1f G", size / (1L << 30));
65+
}
66+
67+
if (size >= (1L << 20)) {
68+
return String.format("%.1f M", size / (1L << 20));
69+
}
70+
71+
if (size >= (1L << 10)) {
72+
return String.format("%.1f K", size / (1L << 10));
73+
}
74+
6375
return String.format("%.0f", size);
6476
}
6577

@@ -81,4 +93,4 @@ public static StringBuilder appendStrings(final StringBuilder sb, final String..
8193
}
8294
return sb;
8395
}
84-
}
96+
}

0 commit comments

Comments
 (0)