浏览代码

AMBARI-3087. Ambari dashboard does not update when datanodes are lost. (xiwang via yusaku)

Yusaku Sako 11 年之前
父节点
当前提交
96751430b7

+ 14 - 9
ambari-web/app/views/main/dashboard/widgets/datanode_live.js

@@ -30,26 +30,31 @@ App.DataNodeUpView = App.TextDashboardWidgetView.extend({
 
   hiddenInfo: function () {
     var result = [];
-    result.pushObject( App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED").length
-      + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.live'));
-    result.pushObject( App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","INSTALLED").length
-      + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.dead'));
+    result.pushObject(this.get('dataNodesLive').length + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.live'));
+    result.pushObject(this.get('dataNodesDead').length + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.dead'));
     result.pushObject(this.get('model.decommissionDataNodes.length')+ ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.decom'));
     return result;
-  }.property('model', 'model.decommissionDataNodes.length'),
+  }.property('dataNodesLive', 'dataNodesDead', 'model.decommissionDataNodes.length'),
   hiddenInfoClass: "hidden-info-three-line",
 
   thresh1: 40,
   thresh2: 70,
   maxValue: 100,
 
+  dataNodesLive: function(){
+    return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED");
+  }.property('model.hostComponents.@each'),
+  dataNodesDead: function(){
+    return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","INSTALLED");
+  }.property('model.hostComponents.@each'),
+
   data: function () {
-    return ((App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED").length / this.get('model.dataNodes.length')).toFixed(2)) * 100;
-  }.property('model.dataNodes.length', 'model'),
+    return ((this.get('dataNodesLive').length / this.get('model.dataNodes.length')).toFixed(2)) * 100;
+  }.property('model.dataNodes.length', 'dataNodesLive'),
 
   content: function () {
-    return App.HostComponent.find().filterProperty('componentName', 'DATANODE').filterProperty("workStatus","STARTED").length + "/" + this.get('model.dataNodes.length');
-  }.property('model.dataNodes.length', 'model'),
+    return this.get('dataNodesLive').length + "/" + this.get('model.dataNodes.length');
+  }.property('model.dataNodes.length', 'dataNodesLive'),
 
   editWidget: function (event) {
     var parent = this;

+ 10 - 6
ambari-web/app/views/main/dashboard/widgets/tasktracker_live.js

@@ -27,25 +27,29 @@ App.TaskTrackerUpView = App.TextDashboardWidgetView.extend({
 
   hiddenInfo: function () {
     var svc = this.get('model');
-    var liveCount = App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED").length;
+    var liveCount = this.get('taskTrackersLive').length;
     var totalCount = svc.get('taskTrackers').get('length');
     var result = [];
     result.pushObject(liveCount + " live");
     result.pushObject(totalCount + " total");
     return result;
-  }.property('model.aliveTrackers.length', 'model.taskTrackers.length'),
+  }.property('model.taskTrackers.length', 'taskTrackersLive'),
 
   thresh1: 40,
   thresh2: 70,
   maxValue: 100,
 
+  taskTrackersLive: function(){
+    return App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED");
+  }.property('model.hostComponents.@each'),
+
   data: function () {
-    return ( App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED").length / this.get('model.taskTrackers.length')).toFixed(2) * 100;
-  }.property('model.taskTrackers.length', 'model.aliveTrackers.length'),
+    return (this.get('taskTrackersLive').length / this.get('model.taskTrackers.length')).toFixed(2) * 100;
+  }.property('model.taskTrackers.length', 'taskTrackersLive'),
 
   content: function () {
-    return App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED").length + "/" + this.get('model.taskTrackers.length');
-  }.property('model.taskTrackers.length', 'model.aliveTrackers.length'),
+    return this.get('taskTrackersLive').length + "/" + this.get('model.taskTrackers.length');
+  }.property('model.taskTrackers.length', 'taskTrackersLive'),
 
   editWidget: function (event) {
     var parent = this;