You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/06/02 15:23:31 UTC

ambari git commit: AMBARI-11608 Install Wizard: Merge calls for service stack configs into single. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/trunk e83125106 -> d4a26a8fe


AMBARI-11608 Install Wizard: Merge calls for service stack configs into single. (atkach)


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

Branch: refs/heads/trunk
Commit: d4a26a8fe78cc8d18b4bb0899711dd4fa08f8c88
Parents: e831251
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Tue Jun 2 12:40:06 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Tue Jun 2 16:23:15 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js       | 44 ++++++++++---------------
 ambari-web/app/utils/ajax/ajax.js          |  4 +++
 ambari-web/app/utils/config.js             | 44 +++++++++++++++++++++++++
 ambari-web/test/controllers/wizard_test.js | 18 +++++-----
 4 files changed, 76 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a26a8f/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 8a3c15c..1177272 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -827,39 +827,31 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
    */
   loadAdvancedConfigs: function (dependentController) {
     var self = this;
-    var loadServiceConfigsFn = function(clusterProperties) {
+    var loadServiceConfigsFn = function (clusterProperties) {
       var stackServices = self.get('content.services').filter(function (service) {
         return service.get('isInstalled') || service.get('isSelected');
       });
-      var counter = stackServices.length;
       var loadAdvancedConfigResult = [];
       dependentController.set('isAdvancedConfigLoaded', false);
-      stackServices.forEach(function (service) {
-        var serviceName = service.get('serviceName');
-        App.config.loadAdvancedConfig(serviceName, function (properties) {
-          var supportsFinal = App.config.getConfigTypesInfoFromService(service).supportsFinal;
 
-          function shouldSupportFinal(filename) {
-            var matchingConfigType = supportsFinal.find(function (configType) {
-              return filename.startsWith(configType);
-            });
-            return !!matchingConfigType;
-          }
+      App.config.loadAdvancedConfigAll(stackServices.mapProperty('serviceName'), function (configMap) {
+        stackServices.forEach(function (service) {
+          var serviceName = service.get('serviceName');
+          var properties = configMap[serviceName];
+          var supportsFinal = App.config.getConfigTypesInfoFromService(service).supportsFinal;
 
           properties.forEach(function (property) {
-            property.supportsFinal = shouldSupportFinal(property.filename);
+            property.supportsFinal = Boolean(supportsFinal.find(function (configType) {
+              return property.filename.startsWith(configType);
+            }));
           });
           loadAdvancedConfigResult.pushObjects(properties);
-          counter--;
-          //pass configs to controller after last call is completed
-          if (counter === 0) {
-            loadAdvancedConfigResult.pushObjects(clusterProperties);
-            self.set('content.advancedServiceConfig', loadAdvancedConfigResult);
-            self.setDBProperty('advancedServiceConfig', loadAdvancedConfigResult);
-            dependentController.set('isAdvancedConfigLoaded', true);
-          }
         });
-      }, this);
+        loadAdvancedConfigResult.pushObjects(clusterProperties);
+        self.set('content.advancedServiceConfig', loadAdvancedConfigResult);
+        self.setDBProperty('advancedServiceConfig', loadAdvancedConfigResult);
+        dependentController.set('isAdvancedConfigLoaded', true);
+      });
     };
     App.config.loadClusterConfig(loadServiceConfigsFn);
   },
@@ -1227,16 +1219,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
    * @method loadConfigThemes
    * @return {$.Deferred}
    */
-   loadConfigThemes: function() {
+  loadConfigThemes: function () {
     var self = this;
     var dfd = $.Deferred();
     if (App.get('isClusterSupportsEnhancedConfigs') && !this.get('stackConfigsLoaded')) {
-      var serviceNames = App.StackService.find().filter(function(s) {
+      var serviceNames = App.StackService.find().filter(function (s) {
         return s.get('isSelected') || s.get('isInstalled');
       }).mapProperty('serviceName');
       // Load stack configs before loading themes
-      App.config.loadConfigsFromStack(serviceNames).done(function() {
-        self.loadConfigThemeForServices(serviceNames).always(function() {
+      App.config.loadConfigsFromStack(serviceNames).done(function () {
+        self.loadConfigThemeForServices(serviceNames).always(function () {
           self.set('stackConfigsLoaded', true);
           App.themesMapper.generateAdvancedTabs(serviceNames);
           dfd.resolve();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a26a8f/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 28422aa..bed6fd5 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -720,6 +720,10 @@ var urls = {
     'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
     'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
   },
+  'config.advanced.multiple.services': {
+    'real': '{stackVersionUrl}/services?StackServices/service_name.in({serviceNames})&fields=configurations/*',
+    'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
+  },
   'config.advanced.partial': {
     'real': '{stackVersionUrl}/services/?StackServices/service_name.in({serviceList})&fields=configurations/*{queryFilter}',
     'mock': ''

http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a26a8f/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 1a902bd..8e11193 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -909,6 +909,50 @@ App.config = Em.Object.create({
   },
 
   /**
+   * Generate serviceProperties save it to localDB
+   * called from stepController step6WizardController
+   *
+   * @method loadAdvancedConfig
+   * @param {Array} serviceNames
+   * @param callback
+   * @return {object|null}
+   */
+  loadAdvancedConfigAll: function (serviceNames, callback) {
+    return App.ajax.send({
+      name: 'config.advanced.multiple.services',
+      sender: this,
+      data: {
+        serviceNames: serviceNames.join(','),
+        stackVersionUrl: App.get('stackVersionURL'),
+        stackVersion: App.get('currentStackVersionNumber'),
+        callback: callback
+      },
+      success: 'loadAdvancedConfigAllSuccess',
+      error: 'loadAdvancedConfigAllError'
+    });
+  },
+
+  loadAdvancedConfigAllSuccess: function (data, opt, params, request) {
+    console.log("TRACE: In success function for the loadAdvancedConfig; url is ", opt.url);
+    var serviceConfigMap = {};
+    if (data.items.length) {
+      data.items.forEach(function (service) {
+        var properties = [];
+        service.configurations.forEach(function(item){
+          properties.push(this.createAdvancedPropertyObject(item.StackConfigurations));
+        }, this);
+        serviceConfigMap[service.StackServices.service_name] = properties;
+      }, this);
+    }
+    params.callback(serviceConfigMap, request);
+  },
+
+  loadAdvancedConfigAllError: function (request, ajaxOptions, error, opt, params) {
+    console.log('ERROR: failed to load stack configs for', params.serviceNames);
+    params.callback([], request);
+  },
+
+  /**
    * Load advanced configs by service names etc.
    * Use this method when you need to get configs for
    * particular services by single request

http://git-wip-us.apache.org/repos/asf/ambari/blob/d4a26a8f/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 0bc9722..95f7f5c 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -97,19 +97,21 @@ describe('App.WizardController', function () {
       sinon.stub(App.config, 'loadClusterConfig', function(callback){
         callback();
       });
-      sinon.stub(App.config, 'loadAdvancedConfig', function(val,callback) {
-        var properties = Em.A([
-          {
-            supportsFinal: '',
-            filename: 'name'
-          }
-        ]);
+      sinon.stub(App.config, 'loadAdvancedConfigAll', function(val,callback) {
+        var properties = {
+          "s1" : [
+            {
+              supportsFinal: '',
+              filename: 'name'
+            }
+          ]
+        };
         callback(properties);
       });
     });
     afterEach(function () {
       App.config.loadClusterConfig.restore();
-      App.config.loadAdvancedConfig.restore();
+      App.config.loadAdvancedConfigAll.restore();
     });
     it('Should load configs', function() {
       var data = Em.Object.create({