Skip to content

Commit fa2ee73

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 (#6492)
Signed-off-by: Nihal Jain <nihaljain@apache.org> Signed-off-by: Pankaj Kumar<pankajkumar@apache.org>
1 parent 1f6ad4d commit fa2ee73

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
@@ -30,6 +30,8 @@
3030
import="java.util.Optional"
3131
import="java.util.TreeMap"
3232
import="java.util.concurrent.TimeUnit"
33+
import="java.text.DecimalFormat"
34+
import="java.math.RoundingMode"
3335
import="org.apache.commons.lang3.StringEscapeUtils"
3436
import="org.apache.hadoop.conf.Configuration"
3537
import="org.apache.hadoop.hbase.HConstants"
@@ -927,10 +929,10 @@
927929
((float) totalCompactedCells / totalCompactingCells)) + "%";
928930
}
929931
if (totalBlocksTotalWeight > 0) {
930-
totalLocality = String.format("%.1f",
931-
((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
932-
totalLocalityForSsd = String.format("%.1f",
933-
((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
932+
DecimalFormat df = new DecimalFormat("0.0#");
933+
df.setRoundingMode(RoundingMode.DOWN);
934+
totalLocality = df.format(((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
935+
totalLocalityForSsd = df.format(((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
934936
}
935937
if(regions != null && regions.size() > 0) { %>
936938
<div class="row">

0 commit comments

Comments
 (0)