This is an automated email from the ASF dual-hosted git repository.

pankajkumar pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new bbad0be604d HBASE-28997 Table Regions Total Locality value on the UI 
shows 1.0 even though some of the regions locality value is zero (#6840)
bbad0be604d is described below

commit bbad0be604dea06a55a80d1f9feb1223e990b55d
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]>
    (cherry picked from commit bbbee92ec3706b86f507cb2fcffb4fa91da6016b)
---
 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 3ddea5563d1..cda8bb036c0 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"
@@ -931,10 +933,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">

Reply via email to