AMBARI-18522 Add Service wizard breaks on large clusters when persisting data in localStorage. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/26660f20 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/26660f20 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/26660f20 Branch: refs/heads/branch-dev-patch-upgrade Commit: 26660f20e071d2a01dd0d37414d556e34947018d Parents: a442efb Author: ababiichuk <ababiic...@hortonworks.com> Authored: Tue Oct 4 13:55:21 2016 +0300 Committer: ababiichuk <ababiic...@hortonworks.com> Committed: Wed Oct 5 12:38:50 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/controllers/wizard.js | 14 +-- .../app/controllers/wizard/step7_controller.js | 20 +++- ambari-web/app/utils/config.js | 20 ++++ ambari-web/test/controllers/wizard_test.js | 97 +------------------- 4 files changed, 45 insertions(+), 106 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/26660f20/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index def6b84..e0df4fa 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -920,19 +920,11 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM 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'))) { + _content.get('configs').forEach(function (_configProperty) { + if (!Em.isNone(_configProperty.get('group'))) { return false; } - var configProperty = App.config.createDefaultConfig( - _configProperties.get('name'), - _configProperties.get('filename'), - // need to invert boolean because this argument will be inverted in method body - !_configProperties.get('isUserProperty'), - _configProperties.getProperties('value', 'isRequired', 'errorMessage', 'warnMessage') - ); - configProperty = App.config.mergeStaticProperties(configProperty, _configProperties, [], ['name', 'filename', 'isUserProperty', 'value']); - + var configProperty = App.config.createMinifiedConfig(_configProperty); if (this.isExcludedConfig(configProperty)) { configProperty.value = ''; } http://git-wip-us.apache.org/repos/asf/ambari/blob/26660f20/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 dc030be..d5cbe67 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -478,9 +478,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage')); - var storedConfigs = this.get('content.serviceConfigProperties'); - - var configs = storedConfigs && storedConfigs.length ? storedConfigs : App.configsCollection.getAll(); + var configs = this.getInitialConfigs(this.get('content.serviceConfigProperties')); this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []); if (this.get('wizardController.name') === 'addServiceController' && !this.get('content.serviceConfigProperties.length')) { @@ -494,6 +492,22 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E }, /** + * If configs are saved in store returns stored configs merged with stack + * otherwise return stack configs + * @returns {Object[]} + */ + getInitialConfigs: function(storedConfigs) { + if (storedConfigs && storedConfigs.length) { + var mergedConfigs = []; + storedConfigs.forEach(function (c) { + mergedConfigs.push($.extend({}, App.configsCollection.getConfigByName(c.name, c.filename), c)); + }); + return mergedConfigs; + } + return App.configsCollection.getAll(); + }, + + /** * Update hawq configuration depending on the state of the cluster * @param {Array} configs */ http://git-wip-us.apache.org/repos/asf/ambari/blob/26660f20/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index abb2fbf..d562e9e 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -1244,6 +1244,26 @@ App.config = Em.Object.create({ } return false; }, + + /** + * creates config object with non static properties like + * 'value', 'isFinal', 'errorMessage' and + * 'id', 'name', 'filename', + * @param configProperty + * @returns {Object} + */ + createMinifiedConfig: function (configProperty) { + if (configProperty instanceof Ember.Object) { + return configProperty.getProperties('name', 'filename', 'serviceName', 'value', 'isFinal'); + } + return { + name: configProperty.name, + filename: configProperty.filename, + serviceName: configProperty.serviceName, + value: configProperty.value, + isFinal: configProperty.isFinal + } + }, /** * Update config property value based on its current value and list of zookeeper server hosts. http://git-wip-us.apache.org/repos/asf/ambari/blob/26660f20/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 2b28d01..6854c42 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -1070,49 +1070,19 @@ describe('App.WizardController', function () { serviceName: 'KERBEROS', configs: [ Em.Object.create({ - id: 'id', name: 'admin_password', value: 'value', - defaultValue: 'defaultValue', - description: 'description', serviceName: 'serviceName', - domain: 'domain', - isVisible: true, - isNotDefaultValue: true, isFinal: true, - defaultIsFinal: true, - supportsFinal: true, - filename: 'krb5-conf.xml', - displayType: 'string', - isRequiredByAgent: true, - hasInitialValue: true, - isRequired: true, - group: {name: 'group'}, - showLabel: true, - category: 'some_category' + filename: 'krb5-conf.xml' }), Em.Object.create({ - id: 'id', name: 'admin_principal', value: 'value', - defaultValue: 'defaultValue', - description: 'description', serviceName: 'serviceName', - domain: 'domain', - isVisible: true, - isNotDefaultValue: true, isFinal: true, - defaultIsFinal: true, - supportsFinal: true, - filename: 'krb5-conf.xml', - displayType: 'string', - isRequiredByAgent: true, - hasInitialValue: true, - isRequired: true, - group: {name: 'group'}, - showLabel: true, - category: 'some_category' + filename: 'krb5-conf.xml' }) ] }) @@ -1126,48 +1096,18 @@ describe('App.WizardController', function () { serviceName: 'HDFS', configs: [ Em.Object.create({ - id: 'id', name: 'name', value: 'value', - defaultValue: 'defaultValue', - description: 'description', serviceName: 'serviceName', - domain: 'domain', - isVisible: true, - isNotDefaultValue: true, isFinal: true, - defaultIsFinal: true, - supportsFinal: true, filename: 'hdfs-site', - displayType: 'string', - isRequiredByAgent: true, - hasInitialValue: true, - isRequired: true, - isUserProperty: true, - showLabel: true, - category: 'some_category' }), Em.Object.create({ - id: 'id', name: 'name2', value: 'value', - defaultValue: 'defaultValue', - description: 'description', serviceName: 'serviceName', - domain: 'domain', - isVisible: true, - isNotDefaultValue: true, isFinal: true, - defaultIsFinal: true, - supportsFinal: true, - filename: 'hdfs-site', - displayType: 'string', - isRequiredByAgent: true, - hasInitialValue: true, - isRequired: false, - isUserProperty: false, - showLabel: true, - category: 'some_category' + filename: 'hdfs-site' }) ] }), @@ -1175,26 +1115,11 @@ describe('App.WizardController', function () { serviceName: 'YARN', configs: [ Em.Object.create({ - id: 'id', name: 'name', value: 'value', - defaultValue: 'defaultValue', - description: 'description', serviceName: 'serviceName', - domain: 'domain', - isVisible: true, isFinal: true, - defaultIsFinal: true, - supportsFinal: true, - filename: 'filename', - displayType: 'string', - isRequiredByAgent: true, - hasInitialValue: true, - isRequired: true, - isUserProperty: false, - group: {name: 'group'}, - showLabel: true, - category: 'some_category' + filename: 'filename' }) ] }) @@ -1203,8 +1128,7 @@ describe('App.WizardController', function () { it('should save configs from default config group to content.serviceConfigProperties', function () { c.saveServiceConfigProperties(stepController); var saved = c.get('content.serviceConfigProperties'); - expect(saved.length).to.equal(2); - expect(saved[0].category).to.equal('some_category'); + expect(saved.length).to.equal(3); }); it('should not save admin_principal or admin_password to the localStorage', function () { @@ -1212,17 +1136,6 @@ describe('App.WizardController', function () { var saved = c.get('content.serviceConfigProperties'); expect(saved.everyProperty('value', '')).to.be.true; }); - - it('should save `isUserProperty` and `isRequired` attributes correctly', function() { - c.saveServiceConfigProperties(stepController); - var saved = c.get('content.serviceConfigProperties'), - nameProp = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name', 'name'), - name2Prop = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name', 'name2'); - assert.isTrue(Em.get(nameProp, 'isRequired'), 'hdfs-site.xml:name isRequired validation'); - assert.isTrue(Em.get(nameProp, 'isUserProperty'), 'hdfs-site.xml:name isUserProperty validation'); - assert.isFalse(Em.get(name2Prop, 'isRequired'), 'hdfs-site.xml:name2 isRequired validation'); - assert.isFalse(Em.get(name2Prop, 'isUserProperty'), 'hdfs-site.xml:name2 isUserProperty validation'); - }); }); describe('#enableStep', function () {