AMBARI-18819 Ambari tab consuming lots of memory & cpu. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/79de029b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/79de029b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/79de029b Branch: refs/heads/branch-feature-AMBARI-18634 Commit: 79de029b544f0f6aa7439b65c120b62da7053a5d Parents: e158756 Author: Andrii Tkach <[email protected]> Authored: Tue Nov 8 13:19:30 2016 +0200 Committer: Andrii Tkach <[email protected]> Committed: Tue Nov 8 13:19:30 2016 +0200 ---------------------------------------------------------------------- .../models/configs/objects/service_config.js | 61 +++++++++++++------- ambari-web/app/utils/helper.js | 2 + .../admin/kerberos/step4_controller_test.js | 21 +++++-- .../configs/objects/service_config_test.js | 5 +- 4 files changed, 63 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/79de029b/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 4bddcb6..a0800fa 100644 --- a/ambari-web/app/models/configs/objects/service_config.js +++ b/ambari-web/app/models/configs/objects/service_config.js @@ -44,17 +44,52 @@ App.ServiceConfig = Ember.Object.extend({ * * @type {Object[]} */ - activeProperties: function() { - return this.get('configs').filter(function(c) { + activeProperties: [], + + configsWithErrors: [], + + /** + * Collection of properties that were changed: + * for saved properties use - <code>isNotDefaultValue<code> + * for not saved properties (on wizards, for new services) use + * - <code>isNotInitialValue<code> + * for added properties use - <code>isNotSaved<code> + * @type {Object[]} + */ + changedConfigProperties: [], + + setActiveProperties: function() { + Em.run.once(this, 'setActivePropertiesOnce'); + }.observes('[email protected]', '[email protected]', '[email protected]'), + + setActivePropertiesOnce: function() { + var activeProperties = this.get('configs').filter(function(c) { return c.get('isActive') && (c.get('isRequiredByAgent') || c.get('isRequired')); }); - }.property('[email protected]', '[email protected]'), + this.set('activeProperties', activeProperties); + }, + + setChangedConfigProperties: function() { + Em.run.once(this, 'setChangedConfigPropertiesOnce'); + }.observes('[email protected]', '[email protected]', '[email protected]'), - configsWithErrors: function() { - return this.get('activeProperties').filter(function(c) { + setChangedConfigPropertiesOnce: function() { + var changedConfigProperties = this.get('activeProperties').filter(function(c) { + return c.get('isNotDefaultValue') || c.get('isNotSaved') || c.get('isNotInitialValue'); + }, this); + this.set('changedConfigProperties', changedConfigProperties); + }, + + setConfigsWithErrors: function() { + Em.run.once(this, 'setConfigsWithErrorsOnce'); + }.observes('[email protected]', '[email protected]', 'activeProperties.length'), + + setConfigsWithErrorsOnce: function() { + var configsWithErrors = this.get('activeProperties').filter(function(c) { return !c.get('isValid') || !c.get('isValidOverride'); }); - }.property('[email protected]', '[email protected]', 'activeProperties.length'), + this.set('configsWithErrors', configsWithErrors); + }, observeErrors: function() { this.get('configCategories').setEach('errorCount', 0); @@ -98,20 +133,6 @@ App.ServiceConfig = Ember.Object.extend({ }, /** - * Collection of properties that were changed: - * for saved properties use - <code>isNotDefaultValue<code> - * for not saved properties (on wizards, for new services) use - * - <code>isNotInitialValue<code> - * for added properties use - <code>isNotSaved<code> - * @type {Object[]} - */ - changedConfigProperties: function() { - return this.get('activeProperties').filter(function(c) { - return c.get('isNotDefaultValue') || c.get('isNotSaved') || c.get('isNotInitialValue'); - }, this); - }.property('[email protected]', '[email protected]', '[email protected]'), - - /** * Config with overrides that has values that differs from saved * * @type {Object[]} http://git-wip-us.apache.org/repos/asf/ambari/blob/79de029b/ambari-web/app/utils/helper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js index 18cdedc..927f8a6 100644 --- a/ambari-web/app/utils/helper.js +++ b/ambari-web/app/utils/helper.js @@ -767,6 +767,7 @@ App.popover = function (self, options) { self.on("remove", function () { $(this).trigger('mouseleave').off().removeData('bs.popover'); }); + self = null; }; /** @@ -787,6 +788,7 @@ App.tooltip = function (self, options) { self.on("remove", function () { $(this).trigger('mouseleave').off().removeData('bs.tooltip'); }); + self = null }; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/79de029b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js index 96f89f4..86e126e 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js @@ -56,11 +56,20 @@ describe('App.KerberosWizardStep4Controller', function() { }); describe('#isSubmitDisabled', function() { - var controller = App.KerberosWizardStep4Controller.create({}); - var configs = Em.A([ - App.ServiceConfigProperty.create({ name: 'prop1', value: 'someVal1', identityType: 'user', category: 'Ambari Principals', serviceName: 'Cluster'}) - ]); - controller.set('stepConfigs', controller.createServiceConfig(configs)); + var controller, configs; + beforeEach(function() { + controller = App.KerberosWizardStep4Controller.create({}); + configs = Em.A([ + App.ServiceConfigProperty.create({ + name: 'prop1', + value: 'someVal1', + identityType: 'user', + category: 'Ambari Principals', + serviceName: 'Cluster' + }) + ]); + controller.set('stepConfigs', controller.createServiceConfig(configs)); + }); it('configuration errors are absent, submit should be not disabled', function() { expect(controller.get('stepConfigs')[0].get('errorCount')).to.be.equal(0); @@ -70,6 +79,8 @@ describe('App.KerberosWizardStep4Controller', function() { it('config has invalid value, submit should be disabled', function() { var serviceConfig = controller.get('stepConfigs')[0]; serviceConfig.get('configs').findProperty('name', 'prop1').set('value', ''); + serviceConfig.setActivePropertiesOnce(); + serviceConfig.setConfigsWithErrorsOnce(); expect(serviceConfig.get('errorCount')).to.be.equal(1); expect(controller.get('isSubmitDisabled')).to.be.true; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/79de029b/ambari-web/test/models/configs/objects/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_test.js b/ambari-web/test/models/configs/objects/service_config_test.js index 9251afb..ad3dbfe 100644 --- a/ambari-web/test/models/configs/objects/service_config_test.js +++ b/ambari-web/test/models/configs/objects/service_config_test.js @@ -99,13 +99,16 @@ describe('App.ServiceConfig', function () { describe('#activeProperties', function() { it('returns collection of properties that should be shown', function() { + serviceConfig.setActivePropertiesOnce(); expect(serviceConfig.get('activeProperties').mapProperty('name')).to.be.eql(['p1','p4','p5','p7']); }); }); describe('#configsWithErrors', function() { it('returns collection of properties with errors', function() { - expect(serviceConfig.get('configsWithErrors').mapProperty('name')).to.be.eql(['p4', 'p5', 'p7']); + serviceConfig.set('activeProperties', configs); + serviceConfig.setConfigsWithErrorsOnce(); + expect(serviceConfig.get('configsWithErrors').mapProperty('name')).to.be.eql(['p4', 'p5', 'p6', 'p7']); }); });
