Browse Source

HDFS-15013. Reduce NameNode overview tab response time. Contributed by HuangTao.

Surendra Singh Lilhore 5 years ago
parent
commit
44f7b9159d
1 changed files with 15 additions and 2 deletions
  1. 15 2
      hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.js

+ 15 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.js

@@ -65,8 +65,9 @@
     };
 
     var data = {};
+    var non_ha = false;
 
-    $.ajax({'url': '/conf', 'dataType': 'xml', 'async': false}).done(
+    $.ajax({'url': '/conf', 'dataType': 'xml', 'async': true}).done(
       function(d) {
         var $xml = $(d);
         var namespace, nnId;
@@ -80,6 +81,8 @@
         });
         if (namespace && nnId) {
           data['HAInfo'] = {"Namespace": namespace, "NamenodeID": nnId};
+        } else {
+          non_ha = true;
         }
     });
 
@@ -109,7 +112,17 @@
 
         data.fs.ObjectsTotal = data.fs.FilesTotal + data.fs.BlocksTotal;
 
-        render();
+        var wait_for_conf =  setInterval(function() {
+          if (non_ha ||
+              (('HAInfo' in data) &&
+                  ("Namespace" in data['HAInfo']) &&
+                  ("NamenodeID" in data['HAInfo'])
+              )
+          ) {
+            render();
+            clearInterval(wait_for_conf);
+          }
+        }, 5);
       }),
       function (url, jqxhr, text, err) {
         show_err_msg('<p>Failed to retrieve data from ' + url + ', cause: ' + err + '</p>');