This is an automated email from the ASF dual-hosted git repository.
pankajkumar pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new bbbee92ec37 HBASE-28997 Table Regions Total Locality value on the UI
shows 1.0 even though some of the regions locality value is zero (#6840)
bbbee92ec37 is described below
commit bbbee92ec3706b86f507cb2fcffb4fa91da6016b
Author: Chandra Sekhar K <[email protected]>
AuthorDate: Wed Apr 2 23:19:25 2025 +0530
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 <[email protected]>
Signed-off-by: Pankaj Kumar<[email protected]>
---
hbase-server/src/main/resources/hbase-webapps/master/table.jsp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
index 1fbcc659148..5ffaa44387d 100644
--- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
+++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
@@ -29,6 +29,8 @@
import="java.util.Optional"
import="java.util.TreeMap"
import="java.util.concurrent.TimeUnit"
+ import="java.text.DecimalFormat"
+ import="java.math.RoundingMode"
import="org.apache.commons.lang3.StringEscapeUtils"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.HConstants"
@@ -928,10 +930,10 @@
((float) totalCompactedCells / totalCompactingCells)) + "%";
}
if (totalBlocksTotalWeight > 0) {
- totalLocality = String.format("%.1f",
- ((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
- totalLocalityForSsd = String.format("%.1f",
- ((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
+ DecimalFormat df = new DecimalFormat("0.0#");
+ df.setRoundingMode(RoundingMode.DOWN);
+ totalLocality = df.format(((float) totalBlocksLocalWeight /
totalBlocksTotalWeight));
+ totalLocalityForSsd = df.format(((float) totalBlocksLocalWithSsdWeight /
totalBlocksTotalWeight));
}
if(regions != null && regions.size() > 0) { %>
<div class="row">