Skip to content

Commit bbbee92

Browse files
HBASE-28997 Table Regions Total Locality value on the UI shows 1.0 even though some of the regions locality value is zero (#6840)
Signed-off-by: Nihal Jain <nihaljain@apache.org> Signed-off-by: Pankaj Kumar<pankajkumar@apache.org>
1 parent c20de4a commit bbbee92

File tree

1 file changed

+6
-4
lines changed
  • hbase-server/src/main/resources/hbase-webapps/master

1 file changed

+6
-4
lines changed

hbase-server/src/main/resources/hbase-webapps/master/table.jsp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import="java.util.Optional"
3030
import="java.util.TreeMap"
3131
import="java.util.concurrent.TimeUnit"
32+
import="java.text.DecimalFormat"
33+
import="java.math.RoundingMode"
3234
import="org.apache.commons.lang3.StringEscapeUtils"
3335
import="org.apache.hadoop.conf.Configuration"
3436
import="org.apache.hadoop.hbase.HConstants"
@@ -928,10 +930,10 @@
928930
((float) totalCompactedCells / totalCompactingCells)) + "%";
929931
}
930932
if (totalBlocksTotalWeight > 0) {
931-
totalLocality = String.format("%.1f",
932-
((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
933-
totalLocalityForSsd = String.format("%.1f",
934-
((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
933+
DecimalFormat df = new DecimalFormat("0.0#");
934+
df.setRoundingMode(RoundingMode.DOWN);
935+
totalLocality = df.format(((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
936+
totalLocalityForSsd = df.format(((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
935937
}
936938
if(regions != null && regions.size() > 0) { %>
937939
<div class="row">

0 commit comments

Comments
 (0)