You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2017/06/08 16:02:18 UTC

ambari git commit: AMBARI-21117. Existing hosts state didn't save after host was added (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 a65b52e58 -> f0226e0e5


AMBARI-21117. Existing hosts state didn't save after host was added (alexantonenko)


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

Branch: refs/heads/branch-2.5
Commit: f0226e0e56066450106fa594e638602919f741ac
Parents: a65b52e
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu May 25 01:35:41 2017 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Jun 8 19:02:13 2017 +0300

----------------------------------------------------------------------
 .../app/controllers/main/host/add_controller.js |  3 --
 ambari-web/app/controllers/wizard.js            |  9 ++---
 ambari-web/app/routes/add_host_routes.js        | 38 +++++++++++---------
 .../main/host/add_controller_test.js            | 19 ----------
 ambari-web/test/controllers/wizard_test.js      |  4 ---
 5 files changed, 27 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f0226e0e/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 38179ea..6b158c1 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -420,9 +420,6 @@ App.AddHostController = App.WizardController.extend({
   finish: function () {
     this.clearAllSteps();
     this.clearStorageData();
-    App.router.get('updateController').updateAll();
-    App.updater.immediateRun('updateHost');
-    App.router.get('clusterController').getAllHostNames();
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f0226e0e/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 51e33d3..c282511 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -871,14 +871,15 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
   /**
    * Save cluster status before going to deploy step
    * @param name cluster state. Unique for every wizard
+   * @param callbackObj can have additional params for ajax callBacks and sender
    */
-  saveClusterState: function (name) {
+  saveClusterState: function (name, callbackObj) {
     App.clusterStatus.setClusterStatus({
       clusterName: this.get('content.cluster.name'),
       clusterState: name,
       wizardControllerName: this.get('content.controllerName'),
       localdb: App.db.data
-    });
+    }, callbackObj);
   },
 
   /**
@@ -1458,10 +1459,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
    * @param {App.WizardController} controller - wizard controller
    * @param {string} route - preferable path to go after wizard finished
    */
-  resetOnClose: function(controller, route) {
+  resetOnClose: function(controller, route, router) {
     App.router.get('wizardWatcherController').resetUser();
     controller.finish();
-    App.router.get('updateController').set('isWorking', true);
     App.clusterStatus.setClusterStatus({
       clusterName: App.get('clusterName'),
       clusterState: 'DEFAULT',
@@ -1469,6 +1469,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     },
     {
       alwaysCallback: function () {
+        router && router.set('nextBtnClickInProgress', false);
         controller.get('popup').hide();
         App.router.transitionTo(route);
         Em.run.next(function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f0226e0e/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 c733a66..851c0da 100644
--- a/ambari-web/app/routes/add_host_routes.js
+++ b/ambari-web/app/routes/add_host_routes.js
@@ -23,7 +23,7 @@ module.exports = App.WizardRoute.extend({
 
   leaveWizard: function (router, context) {
     var addHostController = router.get('addHostController');
-    addHostController.resetOnClose(addHostController, 'hosts.index');
+    addHostController.resetOnClose(addHostController, 'hosts.index', router);
   },
 
   enter: function (router) {
@@ -49,6 +49,7 @@ module.exports = App.WizardRoute.extend({
           },
           onClose: function () {
             var popupContext = this;
+            router.set('nextBtnClickInProgress', true);
             if (addHostController.get('currentStep') == '6') {
               App.ModalPopup.show({
                 header: Em.I18n.t('hosts.add.exit.header'),
@@ -266,9 +267,14 @@ module.exports = App.WizardRoute.extend({
         addHostController.installServices(false, function () {
           addHostController.setInfoForStep9();
           // We need to do recovery based on whether we are in Add Host or Installer wizard
-          addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3');
-          wizardStep8Controller.set('servicesInstalled', true);
-          router.transitionTo('step6');
+          router.set('nextBtnClickInProgress', true);
+          addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3', {
+            alwaysCallback: function () {
+              wizardStep8Controller.set('servicesInstalled', true);
+              router.set('nextBtnClickInProgress', false);
+              router.transitionTo('step6');
+            }
+          });
         });
       });
     }
@@ -301,8 +307,11 @@ module.exports = App.WizardRoute.extend({
             addHostController.setInfoForStep9();
             wizardStep9Controller.resetHostsForRetry();
             // We need to do recovery based on whether we are in Add Host or Installer wizard
-            addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3');
-            wizardStep9Controller.navigateStep();
+            addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3', {
+              alwaysCallback: function () {
+                wizardStep9Controller.navigateStep();
+              }
+            });
           });
         } else {
           wizardStep9Controller.navigateStep();
@@ -317,10 +326,15 @@ module.exports = App.WizardRoute.extend({
       var wizardStep9Controller = router.get('wizardStep9Controller');
       wizardStep9Controller.set('wizardController', addHostController);
       addHostController.saveInstalledHosts(wizardStep9Controller);
+      router.set('nextBtnClickInProgress', true);
 
       // We need to do recovery based on whether we are in Add Host or Installer wizard
-      addHostController.saveClusterState('ADD_HOSTS_INSTALLED_4');
-      router.transitionTo('step7');
+      addHostController.saveClusterState('ADD_HOSTS_INSTALLED_4', {
+        alwaysCallback: function () {
+          router.set('nextBtnClickInProgress', false);
+          router.transitionTo('step7');
+        }
+      });
     }
   }),
 
@@ -342,14 +356,6 @@ module.exports = App.WizardRoute.extend({
     },
     back: Em.Router.transitionTo('step6'),
     complete: function (router, context) {
-      var addHostController = router.get('addHostController');
-      var hostsUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,' +
-        'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,' +
-        'metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free';
-      router.get('clusterController').requestHosts(hostsUrl, function () {
-
-      });
-      router.get('updateController').updateAll();
       $(context.currentTarget).parents("#modal").find(".close").trigger('click');
     }
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/f0226e0e/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index c03075f..089d018 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -1207,24 +1207,14 @@ describe('App.AddHostController', function () {
   });
 
   describe("#finish()", function () {
-    var mock = {
-      updateAll: Em.K,
-      getAllHostNames: Em.K
-    };
     beforeEach(function () {
       sinon.stub(controller, 'clearAllSteps', Em.K);
       sinon.stub(controller, 'clearStorageData', Em.K);
-      sinon.stub(App.router, 'get').returns(mock);
-      sinon.spy(mock, 'updateAll');
-      sinon.spy(mock, 'getAllHostNames');
       controller.finish();
     });
     afterEach(function () {
       controller.clearAllSteps.restore();
       controller.clearStorageData.restore();
-      App.router.get.restore();
-      mock.updateAll.restore();
-      mock.getAllHostNames.restore();
     });
     it("clearAllSteps called once", function () {
       expect(controller.clearAllSteps.calledOnce).to.be.true;
@@ -1232,14 +1222,5 @@ describe('App.AddHostController', function () {
     it('clearStorageData called once', function () {
       expect(controller.clearStorageData.calledOnce).to.be.true;
     });
-    it('updateAll called once', function () {
-      expect(mock.updateAll.calledOnce).to.be.true;
-    });
-    it('App.updater.immediateRun called with valid arguments', function () {
-      expect(App.updater.immediateRun.calledWith('updateHost')).to.be.true;
-    });
-    it('getAllHostNames called once', function () {
-      expect(mock.getAllHostNames.calledOnce).to.be.true;
-    });
   });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/f0226e0e/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 3298f70..d6d9bdd 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1696,10 +1696,6 @@ describe('App.WizardController', function () {
       expect(ctrl.finish.calledOnce).to.be.true;
     });
 
-    it("isWorking should be true", function () {
-      expect(mock.get('isWorking')).to.be.true;
-    });
-
     it("App.clusterStatus.setClusterStatus should be called", function () {
       expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
     });