[ 
https://issues.apache.org/jira/browse/HDFS-13844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16591108#comment-16591108
 ] 

yanghuafeng edited comment on HDFS-13844 at 8/24/18 11:31 AM:
--------------------------------------------------------------

This patch has repaired two bugs.One bug is missing the EB. And another bug is 
unit overflow. For example, if you have the units ['B', 'KB', 'MB', 'GB'] with 
the 8192 GB capacity, you will get the "8 undefined" not better "8192 GB". 
Because according to the code,  when v equals 8192, the i equals units.length 
and UNITS[i]  will be undefined. 

{code:java}
while (Math.floor(v) > 0 && i < UNITS.length) { //when v = 8 and prev=8192, i = 
units.length
        prev = v;
        v /= 1024;
        i += 1;
      }
      if (i > 0 && i < UNITS.length) { //skip the step, because i = units.length
        v = prev;
        i -= 1;
      }
  return Math.round(v * 100) / 100 + ' ' + UNITS[i]; // units[i] will be 
undefined.
{code}

the overflow_unit.jpg is the fixed one, or the capacity will display undefined 
unit.


was (Author: hfyang20071):
This patch has repaired two bugs.One bug is missing the EB. And another bug is 
unit overflow. For example, if you have the units ['B', 'KB', 'MB', 'GB'] with 
the 8192 GB capacity, you will get the "8 undefined" not better "8192 GB". 
Because according to the code,  when v equals 8192, the i equals units.length 
and UNITS[i]  will be undefined. 

{code:java}
while (Math.floor(v) > 0 && i < UNITS.length) { //when v = 8 and prev=8192, i = 
units.length
        prev = v;
        v /= 1024;
        i += 1;
      }
      if (i > 0 && i < UNITS.length) { //skip the step, because i = units.length
        v = prev;
        i -= 1;
      }
  return Math.round(v * 100) / 100 + ' ' + UNITS[i]; // units[i] will be 
undefined.
{code}


> Refactor the fmt_bytes function in the dfs-dust.js.
> ---------------------------------------------------
>
>                 Key: HDFS-13844
>                 URL: https://issues.apache.org/jira/browse/HDFS-13844
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs, ui
>    Affects Versions: 1.2.0, 2.2.0, 2.7.2, 3.0.0, 3.1.0
>            Reporter: yanghuafeng
>            Assignee: yanghuafeng
>            Priority: Minor
>         Attachments: HDFS-13844.001.patch, overflow_undefined_unit.jpg, 
> overflow_unit.jpg, undefined_unit.jpg
>
>
> The namenode WebUI cannot display the capacity with correct units. I have 
> found that the function fmt_bytes in the dfs-dust.js missed the EB unit. This 
> will lead to undefined unit in the ui.
> And although the unit ZB is very large, we should take the unit overflow into 
> consideration. Supposing the last unit is GB, we should get the 8192 GB with 
> the total capacity 8T rather than 8 undefined.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to