You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jg...@apache.org on 2018/05/24 15:35:58 UTC

[ambari] branch branch-feature-AMBARI-14714 updated: Config requests for multiple mpacks.

This is an automated email from the ASF dual-hosted git repository.

jgolieb pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by this push:
     new 2eab7cb  Config requests for multiple mpacks.
2eab7cb is described below

commit 2eab7cb060ae681f2ab9f7f219493bebdeddf7c0
Author: Jason Golieb <jg...@hortonworks.com>
AuthorDate: Wed May 23 13:13:39 2018 -0400

    Config requests for multiple mpacks.
---
 ambari-web/app/app.js                              |  8 +++++
 ambari-web/app/controllers/wizard.js               | 34 +++++++++++++++-------
 .../hosts/host_component_validation_mixin.js       | 18 ++----------
 ambari-web/app/mixins/common/serverValidator.js    | 17 +++++++----
 .../app/mixins/main/service/themes_mapping.js      | 22 +++++++-------
 ambari-web/app/utils/config.js                     | 11 +++----
 6 files changed, 64 insertions(+), 46 deletions(-)

diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 9614e28..d4c7c37 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -94,6 +94,14 @@ module.exports = Em.Application.create({
     return '/stacks/{0}/versions/{1}'.format(this.get('currentStackName') || 'HDP', this.get('currentStackVersionNumber'));
   }.property('currentStackName', 'currentStackVersionNumber'),
 
+  getStackVersionUrl: function (stackName, stackVersion) {
+    if (stackName && stackVersion) {
+      return `/stacks/${stackName}/versions/${stackVersion}`;
+    }
+
+    return null;
+  },
+
   falconServerURL: function () {
     var falconService = this.Service.find().findProperty('serviceName', 'FALCON');
     if (falconService) {
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 499c5ef..feccd7d 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -1525,24 +1525,36 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
    * @return {$.Deferred}
    */
   loadConfigThemes: function () {
-    var self = this;
-    var dfd = $.Deferred();
+    const self = this;
+    const dfd = $.Deferred();
+    
     if (!this.get('stackConfigsLoaded')) {
-      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.loadClusterConfigsFromStack().always(function() {
-        App.config.loadConfigsFromStack(serviceNames).done(function () {
-          self.loadConfigThemeForServices(serviceNames).always(function () {
-            self.set('stackConfigsLoaded', true);
-            dfd.resolve();
-          });
+      App.config.loadClusterConfigsFromStack().always(() => {
+        const mpacks = self.get('content.selectedMpacks');
+        const configPromises = mpacks.map(mpack => {
+          const stackName = mpack.name;
+          const stackVersion = mpack.version;
+          
+          const serviceNames = App.StackService.find().filter(service => {
+            return service.get('stackName') === stackName && service.get('stackVersion') === stackVersion
+              && (service.get('isSelected') || service.get('isInstalled'));
+          }).mapProperty('serviceName');
+
+          return App.config.loadConfigsFromStack(serviceNames, stackName, stackVersion)
+            .done(App.config.saveConfigsToModel)
+            .done(() => self.loadConfigThemeForServices(serviceNames, stackName, stackVersion));
         });
+
+        $.when(...configPromises).always(() => {
+          self.set('stackConfigsLoaded', true);
+          dfd.resolve();
+        });  
       });
     } else {
       dfd.resolve();
     }
+
     return dfd.promise();
   },
 
diff --git a/ambari-web/app/mixins/common/hosts/host_component_validation_mixin.js b/ambari-web/app/mixins/common/hosts/host_component_validation_mixin.js
index a8b1cd4..a7e752c 100644
--- a/ambari-web/app/mixins/common/hosts/host_component_validation_mixin.js
+++ b/ambari-web/app/mixins/common/hosts/host_component_validation_mixin.js
@@ -71,27 +71,15 @@ App.HostComponentValidationMixin = Em.Mixin.create(App.BlueprintMixin, {
   },
 
   /**
-   * Get the url to use to request the correct stack version from stack advisor.
-   * Falls back to using the old global config value if necessary.
-   * 
-   * @param {object} options Should include stackName and stackVersion properties, which should refer to the mpack being installed. 
-   */
-  getStackVersionUrl(options) {
-    if (options.stackName && options.stackVersion) {
-      return '/stacks/' + options.stackName + '/versions/' + options.stackVersion;
-    }
-
-    return App.get('stackVersionURL');
-  },
-
-  /**
    * Returns request data for validation request
    * @method getHostComponentValidationParams
    * @return {HostValidationRequestData}
    */
   getHostComponentValidationParams: function(options) {
+    const stackVersionUrl = App.getStackVersionUrl(options.stackName, options.stackVersion) || App.get('stackVersionURL');
+
     return {
-      stackVersionUrl: this.getStackVersionUrl(options),
+      stackVersionUrl: stackVersionUrl,
       hosts: options.hosts,
       services: options.services,
       validate: 'host_groups',
diff --git a/ambari-web/app/mixins/common/serverValidator.js b/ambari-web/app/mixins/common/serverValidator.js
index b60ae65..4b40bb1 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -133,7 +133,8 @@ App.ServerValidatorMixin = Em.Mixin.create({
       criticalIssues: []
     }));
 
-    this.runServerSideValidation().done(function() {
+    const mpacks = this.get('content.selectedMpacks'); //TODO - mpacks
+    this.runServerSideValidation(mpacks[0].name, mpacks[0].version).done(function() {
       if (self.get('configErrorList.issues.length') || self.get('configErrorList.criticalIssues.length')) {
         App.showConfigValidationPopup(self.get('configErrorList'), primary, secondary, self);
       } else {
@@ -151,7 +152,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
    * send request to validate configs
    * @returns {*}
    */
-  runServerSideValidation: function () {
+  runServerSideValidation: function (stackName, stackVersion) {
     var self = this;
     var recommendations = this.get('hostGroups');
     var stepConfigs = this.get('stepConfigs');
@@ -163,7 +164,9 @@ App.ServerValidatorMixin = Em.Mixin.create({
         var request = self.validateSelectedConfigs({
           hosts: self.get('hostNames'),
           services: self.get('serviceNames'),
-          blueprint: recommendations
+          blueprint: recommendations,
+          stackName: stackName,
+          stackVersion: stackVersion
         });
         self.set('validationRequest', request);
         request.done(dfd.resolve).fail(dfd.reject);
@@ -208,8 +211,10 @@ App.ServerValidatorMixin = Em.Mixin.create({
    * @returns {ConfigsValidationRequestData}
    */
   getServiceConfigsValidationParams: function(options) {
+    const stackVersionUrl = App.getStackVersionUrl(options.stackName, options.stackVersion) || App.get('stackVersionURL');
+
     return {
-      stackVersionUrl: App.get('stackVersionURL'),
+      stackVersionUrl: stackVersionUrl,
       hosts: options.hosts,
       services: options.services,
       validate: 'configurations',
@@ -379,12 +384,14 @@ App.ServerValidatorMixin = Em.Mixin.create({
   valueObserver: function () {
     var self = this;
     if (this.get('isInstallWizard') && this.get('currentTabName') === 'all-configurations') {
+      const mpacks = this.get('content.selectedMpacks'); //TODO - mpacks
+
       if (this.get('requestTimer')) clearTimeout(this.get('requestTimer'));
       self.set('requestTimer', setTimeout(function () {
         if (self.get('validationRequest')) {
           self.get('validationRequest').abort();
         }
-        self.runServerSideValidation().done(function () {
+        self.runServerSideValidation(mpacks[0].name, mpacks[0].version).done(function () {
           self.set('validationRequest', null);
           self.set('requestTimer', 0);
         });
diff --git a/ambari-web/app/mixins/main/service/themes_mapping.js b/ambari-web/app/mixins/main/service/themes_mapping.js
index 2dc2698..7e8fe8d 100644
--- a/ambari-web/app/mixins/main/service/themes_mapping.js
+++ b/ambari-web/app/mixins/main/service/themes_mapping.js
@@ -63,16 +63,18 @@ App.ThemesMappingMixin = Em.Mixin.create({
    * @param {String|String[]} serviceNames
    * @returns {$.ajax}
    */
-  loadConfigThemeForServices: function (serviceNames) {
+  loadConfigThemeForServices: function (serviceNames, stackName, stackVersion) {
+    const stackVersionUrl = App.getStackVersionUrl(stackName, stackVersion) || App.get('stackVersionURL');
+
     return App.ajax.send({
       name: 'configs.theme.services',
       sender: this,
       data: {
         serviceNames: Em.makeArray(serviceNames).join(','),
-        stackVersionUrl: App.get('stackVersionURL')
+        stackVersionUrl: stackVersionUrl
       },
-      success: '_loadConfigThemeForServicesSuccess',
-      error: '_loadConfigThemeForServicesError'
+      success: 'loadConfigThemeForServicesSuccess',
+      error: 'loadConfigThemeForServicesError'
     });
   },
 
@@ -82,9 +84,9 @@ App.ThemesMappingMixin = Em.Mixin.create({
    * @param opt
    * @param params
    * @private
-   * @method _loadConfigThemeForServicesSuccess
+   * @method loadConfigThemeForServicesSuccess
    */
-  _loadConfigThemeForServicesSuccess: function(data, opt, params) {
+  loadConfigThemeForServicesSuccess: function(data, opt, params) {
     if (!data.items.length) return;
     App.themesMapper.map({
       items: data.items.mapProperty('themes').reduce(function(p,c) {
@@ -95,16 +97,16 @@ App.ThemesMappingMixin = Em.Mixin.create({
 
   /**
    * Error-callback for <code>loadConfigThemeForServices</code>
-   * @param {object} request
+   * @param {object} jqXHR
    * @param {object} ajaxOptions
    * @param {string} error
    * @param {object} opt
    * @param {object} params
    * @private
-   * @method _loadConfigThemeForServicesError
+   * @method loadConfigThemeForServicesError
    */
-  _loadConfigThemeForServicesError: function(request, ajaxOptions, error, opt, params) {
-
+  loadConfigThemeForServicesError: function(jqXHR, ajaxOptions, error, opt) {
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
   }
 
 });
\ No newline at end of file
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index d31ba01..d86a0bf 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1049,17 +1049,18 @@ App.config = Em.Object.create({
    * @returns {$.ajax}
    * @method loadConfigsFromStack
    */
-  loadConfigsFromStack: function (serviceNames) {
+  loadConfigsFromStack: function (serviceNames, stackName, stackVersion) {
     serviceNames = serviceNames || [];
-    var name = serviceNames.length > 0 ? 'configs.stack_configs.load.services' : 'configs.stack_configs.load.all';
+    const name = serviceNames.length > 0 ? 'configs.stack_configs.load.services' : 'configs.stack_configs.load.all';
+    const stackVersionUrl = App.getStackVersionUrl(stackName, stackVersion) || App.get('stackVersionURL');
+    
     return App.ajax.send({
       name: name,
       sender: this,
       data: {
-        stackVersionUrl: App.get('stackVersionURL'),
+        stackVersionUrl: stackVersionUrl,
         serviceList: serviceNames.join(',')
-      },
-      success: 'saveConfigsToModel'
+      }
     });
   },
 

-- 
To stop receiving notification emails like this one, please contact
jgolieb@apache.org.