瀏覽代碼

AMBARI-12661. Infinity spinner on HDFS summary page (alexantonenko)

Alex Antonenko 10 年之前
父節點
當前提交
aa930751b2

+ 2 - 1
ambari-web/app/mappers/service_mapper.js

@@ -52,7 +52,8 @@ App.serviceMapper = App.QuickDataMapper.create({
 
     if (!this.get('initialAppLoad')) {
       var parsedCacheServices = App.cache['services'].map(function(item){
-         return self.parseIt(item, self.get('config'));
+        App.serviceMetricsMapper.mapExtendedModel(item);
+        return self.parseIt(item, self.get('config'));
       });
       App.store.loadMany(this.get('model'), parsedCacheServices);
       App.store.commit();

+ 47 - 41
ambari-web/app/mappers/service_metrics_mapper.js

@@ -227,8 +227,6 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
 
       //parse service metrics from components
       services.forEach(function (item) {
-        var finalJson = [];
-
         hostComponents.filterProperty('service_id', item.ServiceInfo.service_name).mapProperty('id').forEach(function (hostComponent) {
           if (!item.host_components.contains(hostComponent)) {
             item.host_components.push(hostComponent);
@@ -236,43 +234,9 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
         }, this);
         item.host_components.sort();
 
-        if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {
-          finalJson = this.hdfsMapper(item);
-          finalJson.rand = Math.random();
-          result.push(finalJson);
-          App.store.load(App.HDFSService, finalJson);
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HBASE") {
-          finalJson = this.hbaseMapper(item);
-          finalJson.rand = Math.random();
-          result.push(finalJson);
-          App.store.load(App.HBaseService, finalJson);
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "FLUME") {
-          finalJson = this.flumeMapper(item);
-          finalJson.rand = Math.random();
-          result.push(finalJson);
-          App.store.load(App.FlumeService, finalJson);
-          App.store.loadMany(App.FlumeAgent, finalJson.agentJsons);
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "YARN") {
-          finalJson = this.yarnMapper(item);
-          finalJson.rand = Math.random();
-          result.push(finalJson);
-          App.store.load(App.YARNService, finalJson);
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE2") {
-          finalJson = this.mapreduce2Mapper(item);
-          finalJson.rand = Math.random();
-          result.push(finalJson);
-          App.store.load(App.MapReduce2Service, finalJson);
-        } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "STORM") {
-          finalJson = this.stormMapper(item);
-          finalJson.rand = Math.random();
-          this.mapQuickLinks(finalJson, item);
-          result.push(finalJson);
-          App.store.load(App.StormService, finalJson);
-        } else {
-          finalJson = this.parseIt(item, this.config);
-          finalJson.rand = Math.random();
-          this.mapQuickLinks(finalJson, item);
-          result.push(finalJson);
+        var extendedModelInfo = this.mapExtendedModel(item);
+        if (extendedModelInfo) {
+          result.push(extendedModelInfo);
         }
       }, this);
 
@@ -284,6 +248,50 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     }
     console.timeEnd('App.serviceMetricsMapper execution time');
   },
+
+  /**
+   * Generate service mapped object and load data to extended models.
+   *
+   * @method mapExtendedModel
+   * @param {Object} item - json presents service information
+   * @returns {Boolean|Object} - mapped info
+   */
+  mapExtendedModel: function(item) {
+    var finalJson = false;
+    if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {
+      finalJson = this.hdfsMapper(item);
+      finalJson.rand = Math.random();
+      App.store.load(App.HDFSService, finalJson);
+    } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HBASE") {
+      finalJson = this.hbaseMapper(item);
+      finalJson.rand = Math.random();
+      App.store.load(App.HBaseService, finalJson);
+    } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "FLUME") {
+      finalJson = this.flumeMapper(item);
+      finalJson.rand = Math.random();
+      App.store.load(App.FlumeService, finalJson);
+      App.store.loadMany(App.FlumeAgent, finalJson.agentJsons);
+    } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "YARN") {
+      finalJson = this.yarnMapper(item);
+      finalJson.rand = Math.random();
+      App.store.load(App.YARNService, finalJson);
+    } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE2") {
+      finalJson = this.mapreduce2Mapper(item);
+      finalJson.rand = Math.random();
+      App.store.load(App.MapReduce2Service, finalJson);
+    } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "STORM") {
+      finalJson = this.stormMapper(item);
+      finalJson.rand = Math.random();
+      this.mapQuickLinks(finalJson, item);
+      App.store.load(App.StormService, finalJson);
+    } else {
+      finalJson = this.parseIt(item, this.config);
+      finalJson.rand = Math.random();
+      this.mapQuickLinks(finalJson, item);
+    }
+
+    return finalJson;
+  },
   /**
    * compute display name of host-components
    * compute tooltip content of services by host-components
@@ -473,7 +481,6 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
   },
 
   yarnMapper: function (item) {
-    var result = [];
     var self = this;
     var finalConfig = jQuery.extend({}, this.config);
     // Change the JSON so that it is easy to map
@@ -525,7 +532,6 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
   },
 
   mapreduce2Mapper: function (item) {
-    var result = [];
     var finalConfig = jQuery.extend({}, this.config);
     // Change the JSON so that it is easy to map
     var mapReduce2Config = this.mapReduce2Config;

+ 5 - 5
ambari-web/app/views/main/service/service.js

@@ -125,16 +125,16 @@ App.MainDashboardServiceView = Em.View.extend({
     return this.get('controller.data.' + this.get('serviceName'));
   }.property('controller.data'),
 
-  dashboardMasterComponentView : Em.View.extend({
+  dashboardMasterComponentView: Em.View.extend({
     didInsertElement: function() {
-      App.tooltip($('[rel=healthTooltip]'));
+      App.tooltip($('[rel=SummaryComponentHealthTooltip]'));
     },
     templateName: require('templates/main/service/info/summary/master_components'),
     mastersComp: function () {
-      return this.get('parentView.service.hostComponents').filterProperty('isMaster', true);
-    }.property("service"),
+      return this.get('parentView.parentView.mastersObj');
+    }.property("parentView.parentView.mastersObj"),
     willDestroyElement: function() {
-      $('[rel=healthTooltip]').tooltip('destroy');
+      $('[rel=SummaryComponentHealthTooltip]').tooltip('destroy');
     }
   }),
 

+ 2 - 5
ambari-web/app/views/main/service/services/hbase.js

@@ -56,11 +56,8 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({
   }.property("service"),
 
   showPhoenixInfo: function () {
-    if (this.get('service.phoenixServersTotal') > 0) {
-      return true;
-    }
-    return false;
-  }.property("service"),
+    return !!this.get('service.phoenixServersTotal');
+  }.property("service.phoenixServersTotal"),
 
   /**
    * One(!) active master component