hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject hadoop git commit: HDFS-13187. RBF: Fix Routers information shown in the web UI. Contributed by Inigo Goiri and Wei Yan.
Date Mon, 26 Feb 2018 23:35:57 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 0945f0eb2 -> 54803ebe4


HDFS-13187. RBF: Fix Routers information shown in the web UI. Contributed by Inigo Goiri and
Wei Yan.

(cherry picked from commit 6ce9f79cc9b2107e5953a39d05b22966aff0b7ff)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/54803ebe
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/54803ebe
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/54803ebe

Branch: refs/heads/branch-2
Commit: 54803ebe492e04e5b531904233e60e7abcea4698
Parents: 0945f0e
Author: Wei Yan <weiy@apache.org>
Authored: Mon Feb 26 15:13:41 2018 -0800
Committer: weiy <weiy@apache.org>
Committed: Mon Feb 26 15:32:27 2018 -0800

----------------------------------------------------------------------
 .../main/webapps/router/federationhealth.html   |  4 ++
 .../src/main/webapps/router/federationhealth.js | 64 ++++++++++++++++----
 2 files changed, 57 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/54803ebe/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.html
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.html
b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.html
index b89e5aa..23d42d3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.html
@@ -35,6 +35,7 @@
   <ul class="nav navbar-nav" id="ui-tabs">
     <li><a href="#tab-overview">Overview</a></li>
     <li><a href="#tab-namenode">Subclusters</a></li>
+    <li><a href="#tab-router">Routers</a></li>
     <li><a href="#tab-datanode">Datanodes</a></li>
     <li><a href="#tab-mounttable">Mount table</a></li>
     <li class="dropdown">
@@ -62,6 +63,7 @@
 <div class="tab-content">
   <div class="tab-pane" id="tab-overview"></div>
   <div class="tab-pane" id="tab-namenode"></div>
+  <div class="tab-pane" id="tab-router"></div>
   <div class="tab-pane" id="tab-datanode"></div>
   <div class="tab-pane" id="tab-mounttable"></div>
 </div>
@@ -245,6 +247,8 @@
 </small>
 </script>
 
+<!-- Routers -->
+<script type="text/x-dust-template" id="tmpl-router">
 <div class="page-header"><h1>Routers Information</h1></div>
 <div>
   <ul class="dfshealth-node-legend">

http://git-wip-us.apache.org/repos/asf/hadoop/blob/54803ebe/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.js
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.js b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.js
index 344b93f..c054fde 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.js
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/router/federationhealth.js
@@ -20,6 +20,7 @@
 
   dust.loadSource(dust.compile($('#tmpl-federationhealth').html(), 'federationhealth'));
   dust.loadSource(dust.compile($('#tmpl-namenode').html(), 'namenode-info'));
+  dust.loadSource(dust.compile($('#tmpl-router').html(), 'router-info'));
   dust.loadSource(dust.compile($('#tmpl-datanode').html(), 'datanode-info'));
   dust.loadSource(dust.compile($('#tmpl-mounttable').html(), 'mounttable'));
 
@@ -133,6 +134,48 @@
         }
       }
 
+      r.Nameservices = node_map_to_array(JSON.parse(r.Nameservices));
+      augment_namenodes(r.Nameservices);
+      r.Namenodes = node_map_to_array(JSON.parse(r.Namenodes));
+      augment_namenodes(r.Namenodes);
+      return r;
+    }
+
+    $.get(
+      '/jmx?qry=Hadoop:service=Router,name=FederationState',
+      guard_with_startup_progress(function (resp) {
+        var data = workaround(resp.beans[0]);
+        var base = dust.makeBase(HELPERS);
+        dust.render('namenode-info', base.push(data), function(err, out) {
+          $('#tab-namenode').html(out);
+          $('#ui-tabs a[href="#tab-namenode"]').tab('show');
+        });
+      })).error(ajax_error_handler);
+  }
+
+  function load_router_info() {
+    var HELPERS = {
+      'helper_lastcontact_tostring' : function (chunk, ctx, bodies, params) {
+        var value = dust.helpers.tap(params.value, chunk, ctx);
+        return chunk.write('' + new Date(Date.now()-1000*Number(value)));
+      }
+    };
+
+    function workaround(r) {
+      function node_map_to_array(nodes) {
+        var res = [];
+        for (var n in nodes) {
+          var p = nodes[n];
+          p.name = n;
+          res.push(p);
+        }
+        return res;
+      }
+
+      function capitalise(string) {
+          return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
+      }
+
       function augment_routers(nodes) {
         for (var i = 0, e = nodes.length; i < e; ++i) {
           var n = nodes[i];
@@ -157,10 +200,6 @@
         }
       }
 
-      r.Nameservices = node_map_to_array(JSON.parse(r.Nameservices));
-      augment_namenodes(r.Nameservices);
-      r.Namenodes = node_map_to_array(JSON.parse(r.Namenodes));
-      augment_namenodes(r.Namenodes);
       r.Routers = node_map_to_array(JSON.parse(r.Routers));
       augment_routers(r.Routers);
       return r;
@@ -171,9 +210,9 @@
       guard_with_startup_progress(function (resp) {
         var data = workaround(resp.beans[0]);
         var base = dust.makeBase(HELPERS);
-        dust.render('namenode-info', base.push(data), function(err, out) {
-          $('#tab-namenode').html(out);
-          $('#ui-tabs a[href="#tab-namenode"]').tab('show');
+        dust.render('router-info', base.push(data), function(err, out) {
+          $('#tab-router').html(out);
+          $('#ui-tabs a[href="#tab-router"]').tab('show');
         });
       })).error(ajax_error_handler);
   }
@@ -314,17 +353,20 @@
   function load_page() {
     var hash = window.location.hash;
     switch(hash) {
-      case "#tab-mounttable":
-        load_mount_table();
+      case "#tab-overview":
+        load_overview();
         break;
       case "#tab-namenode":
         load_namenode_info();
         break;
+      case "#tab-router":
+        load_router_info();
+        break;
       case "#tab-datanode":
         load_datanode_info();
         break;
-      case "#tab-overview":
-        load_overview();
+      case "#tab-mounttable":
+        load_mount_table();
         break;
       default:
         window.location.hash = "tab-overview";


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message