ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-11248. Config Override issue (onechiporenko)
Date Tue, 19 May 2015 19:06:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 1ee56761e -> 15616fd67


AMBARI-11248. Config Override issue (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 15616fd67c76360d9364a23ab9efdc01a809ea92
Parents: 1ee5676
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Tue May 19 22:03:55 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Tue May 19 22:03:55 2015 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  8 ++++++--
 .../app/controllers/wizard/step7_controller.js  |  7 +++++--
 .../models/configs/objects/service_config.js    |  2 +-
 .../configs/objects/service_config_property.js  | 14 ++++++++++---
 ambari-web/app/models/configs/sub_section.js    |  6 ++++--
 ambari-web/app/styles/widgets.less              |  3 +++
 .../configs/widgets/config_widget_view.js       | 12 +++++++++--
 .../widgets/slider_config_widget_view.js        |  9 ++-------
 ambari-web/test/models/configs/section_test.js  | 10 ++++++++--
 .../test/models/configs/sub_section_test.js     | 21 +++++++++++++++-----
 .../widgets/slider_config_widget_view_test.js   |  6 +++---
 11 files changed, 69 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 8ca6840..a82dc41 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -179,8 +179,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   errorsCount: function () {
     return this.get('selectedService.configs').filter(function (config) {
       return Em.isNone(config.get('widget'));
-    }).filterProperty('isValid', false).filterProperty('isVisible').length;
-  }.property('selectedService.configs.@each.isValid'),
+    }).filter(function(config) {
+      return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid',
false);
+    }).filterProperty('isVisible').length;
+  }.property('selectedService.configs.@each.isValid', 'selectedService.configs.@each.overrideErrorTrigger'),
 
   /**
    * Determines if Save-button should be disabled
@@ -370,6 +372,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * @method onConfigGroupChange
    */
   onConfigGroupChange: function () {
+    console.time('!!!!!!!!!');
     var self = this;
     this.get('stepConfigs').clear();
     var selectedConfigGroup = this.get('selectedConfigGroup');
@@ -418,6 +421,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
         } else {
           self.onLoadOverrides(self.get('allConfigs'));
         }
+        console.timeEnd('!!!!!!!!!');
       });
     });
   }.observes('selectedConfigGroup'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/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 7abe894..f0ae1d3 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -133,8 +133,10 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
   errorsCount: function () {
     return this.get('selectedService.configs').filter(function (config) {
       return Em.isNone(config.get('widget'));
-    }).filterProperty('isValid', false).filterProperty('isVisible').length;
-  }.property('selectedService.configs.@each.isValid'),
+    }).filter(function(config) {
+      return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid',
false);
+    }).filterProperty('isVisible').length;
+  }.property('selectedService.configs.@each.isValid', 'selectedService.configs.@each.overrideErrorTrigger'),
 
   /**
    * Should Next-button be disabled
@@ -477,6 +479,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
         serviceConfigProperty.set('overrides', parentOverridesArray);
       }
       serviceConfigProperty.get('overrides').pushObject(newSCP);
+      newSCP.validate();
     }, this);
     return serviceConfigProperty;
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/models/configs/objects/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config.js b/ambari-web/app/models/configs/objects/service_config.js
index e852c56..430d15d 100644
--- a/ambari-web/app/models/configs/objects/service_config.js
+++ b/ambari-web/app/models/configs/objects/service_config.js
@@ -50,7 +50,7 @@ App.ServiceConfig = Ember.Object.extend({
       if (item.get('overrides')) {
         item.get('overrides').forEach(function (e) {
           if (e.error) {
-            if (category) {
+            if (category && !Em.get(e, 'parentSCP.widget')) {
               category.incrementProperty('nonSlaveErrorCount');
             }
             overrideErrors++;

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/models/configs/objects/service_config_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js
index 06994c0..a1e79ae 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -119,8 +119,16 @@ App.ServiceConfigProperty = Em.Object.extend({
    * @type {boolean}
    */
   hasIssues: function () {
-    return (this.get('errorMessage') + this.get('warnMessage')) !== "";
-  }.property('errorMessage', 'warnMessage'),
+    var originalSCPIssued = (this.get('errorMessage') + this.get('warnMessage')) !== "";
+    var overridesIssue = false;
+    (this.get('overrides') || []).forEach(function(override) {
+      if (override.get('errorMessage') + override.get('warnMessage') !== "") {
+        overridesIssue = true;
+        return;
+      }
+    });
+    return originalSCPIssued || overridesIssue;
+  }.property('errorMessage', 'warnMessage', 'overrideErrorTrigger'),
 
   overrideErrorTrigger: 0, //Trigger for overridable property error
   isRestartRequired: false,
@@ -470,4 +478,4 @@ App.ServiceConfigProperty = Em.Object.extend({
     return isError;
   }
 
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/models/configs/sub_section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/sub_section.js b/ambari-web/app/models/configs/sub_section.js
index d500a65..d33fbb9 100644
--- a/ambari-web/app/models/configs/sub_section.js
+++ b/ambari-web/app/models/configs/sub_section.js
@@ -77,8 +77,10 @@ App.SubSection = DS.Model.extend({
    * @type {number}
    */
   errorsCount: function () {
-    return this.get('configs').filterProperty('isValid', false).length;
-  }.property('configs.@each.isValid'),
+    return this.get('configs').filter(function(config) {
+      return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid',
false);
+    }).length;
+  }.property('configs.@each.isValid', 'configs.@each.overrideErrorTrigger'),
 
   /**
    * @type {boolean}

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/styles/widgets.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/widgets.less b/ambari-web/app/styles/widgets.less
index 845ae0d..53296f3 100644
--- a/ambari-web/app/styles/widgets.less
+++ b/ambari-web/app/styles/widgets.less
@@ -259,6 +259,9 @@
   }
   .overrideField {
     margin-top: 30px;
+    .ui-slider-wrapper-inner {
+      padding-top: 20px;
+    }
   }
 }
 .slider-disabled {

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/views/common/configs/widgets/config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
index b7c1931..d1091d3 100644
--- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
@@ -178,9 +178,17 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
      */
     issuedConfig: function() {
       var config = this.get('config');
-      // check editable overrides
-      if (!config.get('isEditable') && config.get('overrides.length') &&
config.get('overrides').someProperty('isEditable', true)) {
+      // check editable override
+      if (!config.get('isEditable') && config.get('isOriginalSCP') && config.get('overrides.length')
&& config.get('overrides').someProperty('isEditable', true)) {
         config = config.get('overrides').findProperty('isEditable', true);
+      } else if (config.get('isOriginalSCP') && config.get('isEditable')) {
+        // use original config if it is not valid
+        if (!config.get('isValid')) {
+          return config;
+        // scan overrides for non valid values and use it
+        } else if (config.get('overrides.length') && config.get('overrides').someProperty('isValid',
false)) {
+          return config.get('overrides').findProperty('isValid', false);
+        }
       }
       return config;
     }.property('config.isEditable', 'config.overrides.length')

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
index 2924514..968ae38 100644
--- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
@@ -228,13 +228,8 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
           warn: true
         });
       } else {
-        this.set('isMirrorValueValid', true);
-        this.get('config').setProperties({
-          warnMessage: '',
-          errorMessage: '',
-          value: '' + this.configValueByWidget(parsed),
-          warn: false
-        });
+        this.set('isMirrorValueValid', !this.get('config.error'));
+        this.set('config.value', '' + this.configValueByWidget(parsed));
         if (slider) {
           slider.setValue(parsed);
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/test/models/configs/section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/section_test.js b/ambari-web/test/models/configs/section_test.js
index 1b72a11..c8f2ebf 100644
--- a/ambari-web/test/models/configs/section_test.js
+++ b/ambari-web/test/models/configs/section_test.js
@@ -29,8 +29,14 @@ describe('App.Section', function () {
 
     beforeEach(function () {
       model.reopen({subSections: [
-        App.SubSection.createRecord({configs: [{isValid: true}, {isValid: false}]}),
-        App.SubSection.createRecord({configs: [{isValid: true}, {isValid: false}]})
+        App.SubSection.createRecord({configs: [
+          App.ServiceConfigProperty.create({isValid: true}),
+          App.ServiceConfigProperty.create({isValid: false})
+        ]}),
+        App.SubSection.createRecord({configs: [
+          App.ServiceConfigProperty.create({isValid: true}),
+          App.ServiceConfigProperty.create({isValid: false})
+        ]})
       ]});
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/test/models/configs/sub_section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/sub_section_test.js b/ambari-web/test/models/configs/sub_section_test.js
index ec8c626..cf394e5 100644
--- a/ambari-web/test/models/configs/sub_section_test.js
+++ b/ambari-web/test/models/configs/sub_section_test.js
@@ -29,15 +29,26 @@ describe('App.SubSection', function () {
 
     beforeEach(function () {
       model.set('configs', [
-        {isValid: false},
-        {isValid: true},
-        {isValid: false},
-        {isValid: true}
+        App.ServiceConfigProperty.create({isValid: true}),
+        App.ServiceConfigProperty.create({isValid: false}),
+        App.ServiceConfigProperty.create({isValid: false}),
+        App.ServiceConfigProperty.create({isValid: false}),
       ]);
     });
 
     it('should use configs.@each.isValid', function () {
-      expect(model.get('errorsCount')).to.equal(2);
+      expect(model.get('errorsCount')).to.equal(3);
+    });
+
+    it('should use configs.@each.overrideErrorTrigger', function() {
+      // original value is valid
+      var validOriginalSCP = model.get('configs').objectAt(0);
+      // add override with not valid value
+      validOriginalSCP.set('overrides', [
+        App.ServiceConfigProperty.create({ isValid: false }),
+        App.ServiceConfigProperty.create({ isValid: true })
+      ]);
+      expect(model.get('errorsCount')).to.equal(4);
     });
 
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/15616fd6/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
index ce42aba..7536cda 100644
--- a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
@@ -31,7 +31,7 @@ describe('App.SliderConfigWidgetView', function () {
         disable: Em.K,
         setValue: Em.K
       },
-      config: Em.Object.create({
+      config: App.ServiceConfigProperty.create({
         name: 'a.b.c',
         description: 'A B C',
         value: '486',
@@ -61,7 +61,7 @@ describe('App.SliderConfigWidgetView', function () {
         disable: Em.K,
         setValue: Em.K
       },
-      config: Em.Object.create({
+      config: App.ServiceConfigProperty.create({
         name: 'a.b.c2',
         description: 'A B C 2',
         value: '72.2',
@@ -90,7 +90,7 @@ describe('App.SliderConfigWidgetView', function () {
         disable: Em.K,
         setValue: Em.K
       },
-      config: Em.Object.create({
+      config: App.ServiceConfigProperty.create({
         name: 'a.b.c3',
         description: 'A B C 3',
         value: '0.22',


Mime
View raw message