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/ed55354a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ed55354a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ed55354a Branch: refs/heads/branch-dev-patch-upgrade Commit: ed55354abaa8bf53ad0c1fda0d935976baf4c53d Parents: aac5389 Author: Andrii Tkach <atk...@hortonworks.com> Authored: Fri Feb 12 16:11:18 2016 +0200 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Fri Feb 12 22:38:32 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/ed55354a/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 b6fe353..6d65c33 100644 --- a/ambari-web/app/mixins/common/widgets/widget_mixin.js +++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js @@ -204,7 +204,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'); @@ -225,15 +227,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) { @@ -771,7 +778,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/ed55354a/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 6feaa28..30eb658 100644 --- a/ambari-web/app/views/common/widget/graph_widget_view.js +++ b/ambari-web/app/views/common/widget/graph_widget_view.js @@ -211,13 +211,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/ed55354a/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 91f628f..e32026a 100644 --- a/ambari-web/test/mixins/common/widget_mixin_test.js +++ b/ambari-web/test/mixins/common/widget_mixin_test.js @@ -626,7 +626,7 @@ describe('App.WidgetLoadAggregator', function () { return { done: Em.K, fail: Em.K, - complete: Em.K + always: Em.K } }, state: 'inDOM'