Repository: ambari Updated Branches: refs/heads/branch-2.2 84e1d84d1 -> 4bf0400b3
AMBARI-16139. Duplicate Dashboard metrics API calls should not be made in parallel. (Andrii Tkach via Jaimin) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4bf0400b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4bf0400b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4bf0400b Branch: refs/heads/branch-2.2 Commit: 4bf0400b33a971389ac8851912fc3cfc5eeab028 Parents: 84e1d84 Author: Jaimin Jetly <jai...@hortonworks.com> Authored: Wed Apr 27 11:56:21 2016 -0700 Committer: Jaimin Jetly <jai...@hortonworks.com> Committed: Wed Apr 27 11:59:09 2016 -0700 ---------------------------------------------------------------------- .../app/controllers/global/update_controller.js | 10 ++-- .../app/views/common/chart/linear_time.js | 9 ++++ .../test/views/common/chart/linear_time_test.js | 53 +++++++++++++++++++- 3 files changed, 67 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4bf0400b/ambari-web/app/controllers/global/update_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js index 8e9ce53..884b71c 100644 --- a/ambari-web/app/controllers/global/update_controller.js +++ b/ambari-web/app/controllers/global/update_controller.js @@ -411,11 +411,13 @@ App.UpdateController = Em.Controller.extend({ var view = Em.View.views[_graph.id]; if (view) { existedGraphs.push(_graph); - //console.log('updated graph', _graph.name); - view.loadData(); - //if graph opened as modal popup update it to - if ($(".modal-graph-line .modal-body #" + _graph.popupId + "-container-popup").length) { + if (!view.get('isRequestRunning')) { + //console.log('updated graph', _graph.name); view.loadData(); + //if graph opened as modal popup update it to + if ($(".modal-graph-line .modal-body #" + _graph.popupId + "-container-popup").length) { + view.loadData(); + } } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4bf0400b/ambari-web/app/views/common/chart/linear_time.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/chart/linear_time.js b/ambari-web/app/views/common/chart/linear_time.js index 2af9cbf..defcad3 100644 --- a/ambari-web/app/views/common/chart/linear_time.js +++ b/ambari-web/app/views/common/chart/linear_time.js @@ -189,6 +189,14 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, { return this.get('_containerSelector') + this.get('popupSuffix'); }.property('_containerSelector', 'popupSuffix'), + /** + * @type {boolean} + */ + isRequestRunning: function() { + var requestsArrayName = this.get('isPopup') ? 'runningPopupRequests' : 'runningRequests'; + return this.get(requestsArrayName).mapProperty('ajaxIndex').contains(this.get('ajaxIndex')); + }.property('runningPopupRequests', 'runningRequests'), + didInsertElement: function () { var self = this; this.setYAxisFormatter(); @@ -344,6 +352,7 @@ App.ChartLinearTimeView = Ember.View.extend(App.ExportMetricsMixin, { })); } }); + if (request) request.ajaxIndex = this.get('ajaxIndex'); this.get(requestsArrayName).push(request); return request; } http://git-wip-us.apache.org/repos/asf/ambari/blob/4bf0400b/ambari-web/test/views/common/chart/linear_time_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/chart/linear_time_test.js b/ambari-web/test/views/common/chart/linear_time_test.js index 4454b83..1e34649 100644 --- a/ambari-web/test/views/common/chart/linear_time_test.js +++ b/ambari-web/test/views/common/chart/linear_time_test.js @@ -20,8 +20,59 @@ var App = require('app'); require('views/common/chart/linear_time'); describe('App.ChartLinearTimeView', function () { + var chartLinearTimeView; - var chartLinearTimeView = App.ChartLinearTimeView.create({}); + beforeEach(function() { + chartLinearTimeView = App.ChartLinearTimeView.create(); + }); + + describe("#isRequestRunning", function () { + + it("isPopup true, running request", function() { + chartLinearTimeView.setProperties({ + isPopup: true, + runningPopupRequests: [{ + ajaxIndex: 'req1' + }], + ajaxIndex: 'req1' + }); + chartLinearTimeView.propertyDidChange('isRequestRunning'); + expect(chartLinearTimeView.get('isRequestRunning')).to.be.true; + }); + + it("isPopup false, running request", function() { + chartLinearTimeView.setProperties({ + isPopup: false, + runningRequests: [{ + ajaxIndex: 'req1' + }], + ajaxIndex: 'req1' + }); + chartLinearTimeView.propertyDidChange('isRequestRunning'); + expect(chartLinearTimeView.get('isRequestRunning')).to.be.true; + }); + + it("isPopup false, no running request", function() { + chartLinearTimeView.setProperties({ + isPopup: false, + runningRequests: [], + ajaxIndex: 'req1' + }); + chartLinearTimeView.propertyDidChange('isRequestRunning'); + expect(chartLinearTimeView.get('isRequestRunning')).to.be.false; + }); + + it("isPopup true, no running request", function() { + chartLinearTimeView.setProperties({ + isPopup: true, + runningPopupRequests: [], + ajaxIndex: 'req1' + }); + chartLinearTimeView.propertyDidChange('isRequestRunning'); + expect(chartLinearTimeView.get('isRequestRunning')).to.be.false; + }); + + }); describe('#transformData', function () {