You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2016/02/26 10:10:49 UTC

ambari git commit: AMBARI-15186 Config saving discards Capacity-scheduler changes. (ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 6eb9e78d4 -> fc8f637b5


AMBARI-15186 Config saving discards Capacity-scheduler changes. (ababiichuk)


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

Branch: refs/heads/branch-2.2
Commit: fc8f637b53706a525b9d113b63d458a8496a151e
Parents: 6eb9e78
Author: ababiichuk <ab...@hortonworks.com>
Authored: Fri Feb 26 10:12:30 2016 +0200
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Fri Feb 26 10:12:30 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            |  3 +
 .../app/mixins/common/configs/configs_saver.js  |  4 ++
 ambari-web/app/utils/config.js                  | 44 +++++++++++-
 ambari-web/app/views/common/controls_view.js    | 74 ++++----------------
 4 files changed, 61 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fc8f637b/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 9e94182..aa82234 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -870,6 +870,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
       installedServiceNamesMap[name] = true;
     });
     stepController.get('stepConfigs').forEach(function (_content) {
+      if (_content.serviceName === 'YARN') {
+        _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
+      }
       _content.get('configs').forEach(function (_configProperties) {
         if (!Em.isNone(_configProperties.get('group'))) {
           return false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/fc8f637b/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 9fa2e4f..ecc3466 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -293,6 +293,10 @@ App.ConfigsSaverMixin = Em.Mixin.create({
    */
   getServiceConfigToSave: function(serviceName, configs) {
 
+    if (serviceName === 'YARN') {
+      configs = App.config.textareaIntoFileConfigs(configs, 'capacity-scheduler.xml');
+    }
+
     //generates list of properties that was changed
     var modifiedConfigs = this.getModifiedConfigs(configs);
     var serviceFilenames = Object.keys(App.StackService.find(serviceName).get('configTypes')).map(function (type) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/fc8f637b/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 209452c..c7c061e 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -919,7 +919,7 @@ App.config = Em.Object.create({
     var connectedConfigs = configs.filter(function(config) {
       return !excludedConfigs.contains(App.config.configId(config.get('name'), config.get('filename'))) && (config.get('filename') === 'capacity-scheduler.xml');
     });
-    connectedConfigs.setEach('isVisible', false);
+    var names = connectedConfigs.mapProperty('name');
 
     connectedConfigs.forEach(function (config) {
       value += config.get('name') + '=' + config.get('value') + '\n';
@@ -944,10 +944,12 @@ App.config = Em.Object.create({
       'recommendedIsFinal': recommendedIsFinal,
       'displayName': 'Capacity Scheduler',
       'description': 'Capacity Scheduler properties',
-      'displayType': 'capacityScheduler',
-      'isRequiredByAgent': false
+      'displayType': 'capacityScheduler'
     });
 
+    configs = configs.filter(function(c) {
+      return !(names.contains(c.get('name')) && (c.get('filename') === 'capacity-scheduler.xml'));
+    });
     configs.push(App.ServiceConfigProperty.create(cs));
     return configs;
   },
@@ -972,6 +974,42 @@ App.config = Em.Object.create({
   },
 
   /**
+   * transform one config with textarea content
+   * into set of configs of file
+   * @param configs
+   * @param filename
+   * @return {*}
+   */
+  textareaIntoFileConfigs: function (configs, filename) {
+    var configsTextarea = configs.findProperty('name', 'capacity-scheduler');
+    if (configsTextarea && !App.get('testMode')) {
+      var properties = configsTextarea.get('value').split('\n');
+
+      properties.forEach(function (_property) {
+        var name, value;
+        if (_property) {
+          _property = _property.split('=');
+          name = _property[0];
+          value = (_property[1]) ? _property[1] : "";
+          configs.push(Em.Object.create({
+            name: name,
+            value: value,
+            savedValue: value,
+            serviceName: configsTextarea.get('serviceName'),
+            filename: filename,
+            isFinal: configsTextarea.get('isFinal'),
+            isNotDefaultValue: configsTextarea.get('isNotDefaultValue'),
+            isRequiredByAgent: configsTextarea.get('isRequiredByAgent'),
+            group: null
+          }));
+        }
+      });
+      return configs.without(configsTextarea);
+    }
+    return configs;
+  },
+
+  /**
    * trim trailing spaces for all properties.
    * trim both trailing and leading spaces for host displayType and hive/oozie datebases url.
    * for directory or directories displayType format string for further using.

http://git-wip-us.apache.org/repos/asf/ambari/blob/fc8f637b/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 95d097f..68d539c 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -296,73 +296,25 @@ App.ServiceConfigTextAreaContent = Ember.TextArea.extend(App.ServiceConfigPopove
 /**
  * Special config type for Capacity Scheduler
  */
-App.CapacitySceduler = Ember.TextArea.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
+App.CapacitySceduler = App.ServiceConfigTextArea.extend({
 
-  configs: function() {
-    return this.get('controller.stepConfigs').findProperty('serviceName', 'YARN').get('configs');
-  }.property('controller.stepConfigs'),
-
-  valueBinding: 'serviceConfig.value',
-  excludedConfigs: function() {
-    return App.config.getPropertiesFromTheme('YARN');
-  }.property(),
   rows: 16,
-  classNames: ['directories'],
-  classNameBindings: ['widthClass'],
-  widthClass: 'span9',
 
-  connectedConfigs: function() {
-    return this.get('categoryConfigsAll').filter(function(config) {
-      return !this.get('excludedConfigs').contains(App.config.configId(config.get('name'), config.get('filename')))
-        && (config.get('name') !== this.get('serviceConfig.name'))
-        && (config.get('filename') === 'capacity-scheduler.xml');
-    }, this);
-  }.property('categoryConfigsAll.length'),
-
-  valueObserver: function () {
-    var self = this, names = [];
-    delay(function () {
-      self.get('serviceConfig.value').split('\n').forEach(function (_property) {
-        if (_property) {
-          _property = _property.split('=');
-          var name = _property[0];
-          var value = (_property[1]) ? _property[1] : "";
-
-          names.push(name);
-
-          var cfg = self.get('connectedConfigs').findProperty('name', name);
-          if (cfg) {
-            /** update configs **/
-            if (cfg.get('value') !== value) {
-              cfg.set('value', value);
-              self.sendRequestRorDependentConfigs(cfg);
-            }
-          } else {
-            /** add configs **/
-            var newCfg = App.config.createDefaultConfig(name, 'YARN', 'capacity-scheduler', true, {
-              'value': value
-            });
-            self.get('configs').pushObject(App.ServiceConfigProperty.create(newCfg));
-          }
+  sendRequestRorDependentConfigs: function(config, controller) {
+    if (!config.get('isValid') && config.get('isNotDefaultValue')) return $.Deferred().resolve().promise();
+    controller = controller || this.get('controller');
+    if (controller && ['mainServiceInfoConfigsController','wizardStep7Controller'].contains(controller.get('name'))) {
+      return controller.getRecommendationsForDependencies(config.get('value').split('\n').map(function (_property) {
+        return {
+          "type": 'capacity-scheduler',
+          "name": _property.split('=')[0]
         }
-      });
-
-      /** remove configs **/
-      self.get('connectedConfigs').filter(function(c) {
-        return !names.contains(c.get('name'));
-      }).forEach(function(c) {
-        self.get('configs').removeObject(c);
-      });
+      }), false);
+    }
 
-    }, 500);
-  }.observes('serviceConfig.value'),
+    return $.Deferred().resolve().promise();
+  }
 
-  /**
-   *
-   */
-  isFinalObserver: function () {
-    this.get('connectedConfigs').setEach('isFinal', this.get('serviceConfig.isFinal'));
-  }.observes('serviceConfig.isFinal')
 });