Skip to content

Commit bbad0be

Browse files
chandrasekhar-188kpankaj72981
authored andcommitted
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> (cherry picked from commit bbbee92)
1 parent 6e24cd2 commit bbad0be

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"
@@ -931,10 +933,10 @@
931933
((float) totalCompactedCells / totalCompactingCells)) + "%";
932934
}
933935
if (totalBlocksTotalWeight > 0) {
934-
totalLocality = String.format("%.1f",
935-
((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
936-
totalLocalityForSsd = String.format("%.1f",
937-
((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
936+
DecimalFormat df = new DecimalFormat("0.0#");
937+
df.setRoundingMode(RoundingMode.DOWN);
938+
totalLocality = df.format(((float) totalBlocksLocalWeight / totalBlocksTotalWeight));
939+
totalLocalityForSsd = df.format(((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight));
938940
}
939941
if(regions != null && regions.size() > 0) { %>
940942
<div class="row">

0 commit comments

Comments
 (0)