PDavid commented on code in PR #6585:
URL: https://github.com/apache/hbase/pull/6585#discussion_r1908806229


##########
hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp:
##########
@@ -134,14 +134,14 @@
   <div class="row">
     <div class="span12">
     <%= stats.getStoreFilesCount() %> HFiles (<%= 
stats.getArchivedStoreFilesCount() %> in archive),
-    total size <%= StringUtils.humanReadableInt(stats.getStoreFilesSize()) %>
+    total size <%= 
StringUtils.TraditionalBinaryPrefix.long2String(stats.getStoreFilesSize(), "", 
1) %>

Review Comment:
   > I am not sure we have any tests for these. 
   
   Yeah I think this is the problem with the JSP UI that we don't have tests 
for it and I'm not sure how to add tests.
   
   Maybe we could extract the inline Java code from the JSP-s to "backing 
beans" (some Java classes) which is then called by JSP-s. But this is not a 
small task.
   
   > Please verify both functions work in same way.
   
   This is actually the implementation of the 
`org.apache.hadoop.util.StringUtils.humanReadableInt(long)` method:
   
   ```java
     /**
      * Given an integer, return a string that is in an approximate, but human 
      * readable format. 
      * @param number the number to format
      * @return a human readable form of the integer
      *
      * @deprecated use {@link TraditionalBinaryPrefix#long2String(long, 
String, int)}.
      */
     @Deprecated
     public static String humanReadableInt(long number) {
       return TraditionalBinaryPrefix.long2String(number, "", 1);
     }
   ```
   
   See: 
https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java#L133
   
   Of course to make this a bit nicer we could introduce a utility method in 
Java code and call that from the JSP. What do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to