Repository: ambari
Updated Branches:
  refs/heads/trunk 0b02517ad -> 1c29f1df0


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/1c29f1df
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1c29f1df
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1c29f1df

Branch: refs/heads/trunk
Commit: 1c29f1df06db04e744b6a3342f341977442472ae
Parents: 0b02517
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:56:21 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/1c29f1df/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 c8bea6b..77341b1 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -422,11 +422,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/1c29f1df/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 821e004..80a30d5 100644
--- a/ambari-web/app/views/common/chart/linear_time.js
+++ b/ambari-web/app/views/common/chart/linear_time.js
@@ -185,6 +185,14 @@ App.ChartLinearTimeView = 
Ember.View.extend(App.ExportMetricsMixin, {
 
   _popupSelector: Em.computed.concat('', '_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/1c29f1df/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 00047bc..3aa425c 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -21,8 +21,59 @@ require('views/common/chart/linear_time');
 var testHelpers = require('test/helpers');
 
 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 () {
 

Reply via email to