You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/08/06 01:06:11 UTC

ambari git commit: AMBARI-12653. Add Host wizard: Failed to add host to cluster after browser refresh on hosts page. (jaimin)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 b0b5335a0 -> 550d3e9bf


AMBARI-12653. Add Host wizard: Failed to add host to cluster after browser refresh on hosts page. (jaimin)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/550d3e9b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/550d3e9b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/550d3e9b

Branch: refs/heads/branch-2.1
Commit: 550d3e9bf62e1d4793f4302cb6ac98171fdc77d6
Parents: b0b5335
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Wed Aug 5 16:04:54 2015 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Wed Aug 5 16:05:04 2015 -0700

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    | 22 +++++----
 .../app/mappers/components_state_mapper.js      |  2 +-
 .../app/mappers/service_metrics_mapper.js       |  3 +-
 ambari-web/app/routes/add_host_routes.js        | 48 ++++++++++----------
 ambari-web/app/utils/components.js              | 21 +++++----
 .../test/controllers/main/host/details_test.js  | 14 ++++--
 6 files changed, 62 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index b9d9711..8bb4950 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -216,19 +216,21 @@ App.ClusterController = Em.Controller.extend({
       updater.updateServices(function () {
         self.updateLoadStatus('services');
         App.config.loadConfigsFromStack(App.Service.find().mapProperty('serviceName')).complete(function () {
-          App.config.loadClusterConfigsFromStack().complete(function() {
+          App.config.loadClusterConfigsFromStack().complete(function () {
             self.set('isConfigsPropertiesLoaded', true);
           });
         });
-        // service metrics loading doesn't affect overall progress
-        updater.updateServiceMetric(function () {
-          self.set('isServiceMetricsLoaded', true);
-          // components config and state loading doesn't affect overall progress
-          updater.updateComponentConfig(function () {
-            self.set('isComponentsConfigLoaded', true);
-          });
-          updater.updateComponentsState(function () {
-            self.set('isComponentsStateLoaded', true);
+        // components state loading doesn't affect overall progress
+        updater.updateComponentsState(function () {
+          self.set('isComponentsStateLoaded', true);
+          // service metrics should be loaded after components state for mapping service components to service in the DS model
+          // service metrics loading doesn't affect overall progress
+          updater.updateServiceMetric(function () {
+            self.set('isServiceMetricsLoaded', true);
+            // components config loading doesn't affect overall progress
+            updater.updateComponentConfig(function () {
+              self.set('isComponentsConfigLoaded', true);
+            });
           });
         });
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js
index 64d00de..0f2b627 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -171,7 +171,7 @@ App.componentsStateMapper = App.QuickDataMapper.create({
         if (cacheService) {
           cacheService.client_components = clients.filterProperty('service_name', cacheService.ServiceInfo.service_name).mapProperty('component_name');
           cacheService.slave_components = slaves.filterProperty('service_name', cacheService.ServiceInfo.service_name).mapProperty('component_name');
-
+          cacheService.master_components = masters.filterProperty('service_name', cacheService.ServiceInfo.service_name).mapProperty('component_name');
           for (var i in parsedItem) {
             if (service.get('isLoaded')) {
               cacheService[i] = parsedItem[i];

http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/app/mappers/service_metrics_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_metrics_mapper.js b/ambari-web/app/mappers/service_metrics_mapper.js
index 6f4531f..c079b16 100644
--- a/ambari-web/app/mappers/service_metrics_mapper.js
+++ b/ambari-web/app/mappers/service_metrics_mapper.js
@@ -35,7 +35,8 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     tool_tip_content: 'tool_tip_content',
     installed_clients: 'installed_clients',
     client_components: 'client_components',
-    slave_components: 'slave_components'
+    slave_components: 'slave_components',
+    master_components: 'master_components'
   },
   hdfsConfig: {
     version: 'nameNodeComponent.host_components[0].metrics.dfs.namenode.Version',

http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/app/routes/add_host_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_host_routes.js b/ambari-web/app/routes/add_host_routes.js
index 7bfe04c..7cf6ed2 100644
--- a/ambari-web/app/routes/add_host_routes.js
+++ b/ambari-web/app/routes/add_host_routes.js
@@ -21,7 +21,7 @@ var App = require('app');
 module.exports = App.WizardRoute.extend({
   route: '/host/add',
 
-  leaveWizard: function (router,context) {
+  leaveWizard: function (router, context) {
     var addHostController = router.get('addHostController');
     App.router.get('updateController').set('isWorking', true);
     addHostController.finish();
@@ -30,7 +30,7 @@ module.exports = App.WizardRoute.extend({
       clusterState: 'DEFAULT',
       localdb: App.db.data
     }, {
-      alwaysCallback: function() {
+      alwaysCallback: function () {
         context.hide();
         App.router.transitionTo('hosts.index');
         location.reload();
@@ -48,34 +48,34 @@ module.exports = App.WizardRoute.extend({
       App.router.get('updateController').set('isWorking', false);
       App.ModalPopup.show({
         classNames: ['full-width-modal'],
-        header:Em.I18n.t('hosts.add.header'),
-        bodyClass:  App.AddHostView.extend({
+        header: Em.I18n.t('hosts.add.header'),
+        bodyClass: App.AddHostView.extend({
           controllerBinding: 'App.router.addHostController'
         }),
-        primary:Em.I18n.t('form.cancel'),
+        primary: Em.I18n.t('form.cancel'),
         secondary: null,
         showFooter: false,
 
-        onPrimary:function () {
+        onPrimary: function () {
           this.hide();
           App.router.get('updateController').set('isWorking', true);
           router.transitionTo('hosts.index');
         },
-        onClose: function() {
+        onClose: function () {
           var popupContext = this;
           if (addHostController.get('currentStep') == '6') {
             App.ModalPopup.show({
               header: Em.I18n.t('hosts.add.exit.header'),
               body: Em.I18n.t('hosts.add.exit.body'),
               onPrimary: function () {
-                self.leaveWizard(router,popupContext);
+                self.leaveWizard(router, popupContext);
               }
             });
           } else {
-            self.leaveWizard(router,this);
+            self.leaveWizard(router, this);
           }
         },
-        didInsertElement: function(){
+        didInsertElement: function () {
           this.fitHeight();
         }
       });
@@ -151,7 +151,7 @@ module.exports = App.WizardRoute.extend({
         controller.connectOutlet('wizardStep3', controller.get('content'));
       });
     },
-    back: function(router){
+    back: function (router) {
       router.transitionTo('step1');
     },
     exit: function (router) {
@@ -200,8 +200,8 @@ module.exports = App.WizardRoute.extend({
       var addHostController = router.get('addHostController');
       var wizardStep6Controller = router.get('wizardStep6Controller');
 
-      wizardStep6Controller.callValidation(function() {
-        wizardStep6Controller.showValidationIssuesAcceptBox(function() {
+      wizardStep6Controller.callValidation(function () {
+        wizardStep6Controller.showValidationIssuesAcceptBox(function () {
           addHostController.saveSlaveComponentHosts(wizardStep6Controller);
           router.transitionTo('step4');
         });
@@ -227,7 +227,7 @@ module.exports = App.WizardRoute.extend({
         });
       });
     },
-    back: function(router){
+    back: function (router) {
       router.transitionTo('step3');
     },
     next: function (router) {
@@ -244,15 +244,17 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('addHostController');
       controller.setCurrentStep('5');
       controller.dataLoading().done(function () {
-        controller.loadAllPriorSteps();
-        controller.getServiceConfigGroups();
-        var wizardStep8Controller = router.get('wizardStep8Controller');
-        wizardStep8Controller.set('wizardController', controller);
-        controller.connectOutlet('wizardStep8', controller.get('content'));
+        router.get('mainController').isLoading.call(router.get('clusterController'), 'isServiceContentFullyLoaded').done(function () {
+          controller.loadAllPriorSteps();
+          controller.getServiceConfigGroups();
+          var wizardStep8Controller = router.get('wizardStep8Controller');
+          wizardStep8Controller.set('wizardController', controller);
+          controller.connectOutlet('wizardStep8', controller.get('content'));
+        });
       });
     },
-    back: function(router){
-      if(!router.get('wizardStep8Controller.isBackBtnDisabled')) {
+    back: function (router) {
+      if (!router.get('wizardStep8Controller.isBackBtnDisabled')) {
         router.transitionTo('step4');
       }
     },
@@ -287,7 +289,7 @@ module.exports = App.WizardRoute.extend({
       });
     },
     back: Em.Router.transitionTo('step5'),
-    retry: function(router,context) {
+    retry: function (router, context) {
       var addHostController = router.get('addHostController');
       var wizardStep9Controller = router.get('wizardStep9Controller');
       wizardStep9Controller.set('wizardController', addHostController);
@@ -306,7 +308,7 @@ module.exports = App.WizardRoute.extend({
         }
       }
     },
-    unroutePath: function() {
+    unroutePath: function () {
       return false;
     },
     next: function (router) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/app/utils/components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/components.js b/ambari-web/app/utils/components.js
index 74f0a33..54ee6c0 100644
--- a/ambari-web/app/utils/components.js
+++ b/ambari-web/app/utils/components.js
@@ -18,10 +18,10 @@
 var App = require('app');
 
 module.exports = {
-  installHostComponent: function(hostName, component) {
+  installHostComponent: function (hostName, component) {
     var self = this,
-        componentName = component.get('componentName'),
-        displayName = component.get('displayName');
+      componentName = component.get('componentName'),
+      displayName = component.get('displayName');
     this.updateAndCreateServiceComponent(componentName).done(function () {
       App.ajax.send({
         name: 'host.host_component.add_new_component',
@@ -151,7 +151,7 @@ module.exports = {
    * @param {Object} opt - options. Allowed options are `hostName`, `installedComponents`, `scope`.
    * @return {Array} - names of missed components
    */
-  checkComponentDependencies: function(componentName, opt) {
+  checkComponentDependencies: function (componentName, opt) {
     opt = opt || {};
     opt.scope = opt.scope || '*';
     var installedComponents;
@@ -168,7 +168,7 @@ module.exports = {
         installedComponents = opt.installedComponents || App.HostComponent.find().mapProperty('componentName').uniq();
         break;
     }
-    return dependencies.filter(function(dependency) {
+    return dependencies.filter(function (dependency) {
       return !installedComponents.contains(dependency.componentName);
     }).mapProperty('componentName');
   },
@@ -181,8 +181,11 @@ module.exports = {
   updateAndCreateServiceComponent: function (componentName) {
     var self = this;
     var dfd = $.Deferred();
-    App.router.get('updateController').updateComponentsState(function() {
-      self.createServiceComponent(componentName, dfd);
+    var updater =  App.router.get('updateController');
+    updater.updateComponentsState(function () {
+      updater.updateServiceMetric(function () {
+        self.createServiceComponent(componentName, dfd);
+      });
     });
     return dfd.promise();
   },
@@ -193,10 +196,10 @@ module.exports = {
    * @param dfd
    * @returns {*}
    */
-  createServiceComponent: function(componentName, dfd) {
+  createServiceComponent: function (componentName, dfd) {
     var allServiceComponents = [];
     var services = App.Service.find().mapProperty('serviceName');
-    services.forEach(function(_service){
+    services.forEach(function (_service) {
       var _serviceComponents = App.Service.find(_service).get('serviceComponents');
       allServiceComponents = allServiceComponents.concat(_serviceComponents);
     }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/550d3e9b/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 76d1835..5edfb58 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -602,10 +602,16 @@ describe('App.MainHostDetailsController', function () {
           })
         ]
       });
-      sinon.stub(App.router, "get").withArgs('updateController').returns({
-        updateComponentsState: function (callback) {
-          return callback();
-        }
+
+      sinon.stub(App.router, 'get', function () {
+        return Em.Object.create({
+          updateComponentsState: function (callback) {
+            return callback();
+          },
+          updateServiceMetric: function (callback) {
+            return callback();
+          }
+        })
       });
     });
     afterEach(function () {