Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 195B0200BC7 for ; Thu, 10 Nov 2016 17:58:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 18198160B1A; Thu, 10 Nov 2016 16:58:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E15C0160B19 for ; Thu, 10 Nov 2016 17:58:31 +0100 (CET) Received: (qmail 50948 invoked by uid 500); 10 Nov 2016 16:58:30 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 50602 invoked by uid 99); 10 Nov 2016 16:58:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Nov 2016 16:58:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E93ABEF79A; Thu, 10 Nov 2016 16:58:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Thu, 10 Nov 2016 16:58:41 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/50] [abbrv] ambari git commit: AMBARI-18819 Ambari tab consuming lots of memory & cpu. (atkach) archived-at: Thu, 10 Nov 2016 16:58:33 -0000 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-18456 Commit: 79de029b544f0f6aa7439b65c120b62da7053a5d Parents: e158756 Author: Andrii Tkach Authored: Tue Nov 8 13:19:30 2016 +0200 Committer: Andrii Tkach 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 - isNotDefaultValue + * for not saved properties (on wizards, for new services) use + * - isNotInitialValue + * for added properties use - isNotSaved + * @type {Object[]} + */ + changedConfigProperties: [], + + setActiveProperties: function() { + Em.run.once(this, 'setActivePropertiesOnce'); + }.observes('configs.@each.isActive', 'configs.@each.isRequiredByAgent', 'configs.@each.value'), + + setActivePropertiesOnce: function() { + var activeProperties = this.get('configs').filter(function(c) { return c.get('isActive') && (c.get('isRequiredByAgent') || c.get('isRequired')); }); - }.property('configs.@each.isActive', 'configs.@each.isRequiredByAgent'), + this.set('activeProperties', activeProperties); + }, + + setChangedConfigProperties: function() { + Em.run.once(this, 'setChangedConfigPropertiesOnce'); + }.observes('activeProperties.@each.isNotDefaultValue', 'activeProperties.@each.isNotSaved', 'activeProperties.@each.isNotInitialValue'), - 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('activeProperties.@each.isValid', 'activeProperties.@each.isValidOverride', 'activeProperties.length'), + + setConfigsWithErrorsOnce: function() { + var configsWithErrors = this.get('activeProperties').filter(function(c) { return !c.get('isValid') || !c.get('isValidOverride'); }); - }.property('activeProperties.@each.isValid', 'activeProperties.@each.isValidOverride', '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 - isNotDefaultValue - * for not saved properties (on wizards, for new services) use - * - isNotInitialValue - * for added properties use - isNotSaved - * @type {Object[]} - */ - changedConfigProperties: function() { - return this.get('activeProperties').filter(function(c) { - return c.get('isNotDefaultValue') || c.get('isNotSaved') || c.get('isNotInitialValue'); - }, this); - }.property('activeProperties.@each.isNotDefaultValue', 'activeProperties.@each.isNotSaved', 'activeProperties.@each.isNotInitialValue'), - - /** * 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']); }); });