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

Chang Li commented on HDFS-6407:
--------------------------------

bq. parsing data pretty-formatted data and sorting them
I do not parse the formatted the data and then sort them.
currently dust template pull those data and format them, but I disable the 
format in my patch,
{code}
-    <td>{capacity|fmt_bytes}</td>
-    <td>{used|fmt_bytes}</td>
-    <td>{nonDfsUsedSpace|fmt_bytes}</td>
-    <td>{remaining|fmt_bytes}</td>
+    <td>{capacity}</td>
+    <td>{used}</td>
+    <td>{nonDfsUsedSpace}</td>
+    <td>{remaining}</td>
     <td>{numBlocks}</td>
-    <td>{blockPoolUsed|fmt_bytes} ({blockPoolUsedPercent|fmt_percentage})</td>
+    <td>{blockPoolUsed} ({blockPoolUsedPercent|fmt_percentage})</td>
{code}.
Thus data pulled by dust is stored in their raw formmat as in jmx in html table.
So dataTable sort those same data as in jmx.
When dataTable display those data, I use the render function of dataTable, 
which is able to take input data in the table and parse and display the 
formmatted the value of file size without changing the long formmatted data 
stored in html table.
{code}
+                "render": function ( data, type, full, meta) {
+                  var colIndex = meta.col;
+                  var v;
+                  if (colIndex == 8) { 
+                    var comp = data;
+                    var res = comp.split(" ");
+                    var percent = res[1];
+                    v = res[0];
+                  } else {
+                    v = data;
+                  }
+
+                  if (type == 'display') {
+                    //var v = data;
+                    var UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'ZB'];
+                    var prev = 0, i = 0;
+                    while (Math.floor(v) > 0 && i < UNITS.length) {
+                      prev = v;
+                      v /= 1024;
+                      i += 1;
+                    }
+
+                    if (i > 0 && i < UNITS.length) {
+                      v = prev;
+                      i -= 1;
+                    }
+                    var size = Math.round(v * 100) / 100 + ' ' + UNITS[i];
+                    if (colIndex == 8) {
+                      return size + ' ' + percent;
+                    } else {
+                      return size;
+                    }
+                  }
+                  return v; 
+                }
+             }]
+          });
{code}

I see you are worried about the error prone parsing issue, but I don't see it 
exist in my patch. Also loing the ability to sort in 2.7 and lost legacy UI is 
preventing my company from using 2.7. I think we should treat this issue as 
critical and not postpone it anymore.

> new namenode UI, lost ability to sort columns in datanode tab
> -------------------------------------------------------------
>
>                 Key: HDFS-6407
>                 URL: https://issues.apache.org/jira/browse/HDFS-6407
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>    Affects Versions: 2.4.0
>            Reporter: Nathan Roberts
>            Assignee: Benoy Antony
>            Priority: Minor
>              Labels: BB2015-05-TBR
>         Attachments: 002-datanodes-sorted-capacityUsed.png, 
> 002-datanodes.png, 002-filebrowser.png, 002-snapshots.png, 
> HDFS-6407-002.patch, HDFS-6407-003.patch, HDFS-6407.4.patch, 
> HDFS-6407.5.patch, HDFS-6407.patch, browse_directory.png, datanodes.png, 
> snapshots.png
>
>
> old ui supported clicking on column header to sort on that column. The new ui 
> seems to have dropped this very useful feature.
> There are a few tables in the Namenode UI to display  datanodes information, 
> directory listings and snapshots.
> When there are many items in the tables, it is useful to have ability to sort 
> on the different columns.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to