Repository: ambari Updated Branches: refs/heads/branch-2.2 28214b2da -> 9790191a7
AMBARI-15027 Sometimes Yarn graphs,Heatmaps take longer to load. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9790191a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9790191a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9790191a Branch: refs/heads/branch-2.2 Commit: 9790191a7624d315187c2606453556181223cc0e Parents: 28214b2 Author: Andrii Tkach <atk...@hortonworks.com> Authored: Fri Feb 12 14:52:24 2016 +0200 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Fri Feb 12 22:41:43 2016 +0200 ---------------------------------------------------------------------- .../app/mixins/common/widgets/widget_mixin.js | 29 ++++++++++++-------- .../views/common/widget/graph_widget_view.js | 18 +++++++----- .../test/mixins/common/widget_mixin_test.js | 2 +- 3 files changed, 30 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9790191a/ambari-web/app/mixins/common/widgets/widget_mixin.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js index 6a2d287..eb2cf19 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -206,7 +206,9 @@ App.WidgetMixin = Ember.Mixin.create({ }, /** - * aggregate all metric names in the query. Add time range and step to temporal queries + * aggregate all metric names in the query. Add time range and step to temporal queries + * @param {Array} metricPaths + * @returns {string} */ prepareMetricPaths: function(metricPaths) { var temporalMetrics = metricPaths.filterProperty('metric_type', 'TEMPORAL'); @@ -227,15 +229,20 @@ App.WidgetMixin = Ember.Mixin.create({ * @returns {$.ajax} */ getHostComponentMetrics: function (request) { - return App.ajax.send({ - name: 'widgets.hostComponent.metrics.get', - sender: this, - data: { - componentName: request.component_name, - metricPaths: this.prepareMetricPaths(request.metric_paths), - hostComponentCriteria: this.computeHostComponentCriteria(request) - } - }); + var metricPaths = this.prepareMetricPaths(request.metric_paths); + + if (metricPaths.length) { + return App.ajax.send({ + name: 'widgets.hostComponent.metrics.get', + sender: this, + data: { + componentName: request.component_name, + metricPaths: this.prepareMetricPaths(request.metric_paths), + hostComponentCriteria: this.computeHostComponentCriteria(request) + } + }); + } + return jQuery.Deferred().reject().promise(); }, getHostComponentMetricsSuccessCallback: function (data) { @@ -775,7 +782,7 @@ App.WidgetLoadAggregator = Em.Object.create({ subRequest.errorCallback.call(subRequest.context, xhr, textStatus, errorThrown); } }, this); - }).complete(function () { + }).always(function () { _request.subRequests.forEach(function (subRequest) { subRequest.completeCallback.call(subRequest.context); }, this); http://git-wip-us.apache.org/repos/asf/ambari/blob/9790191a/ambari-web/app/views/common/widget/graph_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/widget/graph_widget_view.js b/ambari-web/app/views/common/widget/graph_widget_view.js index 5887e58..2ab2706 100644 --- a/ambari-web/app/views/common/widget/graph_widget_view.js +++ b/ambari-web/app/views/common/widget/graph_widget_view.js @@ -213,13 +213,17 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, App.ExportMetricsMixin, { step = this.get('timeStep'), timeRange = this.get('timeRange'), result = [], - targetView = this.get('exportTargetView.isPopup') ? this.get('exportTargetView') : this.get('parentView'), - customStartTime = targetView.get('customStartTime'), - customEndTime = targetView.get('customEndTime'); - if (timeRange === 0 && !Em.isNone(customStartTime) && !Em.isNone(customEndTime)) { - // Custom start and end time is specified by user - toSeconds = customEndTime / 1000; - fromSeconds = customStartTime / 1000; + targetView = this.get('exportTargetView.isPopup') ? this.get('exportTargetView') : this.get('parentView'); + + //if view destroyed then no metrics should be asked + if (Em.isNone(targetView)) return result; + + if (timeRange === 0 && + !Em.isNone(targetView.get('customStartTime')) && + !Em.isNone(targetView.get('customEndTime'))) { + // Custom start/end time is specified by user + toSeconds = targetView.get('customEndTime') / 1000; + fromSeconds = targetView.get('customStartTime') / 1000; } else { // Preset time range is specified by user toSeconds = Math.round(App.dateTime() / 1000); http://git-wip-us.apache.org/repos/asf/ambari/blob/9790191a/ambari-web/test/mixins/common/widget_mixin_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js index 73146c4..e458840 100644 --- a/ambari-web/test/mixins/common/widget_mixin_test.js +++ b/ambari-web/test/mixins/common/widget_mixin_test.js @@ -608,7 +608,7 @@ describe('App.WidgetLoadAggregator', function () { return { done: Em.K, fail: Em.K, - complete: Em.K + always: Em.K } } };