ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-18659 Renavigating back to "Customize Services" page from "Review" page on installer/ASW loses all static attributes of properties (ababiichuk)
Date Mon, 24 Oct 2016 12:56:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 29a41b69e -> d64f0900f


AMBARI-18659 Renavigating back to "Customize Services" page from "Review" page on installer/ASW
 loses all static attributes of properties (ababiichuk)


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

Branch: refs/heads/branch-2.4
Commit: d64f0900f54612ada168775b62974f22b359e7b7
Parents: 29a41b6
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Fri Oct 21 16:16:40 2016 +0300
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Mon Oct 24 15:58:25 2016 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         |  26 ++---
 .../main/admin/kerberos/step4_controller.js     |   2 +-
 .../main/admin/kerberos/wizard_controller.js    |  26 ++---
 .../controllers/main/service/add_controller.js  |  46 +++++----
 ambari-web/app/controllers/wizard.js            |  29 ++++--
 .../app/controllers/wizard/step7_controller.js  |   4 +-
 .../app/controllers/wizard/step8_controller.js  |   2 +-
 ambari-web/app/mixins.js                        |   1 +
 ambari-web/app/mixins/common/persist_mixin.js   |  45 +++++++++
 ambari-web/app/routes/add_kerberos_routes.js    |  72 +++++++------
 ambari-web/app/routes/add_service_routes.js     |  20 ++--
 ambari-web/app/routes/installer.js              |  24 +++--
 ambari-web/app/utils/ajax/ajax.js               |  21 ++++
 ambari-web/app/utils/persist.js                 | 101 +++++++++++++++++++
 ambari-web/test/controllers/installer_test.js   |   8 +-
 .../kerberos/kerberos_wizard_controler_test.js  |  16 ---
 .../admin/kerberos/step4_controller_test.js     |   6 +-
 .../test/controllers/wizard/step8_test.js       |   6 +-
 ambari-web/test/controllers/wizard_test.js      |   4 +
 19 files changed, 324 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index 5493b3a..1b7a48b 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -555,13 +555,6 @@ App.InstallerController = App.WizardController.extend({
   },
 
   /**
-   * Load serviceConfigProperties to model
-   */
-  loadServiceConfigProperties: function () {
-    var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
-    this.set('content.serviceConfigProperties', serviceConfigProperties);
-  },
-  /**
    * Generate clients list for selected services and save it to model
    * @param stepController step4WizardController
    */
@@ -1004,12 +997,18 @@ App.InstallerController = App.WizardController.extend({
       {
         type: 'async',
         callback: function () {
-          this.loadServiceConfigGroups();
-          this.loadServiceConfigProperties();
-          this.loadCurrentHostGroups();
-          this.loadRecommendationsConfigs();
-          this.loadComponentsFromConfigs();
-          return this.loadConfigThemes();
+          var dfd = $.Deferred();
+          var self = this;
+          this.loadServiceConfigProperties().always(function() {
+            self.loadServiceConfigGroups();
+            self.loadCurrentHostGroups();
+            self.loadRecommendationsConfigs();
+            self.loadComponentsFromConfigs();
+            self.loadConfigThemes().then(function() {
+              dfd.resolve();
+            });
+          });
+          return dfd.promise();
         }
       }
     ]
@@ -1036,6 +1035,7 @@ App.InstallerController = App.WizardController.extend({
   finish: function () {
     this.setCurrentStep('0');
     this.clearStorageData();
+    this.clearServiceConfigProperties();
     App.router.get('userSettingsController').postUserPref('show_bg', true);
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
index 29cbfff..e43dd02 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
@@ -208,7 +208,7 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
   prepareConfigProperties: function(configs) {
     var self = this;
     // stored configs from previous steps (Configure Kerberos or Customize Services for ASW)
-    var storedServiceConfigs = this.get('wizardController').getDBProperty('serviceConfigProperties');
+    var storedServiceConfigs = this.get('wizardController.content.serviceConfigProperties');
     var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
     var configProperties = configs.slice(0);
     var siteProperties = App.configsCollection.getAll();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
index 5fc1633..918742d 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
@@ -139,14 +139,6 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
     this.set('content.kerberosOption', stepController.get('selectedItem'));
   },
 
-  /**
-   * Load serviceConfigProperties to model
-   */
-  loadServiceConfigProperties: function () {
-    var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
-    this.set('content.serviceConfigProperties', serviceConfigProperties);
-  },
-
   loadKerberosDescriptorConfigs: function () {
     var kerberosDescriptorConfigs = this.getDBProperty('kerberosDescriptorConfigs');
     this.set('kerberosDescriptorConfigs', kerberosDescriptorConfigs);
@@ -287,15 +279,19 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
     ],
     '2': [
       {
-        type: 'sync',
+        type: 'async',
         callback: function () {
           var self = this;
-          this.loadServiceConfigProperties();
-          if (!this.get('stackConfigsLoaded')) {
-            App.config.loadConfigsFromStack(['KERBEROS']).complete(function() {
-              self.set('stackConfigsLoaded', true);
-            }, this);
-          }
+          var dfd = $.Deferred();
+          this.loadServiceConfigProperties().always(function() {
+            if (!self.get('stackConfigsLoaded')) {
+              App.config.loadConfigsFromStack(['KERBEROS']).complete(function() {
+                self.set('stackConfigsLoaded', true);
+              }, self);
+            }
+            dfd.resolve();
+          });
+          return dfd.promise();
         }
       }
     ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index fb4ab19..04427a2 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -123,12 +123,13 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs,
{
           var self = this;
           var dfd = $.Deferred();
           this.loadKerberosDescriptorConfigs().done(function() {
+            self.loadServiceConfigGroups();
             self.loadConfigThemes().then(function() {
-              dfd.resolve();
+              self.loadServiceConfigProperties().always(function() {
+                self.loadCurrentHostGroups();
+                dfd.resolve();
+              });
             });
-            self.loadServiceConfigGroups();
-            self.loadServiceConfigProperties();
-            self.loadCurrentHostGroups();
           });
           return dfd.promise();
         }
@@ -301,14 +302,19 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs,
{
   },
 
   loadServiceConfigProperties: function () {
-    this._super();
-    if (!this.get('content.services')) {
-      this.loadServices();
-    }
-    if (this.get('currentStep') > 1 && this.get('currentStep') < 6) {
-      this.set('content.skipConfigStep', this.skipConfigStep());
-      this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep'));
-    }
+    var self = this;
+    var dfd = $.Deferred();
+    this._super().always(function() {
+      if (!self.get('content.services')) {
+        self.loadServices();
+      }
+      if (self.get('currentStep') > 1 && self.get('currentStep') < 6) {
+        self.set('content.skipConfigStep', self.skipConfigStep());
+        self.get('isStepDisabled').findProperty('step', 4).set('value', self.get('content.skipConfigStep'));
+      }
+      dfd.resolve();
+    });
+    return dfd.promise();
   },
 
   /**
@@ -331,11 +337,16 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs,
{
   },
 
   saveServiceConfigProperties: function (stepController) {
-    this._super(stepController);
-    if (this.get('currentStep') > 1 && this.get('currentStep') < 6) {
-      this.set('content.skipConfigStep', this.skipConfigStep());
-      this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep'));
-    }
+    var dfd = $.Deferred();
+    var self = this;
+    this._super(stepController).always(function() {
+      if (self.get('currentStep') > 1 && self.get('currentStep') < 6) {
+        self.set('content.skipConfigStep', self.skipConfigStep());
+        self.get('isStepDisabled').findProperty('step', 4).set('value', self.get('content.skipConfigStep'));
+      }
+      dfd.resolve();
+    });
+    return dfd.promise();
   },
 
   /**
@@ -413,6 +424,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs,
{
   finish: function () {
     this.clearAllSteps();
     this.clearStorageData();
+    this.clearServiceConfigProperties();
     this.resetDbNamespace();
     App.router.get('updateController').updateAll();
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index def6b84..dee301f 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -18,9 +18,11 @@
 
 
 var App = require('app');
+var persistUtils = require('utils/persist');
+
 require('models/host');
 
-App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, {
+App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, App.Persist,
{
 
   isStepDisabled: null,
 
@@ -901,11 +903,19 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
   },
 
   /**
-   * Load serviceConfigProperties to model
+   * Load serviceConfigProperties from persist
+   * @return {$.Deferred}
    */
   loadServiceConfigProperties: function () {
-    var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
-    this.set('content.serviceConfigProperties', serviceConfigProperties);
+    var dfd = $.Deferred();
+    var self = this;
+    this.getPersistentProperty('serviceConfigProperties').always(function(data) {
+      if (data && !data.error) {
+        self.set('content.serviceConfigProperties', data);
+      }
+      dfd.resolve();
+    });
+    return dfd.promise();
   },
   /**
    * Save config properties
@@ -953,11 +963,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
         }
       }
     }, this);
-    this.setDBProperties({
-      fileNamesToUpdate: fileNamesToUpdate,
-      serviceConfigProperties: serviceConfigProperties
-    });
     this.set('content.serviceConfigProperties', serviceConfigProperties);
+    this.setDBProperty('fileNamesToUpdate', fileNamesToUpdate);
+    return this.setPersistentProperty('serviceConfigProperties', serviceConfigProperties);
   },
 
   isExcludedConfig: function (configProperty) {
@@ -1377,6 +1385,11 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     this.setDBProperty(stepController.name + "-sc", null);
   },
 
+  clearServiceConfigProperties: function() {
+    this.get('content.serviceConfigProperties', null);
+    return this.removePersistentProperty('serviceConfigProperties');
+  },
+
   saveTasksStatuses: function (tasksStatuses) {
     this.set('content.tasksStatuses', tasksStatuses);
     this.setDBProperty('tasksStatuses', tasksStatuses);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index f0c2f57..1b106de 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -469,15 +469,13 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     this.clearStep();
 
     var self = this;
-
     App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
 
     var storedConfigs = this.get('content.serviceConfigProperties');
-
     var configs = storedConfigs && storedConfigs.length ? storedConfigs : App.configsCollection.getAll();
 
     this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete')
|| []);
-    if (this.get('wizardController.name') === 'addServiceController' && !this.get('content.serviceConfigProperties.length'))
{
+    if (this.get('wizardController.name') === 'addServiceController' && !storedConfigs)
{
       App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function
(loadedConfigs) {
         configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
         self.applyServicesConfigs(configs);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 0ad68ed..644885b 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -522,7 +522,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs,
App.wiz
    * @method loadHiveDbValue
    */
   loadDbValue: function (serviceName) {
-    var serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties');
+    var serviceConfigProperties = this.get('content.serviceConfigProperties');
     var dbFull = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() +
'_database');
       //db = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() + '_ambari_database');
     //since db.value contains the intial default value of <service>_admin_database
(MySQL) and not the actual db type selected,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index b27751b..b4fe115 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -23,6 +23,7 @@ require('mixins/common/blueprint');
 require('mixins/common/kdc_credentials_controller_mixin');
 require('mixins/common/localStorage');
 require('mixins/common/infinite_scroll_mixin');
+require('mixins/common/persist_mixin');
 require('mixins/common/userPref');
 require('mixins/common/reload_popup');
 require('mixins/common/serverValidator');

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/mixins/common/persist_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/persist_mixin.js b/ambari-web/app/mixins/common/persist_mixin.js
new file mode 100644
index 0000000..0b81364
--- /dev/null
+++ b/ambari-web/app/mixins/common/persist_mixin.js
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var persistUtils = require('utils/persist');
+
+App.Persist = Em.Mixin.create({
+
+  persistNamespace: function() {
+    var name = this.get('name');
+    if (Em.isNone(name)) {
+      name = this.get('controller.name');
+    }
+    return name.capitalize().replace('Controller', '');
+  }.property('name'),
+
+  getPersistentProperty: function(key) {
+    return persistUtils.get(this.get('persistNamespace') + '__' + key);
+  },
+
+  setPersistentProperty: function(key, value) {
+    return persistUtils.put(this.get('persistNamespace') + '__' + key, value);
+  },
+
+  removePersistentProperty: function(key) {
+    return persistUtils.remove(this.get('persistNamespace') + '__' + key);
+  }
+
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/routes/add_kerberos_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js
index 4291394..6ef144d 100644
--- a/ambari-web/app/routes/add_kerberos_routes.js
+++ b/ambari-web/app/routes/add_kerberos_routes.js
@@ -115,8 +115,9 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('kerberosWizardController');
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('1');
-        controller.loadAllPriorSteps();
-        controller.connectOutlet('kerberosWizardStep1', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.connectOutlet('kerberosWizardStep1', controller.get('content'));
+        });
       });
     },
 
@@ -129,8 +130,9 @@ module.exports = App.WizardRoute.extend({
       var kerberosStep1controller = router.get('kerberosWizardStep1Controller');
 
       kerberosWizardController.saveKerberosOption(kerberosStep1controller);
-      kerberosWizardController.setDBProperty('serviceConfigProperties', null);
-      router.transitionTo('step2');
+      kerberosWizardController.clearServiceConfigProperties().always(function() {
+        router.transitionTo('step2');
+      });
     }
   }),
 
@@ -141,10 +143,11 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('kerberosWizardController');
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('2');
-        controller.loadAllPriorSteps();
-        var kerberosWizardStep2Controller = router.get('kerberosWizardStep2Controller');
-        kerberosWizardStep2Controller.set('wizardController', controller);
-        controller.connectOutlet('kerberosWizardStep2', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          var kerberosWizardStep2Controller = router.get('kerberosWizardStep2Controller');
+          kerberosWizardStep2Controller.set('wizardController', controller);
+          controller.connectOutlet('kerberosWizardStep2', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {
@@ -169,14 +172,15 @@ module.exports = App.WizardRoute.extend({
         kerberosWizardStep2Controller.get('stepConfigs')[0].get('configs').findProperty('name',
'manage_krb5_conf').set('value', 'false');
       }
 
-      kerberosWizardController.saveServiceConfigProperties(kerberosWizardStep2Controller);
-      kerberosWizardController.clearTasksData();
-      if (kerberosWizardController.get('skipClientInstall')) {
-        kerberosWizardController.setDBProperty('kerberosDescriptorConfigs', null);
-        router.transitionTo('step4');
-      } else {
-        router.transitionTo('step3');
-      }
+      kerberosWizardController.saveServiceConfigProperties(kerberosWizardStep2Controller).always(function()
{
+        kerberosWizardController.clearTasksData();
+        if (kerberosWizardController.get('skipClientInstall')) {
+          kerberosWizardController.setDBProperty('kerberosDescriptorConfigs', null);
+          router.transitionTo('step4');
+        } else {
+          router.transitionTo('step3');
+        }
+      });
     }
   }),
 
@@ -187,8 +191,9 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('kerberosWizardController');
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('3');
-        controller.loadAllPriorSteps();
-        controller.connectOutlet('kerberosWizardStep3', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.connectOutlet('kerberosWizardStep3', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {
@@ -212,10 +217,11 @@ module.exports = App.WizardRoute.extend({
       controller.setCurrentStep(4);
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('4');
-        controller.loadAllPriorSteps();
-        controller.setLowerStepsDisable(4);
-        step4Controller.set('wizardController', controller);
-        controller.connectOutlet('kerberosWizardStep4', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.setLowerStepsDisable(4);
+          step4Controller.set('wizardController', controller);
+          controller.connectOutlet('kerberosWizardStep4', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {
@@ -251,8 +257,9 @@ module.exports = App.WizardRoute.extend({
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('5');
         controller.setLowerStepsDisable(5);
-        controller.loadAllPriorSteps();
-        controller.connectOutlet('kerberosWizardStep5', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.connectOutlet('kerberosWizardStep5', controller.get('content'));
+        });
       });
     },
 
@@ -290,8 +297,9 @@ module.exports = App.WizardRoute.extend({
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('6');
         controller.setLowerStepsDisable(6);
-        controller.loadAllPriorSteps();
-        controller.connectOutlet('kerberosWizardStep6', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.connectOutlet('kerberosWizardStep6', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {
@@ -317,9 +325,10 @@ module.exports = App.WizardRoute.extend({
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('7');
         controller.setLowerStepsDisable(7);
-        controller.loadAllPriorSteps();
-        step7Controller.setRequest();
-        controller.connectOutlet('kerberosWizardStep7', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          step7Controller.setRequest();
+          controller.connectOutlet('kerberosWizardStep7', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {
@@ -339,8 +348,9 @@ module.exports = App.WizardRoute.extend({
       controller.dataLoading().done(function () {
         router.get('kerberosWizardController').setCurrentStep('8');
         controller.setLowerStepsDisable(8);
-        controller.loadAllPriorSteps();
-        controller.connectOutlet('kerberosWizardStep8', controller.get('content'));
+        controller.loadAllPriorSteps().done(function() {
+          controller.connectOutlet('kerberosWizardStep8', controller.get('content'));
+        });
       });
     },
     unroutePath: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 30c8e07..88e196a 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -198,7 +198,6 @@ module.exports = App.WizardRoute.extend({
           addServiceController.saveSlaveComponentHosts(wizardStep6Controller);
           addServiceController.get('content').set('serviceConfigProperties', null);
           addServiceController.setDBProperties({
-            serviceConfigProperties: null,
             groupsToDelete: null,
             recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
             recommendationsConfigs: null
@@ -206,7 +205,9 @@ module.exports = App.WizardRoute.extend({
           router.get('wizardStep7Controller').set('recommendationsConfigs', null);
           router.get('wizardStep7Controller').clearAllRecommendations();
           addServiceController.setDBProperty('serviceConfigGroups', undefined);
-          router.transitionTo('step4');
+          addServiceController.clearServiceConfigProperties().always(function() {
+            router.transitionTo('step4');
+          });
         });
       });
     }
@@ -248,14 +249,15 @@ module.exports = App.WizardRoute.extend({
     next: function (router) {
       var addServiceController = router.get('addServiceController');
       var wizardStep7Controller = router.get('wizardStep7Controller');
-      addServiceController.saveServiceConfigProperties(wizardStep7Controller);
       addServiceController.saveServiceConfigGroups(wizardStep7Controller, true);
-      if (App.get('isKerberosEnabled')) {
-        addServiceController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
-        router.transitionTo('step5');
-        return;
-      }
-      router.transitionTo('step6');
+      addServiceController.saveServiceConfigProperties(wizardStep7Controller).always(function()
{
+        if (App.get('isKerberosEnabled')) {
+          addServiceController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
+          router.transitionTo('step5');
+          return;
+        }
+        router.transitionTo('step6');
+      });
     }
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index 0cfbf20..b4aa799 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -360,14 +360,15 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
             controller.get('content').set('serviceConfigProperties', null);
             controller.get('content').set('componentsFromConfigs', []);
             controller.setDBProperties({
-              serviceConfigProperties: null,
               serviceConfigGroups: null,
               recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
               recommendationsConfigs: null,
               componentsFromConfigs: []
             });
-            router.transitionTo('step7');
-            console.timeEnd('step6 next');
+            controller.clearServiceConfigProperties().then(function() {
+              router.transitionTo('step7');
+              console.timeEnd('step6 next');
+            });
           }
         });
       }
@@ -418,14 +419,15 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         App.set('router.nextBtnClickInProgress', true);
         var controller = router.get('installerController');
         var wizardStep7Controller = router.get('wizardStep7Controller');
-        controller.saveServiceConfigProperties(wizardStep7Controller);
-        controller.saveServiceConfigGroups(wizardStep7Controller);
-        controller.setDBProperty('recommendationsConfigs', wizardStep7Controller.get('recommendationsConfigs'));
-        controller.saveComponentsFromConfigs(controller.get('content.componentsFromConfigs'));
-        controller.setDBProperty('recommendationsHostGroup', wizardStep7Controller.get('content.recommendationsHostGroup'));
-        controller.setDBProperty('masterComponentHosts', wizardStep7Controller.get('content.masterComponentHosts'));
-        router.transitionTo('step8');
-        console.timeEnd('step7 next');
+        controller.saveServiceConfigProperties(wizardStep7Controller).always(function() {
+          controller.saveServiceConfigGroups(wizardStep7Controller);
+          controller.setDBProperty('recommendationsConfigs', wizardStep7Controller.get('recommendationsConfigs'));
+          controller.saveComponentsFromConfigs(controller.get('content.componentsFromConfigs'));
+          controller.setDBProperty('recommendationsHostGroup', wizardStep7Controller.get('content.recommendationsHostGroup'));
+          controller.setDBProperty('masterComponentHosts', wizardStep7Controller.get('content.masterComponentHosts'));
+          router.transitionTo('step8');
+          console.timeEnd('step7 next');
+        });
       }
     }
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index af3a9e2..13e4fdf 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2151,6 +2151,27 @@ var urls = {
     'mock': '/data/requests/host_check/1.json'
   },
 
+  'persist.get': {
+    'real': '/persist/{key}',
+    'mock': '',
+    'type': 'GET',
+    'format': function() {
+      return {
+        dataType: 'text'
+      }
+    }
+  },
+  'persist.put': {
+    'real': '/persist',
+    'mock': '',
+    'type': 'POST',
+    'format': function (data) {
+      return {
+        data: JSON.stringify(data.keyValuePair)
+      }
+    }
+  },
+
   'wizard.step3.rerun_checks': {
     'real': '/hosts?fields=Hosts/last_agent_env',
     'mock': '/data/wizard/bootstrap/two_hosts_information.json',

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/app/utils/persist.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/persist.js b/ambari-web/app/utils/persist.js
new file mode 100644
index 0000000..3d3164f
--- /dev/null
+++ b/ambari-web/app/utils/persist.js
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var LZString = require('utils/lz-string');
+/**
+ * Persist storage managing utils. It helps to put and get values from persisted storage
+ * by api (/api/v1/persist).
+ * @type {Object}
+ */
+module.exports = {
+  /**
+   * Get item from persist storage by key and optional path.
+   *
+   * @param  {String} key persist key to get e.g 'CLUSTER_STATUS', will fetch data from
+   * /api/v1/persist/CLUSTER_STATUS
+   * @param  {String} [path=null] Em.get compatible attributes path
+   * @return {$.Deferred}
+   */
+  get: function(key, path) {
+    var dfd = $.Deferred();
+    App.ajax.send({
+      name: 'persist.get',
+      sender: this,
+      data: {
+        deferred: dfd,
+        key: key || '',
+        path: path
+      },
+      success: 'getSuccessCallback',
+      error: 'getErrorCallback'
+    });
+    return dfd.promise();
+  },
+
+  getSuccessCallback: function(data, xhr, params) {
+    var extracted, response = data;
+    try {
+      response = JSON.parse(response);
+    } catch(e) { }
+    if (Em.isEmpty(data)) {
+      params.deferred.resolve(null);
+      return;
+    }
+    if (typeof response === 'string') {
+      extracted = JSON.parse(LZString.decompressFromBase64(response));
+      params.deferred.resolve(params.path ? Em.get(extracted, params.path) : extracted);
+    } else {
+      params.deferred.resolve(response);
+    }
+  },
+
+  getErrorCallback: function(request, ajaxOptions, error, opt, params) {
+    params.deferred.reject({
+      request: request,
+      error: error
+    });
+  },
+
+  /**
+   * Update key value.
+   *
+   * @param  {String} key
+   * @param  {Object} value value to save
+   * @return {$.Deferred}
+   */
+  put: function(key, value) {
+    var kv = {};
+    kv[key] = !Em.isEmpty(value) ? LZString.compressToBase64(JSON.stringify(value)) : '';
+    return App.ajax.send({
+      name: 'persist.put',
+      sender: this,
+      data: {
+        keyValuePair: kv
+      },
+      success: 'putSuccessCallback',
+      error: 'putErrorCallback'
+    });
+  },
+
+  putSuccessCallback: function() {},
+  putErrorCallback: function() {},
+
+  remove: function(key) {
+    return this.put(key, '');
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 5b78cbc..6f4b18d 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -608,6 +608,7 @@ describe('App.InstallerController', function () {
         },
         loadServiceConfigProperties: function() {
           loadServiceConfigProperties = true;
+          return $.Deferred().resolve().promise();
         },
         loadCurrentHostGroups: function() {
           loadCurrentHostGroups = true;
@@ -620,6 +621,7 @@ describe('App.InstallerController', function () {
         },
         loadConfigThemes: function() {
           loadConfigThemes = true;
+          return $.Deferred().resolve().promise();
         }
       };
 
@@ -785,12 +787,12 @@ describe('App.InstallerController', function () {
 
   describe('#loadServiceConfigProperties', function() {
     beforeEach(function () {
-      sinon.stub(installerController, 'getDBProperty').returns({
+      sinon.stub(installerController, 'getPersistentProperty').returns($.Deferred().resolve({
         value: 2
-      });
+      }).promise());
     });
     afterEach(function () {
-      installerController.getDBProperty.restore();
+      installerController.getPersistentProperty.restore();
     });
     it ('Should load service config property', function() {
       installerController.loadServiceConfigProperties();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
b/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
index 2d792f2..f6754d5 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
@@ -193,22 +193,6 @@ describe('App.KerberosWizardController', function() {
     });
   });
 
-  describe("#loadServiceConfigProperties()", function () {
-
-    beforeEach(function() {
-      sinon.stub(controller, 'getDBProperty').returns([{}]);
-    });
-
-    afterEach(function() {
-      controller.getDBProperty.restore();
-    });
-
-    it("serviceConfigProperties should be set", function() {
-      controller.loadServiceConfigProperties();
-      expect(controller.get('content.serviceConfigProperties')).to.be.eql([{}]);
-    });
-  });
-
   describe("#loadKerberosDescriptorConfigs()", function () {
 
     beforeEach(function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 1713e9c..96f89f4 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -147,10 +147,10 @@ describe('App.KerberosWizardStep4Controller', function() {
     before(function() {
       var controller = App.KerberosWizardStep4Controller.create({
         wizardController: {
-          getDBProperty: function() {
-            return Em.A([
+          content: {
+            serviceConfigProperties: Em.A([
               Em.Object.create({ name: 'realm', value: 'realm_value' })
-            ]);
+            ])
           },
           loadCachedStepConfigValues: function() {
             return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index 9214631..217900f 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -900,11 +900,9 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.set('wizardController', Em.Object.create({
         getDBProperty: Em.K
       }));
-      this.mock = sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty');
     });
 
     afterEach(function() {
-      this.mock.restore();
     });
 
     var tests = [
@@ -928,10 +926,10 @@ describe('App.WizardStep8Controller', function () {
 
     tests.forEach(function(test) {
       it(test.it, function() {
-        this.mock.returns(test.serviceConfigProperties);
+        installerStep8Controller.set('content.serviceConfigProperties', test.serviceConfigProperties);
         var dbComponent = installerStep8Controller.loadDbValue(test.serviceName);
         expect(dbComponent).to.equal(test.result);
-      })
+      });
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d64f0900/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 2b28d01..922cc90 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1052,14 +1052,18 @@ describe('App.WizardController', function () {
 
     beforeEach(function () {
       c.set('content', {});
+      sinon.stub(c, 'setDBProperty', Em.K);
       sinon.stub(c, 'setDBProperties', Em.K);
       sinon.stub(c, 'getDBProperty').withArgs('fileNamesToUpdate').returns([]);
+      sinon.stub(c, 'setPersistentProperty', Em.K);
       sinon.stub(App.config, 'shouldSupportFinal').returns(true);
     });
 
     afterEach(function () {
+      c.setDBProperty.restore();
       c.setDBProperties.restore();
       c.getDBProperty.restore();
+      c.setPersistentProperty.restore();
       App.config.shouldSupportFinal.restore();
     });
 


Mime
View raw message