Browse Source

AMBARI-10330. Recommend config-dependencies API call should be hooked up properly (ababiichuk via srimanth)

Srimanth Gunturi 10 năm trước cách đây
mục cha
commit
105a62060d

+ 12 - 0
ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-site.xml

@@ -189,6 +189,10 @@
         <type>yarn-site</type>
         <name>yarn.scheduler.maximum-allocation-mb</name>
       </property>
+      <property>
+        <type>yarn-site</type>
+        <name>yarn.scheduler.minimum-allocation-mb</name>
+      </property>
     </depends-on>
   </property>
 
@@ -209,6 +213,10 @@
         <type>yarn-site</type>
         <name>yarn.scheduler.maximum-allocation-mb</name>
       </property>
+      <property>
+        <type>yarn-site</type>
+        <name>yarn.scheduler.minimum-allocation-mb</name>
+      </property>
     </depends-on>
   </property>
 
@@ -284,6 +292,10 @@
         <type>yarn-site</type>
         <name>yarn.scheduler.maximum-allocation-mb</name>
       </property>
+      <property>
+        <type>yarn-site</type>
+        <name>yarn.scheduler.minimum-allocation-mb</name>
+      </property>
     </depends-on>
   </property>
 

+ 18 - 4
ambari-web/app/mixins/common/configs/enhanced_configs.js

@@ -282,12 +282,10 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         services: this.get('serviceNames'),
         recommendations: recommendations
       };
-      /** TODO uncomment when be will be ready
-       if (App.get('supports.enhancedConfigs')) {
+      if (App.get('supports.enhancedConfigs')) {
         dataToSend.recommend = 'configuration-dependencies';
         dataToSend.changed_configurations = changedConfigs;
       }
-       **/
       return App.ajax.send({
         name: 'config.recommendations',
         sender: this,
@@ -345,7 +343,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         if (callback) {
           callback();
         }
-      }, this._discardChanges.bind(this));
+      });
     } else {
       if (callback) {
         callback();
@@ -519,6 +517,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
             if (value != configs[key].properties[propertyName]) {
               this.get('_dependentConfigValues').pushObject({
                 saveRecommended: true,
+                saveRecommendedDefault: true,
                 fileName: key,
                 propertyName: propertyName,
                 configGroup: configGroup,
@@ -528,6 +527,21 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
               });
             }
           }
+          /**
+           * saving new attribute values
+           */
+          if (configs[key].property_attributes && configs[key].property_attributes[propertyName]) {
+
+            var stackProperty = App.StackConfigProperty.find(propertyName + '_' + key);
+            if (stackProperty && stackProperty.get('valueAttributes')) {
+              if (configs[key].property_attributes[propertyName].min) {
+                stackProperty.set('valueAttributes.minimum', configs[key].property_attributes[propertyName].min);
+              }
+              if (configs[key].property_attributes[propertyName].max) {
+                stackProperty.set('valueAttributes.maximum', configs[key].property_attributes[propertyName].max);
+              }
+            }
+          }
         }
       }
     }

+ 34 - 0
ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js

@@ -35,6 +35,31 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
    */
   slider: null,
 
+  /**
+   * recreate widget in case max or min values were changed
+   * @method changeBoundaries
+   */
+  changeBoundaries: function() {
+    if ($.mocho) {
+      //temp fix as it can broke test that doesn't have any connection with this method
+      return;
+    }
+    var self = this;
+    var valueAttributes = this.get('config.stackConfigProperty.valueAttributes');
+    Em.run.once(this, function() {
+      self.prepareValueAttributes();
+      if (self.get('slider')) {
+        self.get('slider').destroy();
+        self.initSlider();
+        if (self.get('config.value') > valueAttributes.get('maximum')) {
+          self.set('mirrorValue', valueAttributes.get('maximum'))
+        }
+        if (self.get('config.value') < valueAttributes.get('minimum')) {
+          self.set('mirrorValue', valueAttributes.get('minimum'))
+        }
+      }
+    })
+  },
   /**
    * Determines if widget controls should be disabled
    * @type {boolean}
@@ -94,6 +119,15 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
     this.initSlider();
     this.toggleWidgetState();
     this.initPopover();
+    this.addObserver('config.stackConfigProperty.valueAttributes.minimum', this, this.changeBoundaries);
+    this.addObserver('config.stackConfigProperty.valueAttributes.maximum', this, this.changeBoundaries);
+    this.addObserver('config.stackConfigProperty.valueAttributes.step', this, this.changeBoundaries);
+  },
+
+  willDestroyElement: function() {
+    this.removeObserver('config.stackConfigProperty.valueAttributes.step', this, this.changeBoundaries);
+    this.removeObserver('config.stackConfigProperty.valueAttributes.maximum', this, this.changeBoundaries);
+    this.removeObserver('config.stackConfigProperty.valueAttributes.minimum', this, this.changeBoundaries);
   },
 
   /**

+ 9 - 10
ambari-web/app/views/common/modal_popups/dependent_configs_list_popup.js

@@ -22,15 +22,12 @@ var App = require('app');
  * Show confirmation popup
  * @param {[Object]} configs
  * @param {function} [callback=null]
- * @param {function} [secondaryCallback=null]
  * we use this parameter to defer saving configs before we make some decisions.
  * @return {App.ModalPopup}
  */
-App.showDependentConfigsPopup = function (configs, callback, secondaryCallback) {
+App.showDependentConfigsPopup = function (configs, callback) {
   return App.ModalPopup.show({
     encodeBody: false,
-    primary: Em.I18n.t('common.save'),
-    secondary: Em.I18n.t('common.discard'),
     header: Em.I18n.t('popup.dependent.configs.header'),
     classNames: ['sixty-percent-width-modal','modal-full-width'],
     configs: configs,
@@ -41,17 +38,19 @@ App.showDependentConfigsPopup = function (configs, callback, secondaryCallback)
       return App.get('router.mainServiceInfoConfigsController.stepConfigs').objectAt(0).get('configs');
     }.property('controller.stepConfigs.@each'),
     onPrimary: function () {
-      this.hide();
+      this._super();
+      configs.forEach(function(c) {
+        Em.set(c, 'saveRecommendedDefault', Em.get(c, 'saveRecommended'));
+      });
       if (callback) {
         callback();
       }
     },
     onSecondary: function() {
-      this.hide();
-      configs.setEach('saveRecommended', false);
-      if(secondaryCallback) {
-        secondaryCallback();
-      }
+      this._super();
+      configs.forEach(function(c) {
+        Em.set(c, 'saveRecommended', Em.get(c, 'saveRecommendedDefault'));
+      });
     }
   });
 };

+ 7 - 0
ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js

@@ -73,6 +73,13 @@ describe('App.SliderConfigWidgetView', function () {
     });
     viewFloat.willInsertElement();
     viewFloat.didInsertElement();
+    sinon.stub(viewInt, 'changeBoundaries', Em.K);
+    sinon.stub(viewFloat, 'changeBoundaries', Em.K);
+  });
+
+  afterEach(function() {
+    viewInt.changeBoundaries.restore();
+    viewFloat.changeBoundaries.restore();
   });
 
   describe('#mirrorValue', function () {