hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haohui Mai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-6407) new namenode UI, lost ability to sort columns in datanode tab
Date Tue, 05 May 2015 19:51:00 GMT

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

Haohui Mai commented on HDFS-6407:
----------------------------------

{code}
+jQuery.fn.dataTable.ext.type.detect.unshift( function ( data ) {
+        if ( typeof data !== 'string' ) {
+                return null;
+        }
+
+        var units = data.replace( /[\d\.]/g, '' ).toLowerCase().trim();
+        if ( units !== '' && units !== 'b' && units !== 'kb' && units
!== 'mb' && units !== 'gb' && units !== 'tb' && units !== 'pb' ) {
+                return null;
+        }
+        return isNaN( parseFloat( data.trim() ) ) ?
+                null :
+                'file-size';
+} );
+
+jQuery.fn.dataTable.ext.type.detect.unshift( function ( data ) {
+        if ( typeof data !== 'string' ) {
+                return null;
+        }
+
+        var units = data.replace( /[\d\.\(\%\)]/g, '' ).toLowerCase().trim();
+        if ( units !== '' && units !== 'b' && units !== 'kb' && units
!== 'mb' && units !== 'gb' && units !== 'tb' && units !== 'pb' ) {
+                return null;
+        }
+        return isNaN( parseFloat( data.trim() ) ) ?
+                null :
+                'file-size-percent';
+} );
+
+/**
+ * When dealing with computer file sizes, it is common to append a post fix
+ * such as B, KB, MB or GB to a string in order to easily denote the order of
+ * magnitude of the file size. This plug-in allows sorting to take these
+ * indicates of size into account.
+ * 
+ * A counterpart type detection plug-in is also available.
+ *
+ *  @name File size
+ *  @summary Sort abbreviated file sizes correctly (8MB, 4KB, etc)
+ *  @author Allan Jardine - datatables.net
+ *
+ *  @example
+ *    $('#example').DataTable( {
+ *       columnDefs: [
+ *         { type: 'file-size', targets: 0 }
+ *       ]
+ *    } );
+ */
+
+jQuery.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
+    var units = data.replace( /[\d\.]/g, '' ).toLowerCase().trim();
+    var multiplier = 1;
+
+    if ( units === 'kb' ) {
+        multiplier = 1000;
+    }
+    else if ( units === 'mb' ) {
+        multiplier = 1000000;
+    }
+    else if ( units === 'gb' ) {
+        multiplier = 1000000000;
+    }
+    else if ( units === 'tb' ) {
+        multiplier = 1000000000000;
+    }
+    else if ( units === 'pb' ) {
+        multiplier = 1000000000000000;
+    }
+    return parseFloat( data ) * multiplier;
+};
+
+jQuery.fn.dataTable.ext.type.order['file-size-percent-pre'] = function ( data ) {
+    var units = data.replace( /[\d\.\(\%\)]/g, '' ).toLowerCase().trim();
+    var multiplier = 1;
+
+    if ( units === 'kb' ) {
+        multiplier = 1000;
+    }
+    else if ( units === 'mb' ) {
+        multiplier = 1000000;
+    }
+    else if ( units === 'gb' ) {
+        multiplier = 1000000000;
+    }
+    else if ( units === 'tb' ) {
+        multiplier = 1000000000000;
+    }
+    else if ( units === 'pb' ) {
+        multiplier = 1000000000000000;
+    }
+    return parseFloat( data ) * multiplier;
{code}

The data is available as 64-bit longs in the JMX output. The template engine generates the
strings.

Just to echo my previous comments -- reparsing the string is error-prone and should be avoided.

> 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
>         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.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)

Mime
View raw message