Browse Source

AMBARI-1157. Host component operation causes lags in status/action pulldown update. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431848 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
7bc1164764

+ 3 - 0
CHANGES.txt

@@ -692,6 +692,9 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1157. Host component operation causes lags in status/action pulldown
+  update. (yusaku)
+
   AMBARI-1144. Cannot save changes to ZooKeeper configuration.
   (Arun Kandregula via yusaku)
 

+ 5 - 5
ambari-web/app/controllers/main/host/details.js

@@ -74,7 +74,7 @@ App.MainHostDetailsController = Em.Controller.extend({
     });
   },
 
-  startComponent: function(event){
+  startComponent: function (event) {
     var self = this;
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.host.start.popup.header'),
@@ -96,7 +96,7 @@ App.MainHostDetailsController = Em.Controller.extend({
 
           console.log('Send request for STARTING successfully');
 
-          if(App.testMode){
+          if (App.testMode) {
             component.set('workStatus', App.Component.Status.starting);
             setTimeout(function(){
               component.set('workStatus', App.Component.Status.started);
@@ -126,7 +126,7 @@ App.MainHostDetailsController = Em.Controller.extend({
       }
     });
   },
-  stopComponent: function(event){
+  stopComponent: function (event) {
     var self = this;
     App.ModalPopup.show({
       header: Em.I18n.t('hosts.host.start.popup.header'),
@@ -147,12 +147,12 @@ App.MainHostDetailsController = Em.Controller.extend({
 
           console.log('Send request for STOPPING successfully');
 
-          if(App.testMode){
+          if (App.testMode) {
             component.set('workStatus', App.Component.Status.stopping);
             setTimeout(function(){
               component.set('workStatus', App.Component.Status.stopped);
             },10000);
-          } else{
+          } else {
             App.router.get('clusterController').loadUpdatedStatus();
             App.router.get('backgroundOperationsController.eventsArray').push({
               "when" : function(controller){

+ 13 - 0
ambari-web/app/mappers/server_data_mapper.js

@@ -108,5 +108,18 @@ App.QuickDataMapper = App.ServerDataMapper.extend({
       pathArr.splice(0, 1);
     }
     return current;
+  },
+
+  calculateState: function (json) {
+    var stateEqual = (json.desired_status != json.work_status);
+    if (stateEqual) {
+      if (json.desired_status == 'STARTED' && json.work_status == 'INSTALLED') {
+        json.work_status = 'STARTING';
+      } else if (json.desired_status == 'INSTALLED' && json.work_status == 'STARTED') {
+        json.work_status = 'STOPPING';
+      }
+    }
+
+    return json;
   }
 });

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

@@ -127,7 +127,6 @@ App.servicesMapper = App.QuickDataMapper.create({
     // page must be careful because, it will randomly
     // pick a host.
     work_status: 'host_components[0].HostRoles.state',
-    desired_status: 'host_components[0].HostRoles.desired_state',
     host_id: 'host_components[0].HostRoles.host_name'
   },
 
@@ -209,7 +208,6 @@ App.servicesMapper = App.QuickDataMapper.create({
         if (component && component.get('isLoaded')) { // UPDATE
           if (componentJson.work_status) {
             component.set('workStatus', componentJson.work_status);
-            component.set('desiredStatus', componentJson.desired_status);
           }
           if (componentJson.host_id) {
             component.set('host', App.Host.find(componentJson.host_id));
@@ -233,12 +231,12 @@ App.servicesMapper = App.QuickDataMapper.create({
       }, this);
       var newHostComponents = [];
       result.forEach(function(hcJson){
+        hcJson = this.calculateState(hcJson);
         hcJson.id = hcJson.component_name + '_' + hcJson.host_id;
         var component = App.HostComponent.find(hcJson.id);
         if (component && component.get('isLoaded')) { // UPDATE
           if (hcJson.work_status) {
             component.set('workStatus', hcJson.work_status);
-            component.set('desiredStatus', hcJson.desired_status);
           }
           if (hcJson.component_name) {
             component.set('componentName', hcJson.component_name);
@@ -252,7 +250,7 @@ App.servicesMapper = App.QuickDataMapper.create({
         } else {
           newHostComponents.push(hcJson);
         }
-      });
+      }, this);
       if (newHostComponents.length > 0) {
         App.store.loadMany(this.get('model3'), newHostComponents);
       }

+ 3 - 5
ambari-web/app/mappers/status_mapper.js

@@ -24,8 +24,7 @@ App.statusMapper = App.QuickDataMapper.create({
 
   config2:{
     id:'ServiceComponentInfo.component_name',
-    work_status:'host_components[0].HostRoles.state',
-    desired_status: 'host_components[0].HostRoles.desired_state'
+    work_status:'host_components[0].HostRoles.state'
   },
 
   config3:{
@@ -73,7 +72,6 @@ App.statusMapper = App.QuickDataMapper.create({
         var component = components.findProperty('id', item.id);
         if(component){
           component.set('workStatus', item.work_status);
-          component.set('desiredStatus', item.desired_status);
         }
       })
 
@@ -91,10 +89,10 @@ App.statusMapper = App.QuickDataMapper.create({
       result.forEach(function(item){
         var hostComponent = hostComponents.findProperty('id', item.id);
         if(hostComponent){
+          item = this.calculateState(item);
           hostComponent.set('workStatus', item.work_status);
-          hostComponent.set('desiredStatus', item.desired_status);
         }
-      })
+      }, this)
     }
   }
 });

+ 1 - 3
ambari-web/app/models/component.js

@@ -33,9 +33,7 @@ App.Component = DS.Model.extend({
   //host_id: DS.attr('string'),
 
   workStatus: DS.attr('string'),
-  
-  desiredStatus: DS.attr('string'),
-  
+
   isMaster: function () {
     switch (this.get('componentName')) {
       case 'NAMENODE':

+ 3 - 3
ambari-web/app/models/host.js

@@ -129,8 +129,8 @@ App.Host = DS.Model.extend({
     if (!this.get('isLoaded') || this.get('isSaving')) {
     } else {
       var status;
-      var masterComponents = this.get('components').filterProperty('isMaster', true);
-      var masterComponentsRunning = masterComponents.everyProperty('workStatus', App.Component.Status.started);
+      var masterComponents = this.get('hostComponents').filterProperty('isMaster', true);
+      var masterComponentsRunning = masterComponents.everyProperty('workStatus', App.HostComponent.Status.started);
       if (this.get('isNotHeartBeating')) {
         status = 'DEAD-YELLOW';
       } else if (masterComponentsRunning) {
@@ -145,7 +145,7 @@ App.Host = DS.Model.extend({
       }
     }
     return 'health-status-' + healthStatus;
-  }.property('healthStatus', 'components.@each.workStatus')
+  }.property('healthStatus', 'hostComponents.@each.workStatus')
 });
 
 App.Host.FIXTURES = [];

+ 0 - 1
ambari-web/app/models/host_component.js

@@ -20,7 +20,6 @@ var App = require('app');
 
 App.HostComponent = DS.Model.extend({
   workStatus: DS.attr('string'),
-  desiredStatus: DS.attr('string'),
   componentName: DS.attr('string'),
   host: DS.belongsTo('App.Host'),
   service: DS.belongsTo('App.Service'),

+ 5 - 11
ambari-web/app/models/service.js

@@ -38,23 +38,17 @@ App.Service = DS.Model.extend({
   }.property('healthStatus'),
 
   healthStatus: function () {
-    var components = this.get('components').filterProperty('isMaster', true);
-    if (components.everyProperty('workStatus', App.Component.Status.started)) {
-      if (components.someProperty('desiredStatus', App.Component.Status.stopped)) {
-        return 'red-blinking';
-      }
+    var components = this.get('hostComponents').filterProperty('isMaster', true);
+    if (components.everyProperty('workStatus', App.HostComponent.Status.started)) {
       return 'green';
-    } else if (components.someProperty('workStatus', App.Component.Status.starting)) {
+    } else if (components.someProperty('workStatus', App.HostComponent.Status.starting)) {
       return 'green-blinking';
-    } else if (components.someProperty('workStatus', App.Component.Status.stopped)) {
-      if (components.someProperty('desiredStatus', App.Component.Status.started)) {
-        return 'green-blinking';
-      }
+    } else if (components.someProperty('workStatus', App.HostComponent.Status.stopped)) {
       return 'red';
     } else {
       return 'red-blinking';
     }
-  }.property('components.@each.workStatus'),
+  }.property('hostComponents.@each.workStatus'),
 
   isStopped: function () {
     var components = this.get('components');

+ 11 - 20
ambari-web/app/views/main/host/summary.js

@@ -122,6 +122,11 @@ App.MainHostSummaryView = Em.View.extend({
 
   ComponentView: Em.View.extend({
     content: null,
+    didInsertElement: function () {
+      if (this.get('isInProgress')) {
+        this.doBlinking();
+      }
+    },
     hostComponent: function(){
       var hostComponent = null;
       var serviceComponent = this.get('content');
@@ -132,31 +137,13 @@ App.MainHostSummaryView = Em.View.extend({
       return hostComponent;
     }.property('content', 'App.router.mainHostDetailsController.content'),
     workStatus: function(){
-      var componentName = this.get('content.componentName');
-      var hostComponent = this.get('hostComponent');
-      if (App.router.get('backgroundOperationsController.allOperationsCount')) {
-        var task = App.router.get('backgroundOperationsController').getTasksByRole(componentName);
-        if(!Ember.empty(task)){
-          if (task[0].start_time == -1 && task[0].command == 'START') {
-            this.content.set('workStatus', App.HostComponent.Status.starting);
-            if (hostComponent) {
-              hostComponent.set('workStatus', App.HostComponent.Status.starting);
-            }
-          } else if (task[0].start_time == -1 && task[0].command == 'STOP') {
-            this.content.set('workStatus', App.HostComponent.Status.stopping);
-            if (hostComponent) {
-              hostComponent.set('workStatus', App.HostComponent.Status.stopping);
-            }
-          }
-        }
-      }
-
       var workStatus = this.get('content.workStatus');
+      var hostComponent = this.get('hostComponent');
       if(hostComponent){
         workStatus = hostComponent.get('workStatus');
       }
       return workStatus;
-    }.property('hostComponent.workStatus', 'App.route.backgroundOperationsController.allOperationsCount'), //'content.workStatus',
+    }.property('content.workStatus','hostComponent.workStatus'),
     statusClass: function(){
       var statusClass = null;
       if(this.get('isDataNode')){
@@ -208,6 +195,10 @@ App.MainHostSummaryView = Em.View.extend({
     isStart : function() {
       return (this.get('workStatus') === App.Component.Status.started || this.get('workStatus') === App.Component.Status.starting);
     }.property('workStatus'),
+
+    isInProgress : function() {
+      return (this.get('workStatus') === App.Component.Status.stopping || this.get('workStatus') === App.Component.Status.starting);
+    }.property('workStatus'),
     /**
      * Shows whether we need to show Decommision/Recomission buttons
      */