Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 11074118AA for ; Wed, 20 Aug 2014 15:30:04 +0000 (UTC) Received: (qmail 70944 invoked by uid 500); 20 Aug 2014 15:30:03 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 70848 invoked by uid 500); 20 Aug 2014 15:30:03 -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 70452 invoked by uid 99); 20 Aug 2014 15:30:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2014 15:30:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 336EA954808; Wed, 20 Aug 2014 15:30:03 +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: Wed, 20 Aug 2014 15:30:18 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [17/50] [abbrv] git commit: AMBARI-6912. Browser uses a lot of processor and memory with opened all background operations. (akovalenko) AMBARI-6912. Browser uses a lot of processor and memory with opened all background operations. (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/26c1edca Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/26c1edca Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/26c1edca Branch: refs/heads/branch-alerts-dev Commit: 26c1edca8565a4db3fbd9a68d2622dff874a9dda Parents: 6cfdd1c Author: Aleksandr Kovalenko Authored: Tue Aug 19 15:30:56 2014 +0300 Committer: Aleksandr Kovalenko Committed: Tue Aug 19 15:33:24 2014 +0300 ---------------------------------------------------------------------- .../global/background_operations_controller.js | 2 +- .../templates/common/host_progress_popup.hbs | 2 +- ambari-web/app/utils/host_progress_popup.js | 131 +++++++++++++------ 3 files changed, 96 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/26c1edca/ambari-web/app/controllers/global/background_operations_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js index f6cb80b..e6461d6 100644 --- a/ambari-web/app/controllers/global/background_operations_controller.js +++ b/ambari-web/app/controllers/global/background_operations_controller.js @@ -230,7 +230,7 @@ App.BackgroundOperationsController = Em.Controller.extend({ }); this.get("services").unshift(rq); //To sort DESC by request id - this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); })) ; + this.set("services", this.get("services").sort( function(a,b) { return b.get('id') - a.get('id'); })); } runningServices += ~~isRunning; }, this); http://git-wip-us.apache.org/repos/asf/ambari/blob/26c1edca/ambari-web/app/templates/common/host_progress_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/host_progress_popup.hbs b/ambari-web/app/templates/common/host_progress_popup.hbs index d598ec7..d60dd30 100644 --- a/ambari-web/app/templates/common/host_progress_popup.hbs +++ b/ambari-web/app/templates/common/host_progress_popup.hbs @@ -57,7 +57,7 @@
{{servicesInfo.startTime}}
{{servicesInfo.duration}}
-
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/26c1edca/ambari-web/app/utils/host_progress_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js index 1d3b184..4d27132 100644 --- a/ambari-web/app/utils/host_progress_popup.js +++ b/ambari-web/app/utils/host_progress_popup.js @@ -27,7 +27,7 @@ App.HostPopup = Em.Object.create({ name: 'hostPopup', - servicesInfo: null, + servicesInfo: [], hosts: null, inputData: null, @@ -174,7 +174,7 @@ App.HostPopup = Em.Object.create({ * clear info popup data */ clearHostPopup: function () { - this.set('servicesInfo', null); + this.set('servicesInfo', []); this.set('hosts', null); this.set('inputData', null); this.set('serviceName', ""); @@ -321,6 +321,15 @@ App.HostPopup = Em.Object.create({ } }, + // map to get css class with styles by service status + statusesStyleMap: { + 'FAILED': ['FAILED', 'icon-exclamation-sign', 'progress-danger', false], + 'ABORTED': ['ABORTED', 'icon-minus', 'progress-warning', false], + 'TIMEDOUT': ['TIMEDOUT', 'icon-time', 'progress-warning', false], + 'IN_PROGRESS': ['IN_PROGRESS', 'icon-cogs', 'progress-info', true], + 'COMPLETED': ['SUCCESS', 'icon-ok', 'progress-success', false] + }, + /** * Create services obj data structure for popup * Set data for services @@ -328,56 +337,105 @@ App.HostPopup = Em.Object.create({ */ onServiceUpdate: function (isServiceListHidden) { if (this.get('isBackgroundOperations') && this.get("inputData")) { - var self = this; - var allNewServices = []; - var statuses = { - 'FAILED': ['FAILED', 'icon-exclamation-sign', 'progress-danger', false], - 'ABORTED': ['ABORTED', 'icon-minus', 'progress-warning', false], - 'TIMEDOUT': ['TIMEDOUT', 'icon-time', 'progress-warning', false], - 'IN_PROGRESS': ['IN_PROGRESS', 'icon-cogs', 'progress-info', true], - 'COMPLETED': ['SUCCESS', 'icon-ok', 'progress-success', false] - }; - var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true]; - this.set("servicesInfo", null); - this.get("inputData").forEach(function (service) { - var status = statuses[service.status] || pendingStatus; + var statuses = this.get('statusesStyleMap'); + var servicesInfo = this.get("servicesInfo"); + var currentServices = []; + this.get("inputData").forEach(function (service, index) { + var updatedService; var id = service.id; - var newService = Ember.Object.create({ - id: id, - displayName: service.displayName, - progress: service.progress, - status: App.format.taskStatus(status[0]), - isRunning: service.isRunning, - name: service.name, - isVisible: true, - startTime: date.startTime(service.startTime), - duration: date.durationSummary(service.startTime, service.endTime), - icon: status[1], - barColor: status[2], - isInProgress: status[3], - barWidth: "width:" + service.progress + "%;", - sourceRequestScheduleId: service.get('sourceRequestScheduleId'), - contextCommand: service.get('contextCommand') - }); + currentServices.push(id); + var existedService = servicesInfo.findProperty('id', id); + updatedService = existedService; + if (existedService) { + updatedService = this.updateService(existedService, service); + } else { + updatedService = this.createService(service); + servicesInfo.insertAt(index, updatedService); + } if (App.get('supports.abortRequests')) { var abortable = !Em.keys(statuses).contains(service.status) || service.status == 'IN_PROGRESS'; if (!abortable) { var abortedRequests = this.get('abortedRequests'); this.set('abortedRequests', abortedRequests.without(id)); } - newService.setProperties({ + updatedService.setProperties({ abortable: abortable, abortClassName: 'abort' + id }); } - allNewServices.push(newService); }, this); - self.set('servicesInfo', allNewServices); + this.removeOldServices(servicesInfo, currentServices); this.setBackgroundOperationHeader(isServiceListHidden); } }, /** + * Create service object from transmitted data + * @param service + */ + createService: function (service) { + var statuses = this.get('statusesStyleMap'); + var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true]; + var status = statuses[service.status] || pendingStatus; + return Ember.Object.create({ + id: service.id, + displayName: service.displayName, + progress: service.progress, + status: App.format.taskStatus(status[0]), + isRunning: service.isRunning, + name: service.name, + isVisible: true, + startTime: date.startTime(service.startTime), + duration: date.durationSummary(service.startTime, service.endTime), + icon: status[1], + barColor: status[2], + isInProgress: status[3], + barWidth: "width:" + service.progress + "%;", + sourceRequestScheduleId: service.get('sourceRequestScheduleId'), + contextCommand: service.get('contextCommand') + }); + }, + + /** + * Update properties of existed service with new data + * @param service + * @param newData + * @returns {Ember.Object} + */ + updateService: function (service, newData) { + var statuses = this.get('statusesStyleMap'); + var pendingStatus = ['PENDING', 'icon-cog', 'progress-info', true]; + var status = statuses[newData.status] || pendingStatus; + return service.setProperties({ + progress: newData.progress, + status: App.format.taskStatus(status[0]), + isRunning: newData.isRunning, + startTime: date.startTime(newData.startTime), + duration: date.durationSummary(newData.startTime, newData.endTime), + icon: status[1], + barColor: status[2], + isInProgress: status[3], + barWidth: "width:" + newData.progress + "%;", + sourceRequestScheduleId: newData.get('sourceRequestScheduleId'), + contextCommand: newData.get('contextCommand') + }); + }, + + /** + * remove old requests + * as API returns 10, or 20 , or 30 ...etc latest request, the requests that absent in response should be removed + * @param services + * @param currentServicesIds + */ + removeOldServices: function (services, currentServicesIds) { + services.forEach(function (service, index, services) { + if (!currentServicesIds.contains(service.id)) { + services.removeAt(index, 1); + } + }); + }, + + /** * create task Ember object * @param {Object} _task * @return {Em.Object} @@ -546,7 +604,7 @@ App.HostPopup = Em.Object.create({ } } if (App.get('supports.abortRequests')) { - var operation = this.get('servicesInfo') && this.get('servicesInfo').findProperty('name', this.get('serviceName')); + var operation = this.get('servicesInfo').findProperty('name', this.get('serviceName')); if (!operation || (operation && operation.get('progress') == 100)) { this.set('operationInfo', null); } else { @@ -561,7 +619,6 @@ App.HostPopup = Em.Object.create({ */ createPopup: function () { var self = this; - var hostsInfo = this.get("hosts"); var servicesInfo = this.get("servicesInfo"); var isBackgroundOperations = this.get('isBackgroundOperations'); var categoryObject = Em.Object.extend({