You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/08/13 18:57:07 UTC
ambari git commit: AMBARI-12760 FE: Add experimental flag to show
"page loaded in X seconds" on important pages. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk d1adaa293 -> fd7bcd4e5
AMBARI-12760 FE: Add experimental flag to show "page loaded in X seconds" on important pages. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fd7bcd4e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fd7bcd4e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fd7bcd4e
Branch: refs/heads/trunk
Commit: fd7bcd4e5c1888cda7b832c1985a8b2ba4f4320e
Parents: d1adaa2
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Thu Aug 13 19:55:37 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Thu Aug 13 19:55:37 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
ambari-web/app/config.js | 3 +-
.../controllers/main/service/info/configs.js | 2 +
ambari-web/app/initialize.js | 1 +
.../mixins/common/table_server_view_mixin.js | 1 +
ambari-web/app/routes/main.js | 7 ++
ambari-web/app/styles/application.less | 6 ++
ambari-web/app/templates/main/alerts.hbs | 1 +
.../app/templates/main/charts/heatmap.hbs | 4 +-
ambari-web/app/utils/load_timer.js | 67 ++++++++++++++++++++
.../views/common/widget/heatmap_widget_view.js | 4 +-
.../views/main/dashboard/config_history_view.js | 1 +
ambari-web/app/views/main/dashboard/widgets.js | 1 +
ambari-web/app/views/main/host.js | 1 +
.../app/views/main/service/info/summary.js | 1 +
ambari-web/test/utils/load_timer_test.js | 52 +++++++++++++++
.../main/dashboard/config_history_view_test.js | 1 +
17 files changed, 151 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 90abbb0..56f9444 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -167,6 +167,7 @@ var files = ['test/init_model_test',
'test/utils/configs/config_property_helper_test',
'test/utils/configs/modification_handlers/modification_handler_test',
'test/utils/configs/modification_handlers/misc_test',
+ 'test/utils/load_timer_test',
'test/views/common/chart/linear_time_test',
'test/views/common/configs/widgets/combo_config_widget_view_test',
'test/views/common/configs/widgets/config_widget_view_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index 4cdb6db..3216b11 100644
--- a/ambari-web/app/config.js
+++ b/ambari-web/app/config.js
@@ -72,7 +72,8 @@ App.supports = {
installGanglia: false,
opsDuringRollingUpgrade: false,
customizedWidgetLayout: false,
- enhancedConfigs: true
+ enhancedConfigs: true,
+ showPageLoadTime: false
};
if (App.enableExperimental) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 9e1ab0d..c1f5305 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -550,6 +550,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
this.get('configGroups').forEach(function (configGroup) {
this.getRecommendationsForDependencies(null, true, Em.K, configGroup);
}, this);
+ App.loadTimer.finish('Service Configs Page');
},
/**
@@ -801,6 +802,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
* @method selectConfigGroup
*/
doSelectConfigGroup: function (event) {
+ App.loadTimer.start('Service Configs Page');
var configGroupVersions = App.ServiceConfigVersion.find().filterProperty('groupId', event.context.get('configGroupId'));
//check whether config group has config versions
if (event.context.get('configGroupId') == -1) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/initialize.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/initialize.js b/ambari-web/app/initialize.js
index a53e6af..89d2967 100644
--- a/ambari-web/app/initialize.js
+++ b/ambari-web/app/initialize.js
@@ -37,6 +37,7 @@ require('utils/ajax/ajax');
require('utils/ajax/ajax_queue');
require('utils/updater');
require('utils/action_sequence');
+require('utils/load_timer');
require('mappers');
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/mixins/common/table_server_view_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_view_mixin.js b/ambari-web/app/mixins/common/table_server_view_mixin.js
index 3716d42..339f28a 100644
--- a/ambari-web/app/mixins/common/table_server_view_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_view_mixin.js
@@ -123,6 +123,7 @@ App.TableServerViewMixin = Em.Mixin.create({
clearTimeout(this.get('timeOut'));
this.set('filteringComplete', true);
this.propertyDidChange('pageContent');
+ App.loadTimer.finish('Hosts Page');
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index de2f0a9..44bb055 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -120,6 +120,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
widgets: Em.Route.extend({
route: '/metrics',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Dashboard Metrics Page');
router.set('mainDashboardController.selectedCategory', 'widgets');
router.get('mainDashboardController').connectOutlet('mainDashboardWidgets');
}
@@ -127,6 +128,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
charts: Em.Route.extend({
route: '/charts',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Heatmaps Page');
router.set('mainDashboardController.selectedCategory', 'charts');
router.get('mainDashboardController').connectOutlet('mainCharts');
},
@@ -162,6 +164,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
configHistory: Em.Route.extend({
route: '/config_history',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Config History Page');
router.set('mainDashboardController.selectedCategory', 'configHistory');
router.get('mainDashboardController').connectOutlet('mainConfigHistory');
}
@@ -181,6 +184,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
index: Ember.Route.extend({
route: '/',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Hosts Page');
router.get('mainController').connectOutlet('mainHost');
}
}),
@@ -605,6 +609,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
summary: Em.Route.extend({
route: '/summary',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Service Summary Page');
var item = router.get('mainServiceItemController.content');
if (router.get('clusterController.isServiceMetricsLoaded')) router.get('updateController').updateServiceMetric(Em.K);
//if service is not existed then route to default service
@@ -625,6 +630,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
configs: Em.Route.extend({
route: '/configs',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Service Configs Page');
router.get('mainController').dataLoading().done(function () {
var item = router.get('mainServiceItemController.content');
//if service is not existed then route to default service
@@ -661,6 +667,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
heatmaps: Em.Route.extend({
route: '/heatmaps',
connectOutlets: function (router, context) {
+ App.loadTimer.start('Service Heatmaps Page');
router.get('mainController').dataLoading().done(function () {
var item = router.get('mainServiceItemController.content');
if (item.get('isLoaded')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 18ce87d..a0bc3d6 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -5862,6 +5862,12 @@ input[type="radio"].align-checkbox, input[type="checkbox"].align-checkbox {
margin-left: -10px;
}
+.attach-to-bottom-right {
+ position: fixed;
+ bottom: 10px;
+ right: 10px;
+}
+
.version-labels, .version-info-bar, .version-box {
.label, .badge {
font-weight: normal;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/templates/main/alerts.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts.hbs b/ambari-web/app/templates/main/alerts.hbs
index 33bc908..a5b168b 100644
--- a/ambari-web/app/templates/main/alerts.hbs
+++ b/ambari-web/app/templates/main/alerts.hbs
@@ -107,6 +107,7 @@
<td colspan="2">
<div class="spinner"></div>
</td>
+ <td colspan="2"></td>
</tr>
{{/if}}
</tbody>
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/templates/main/charts/heatmap.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/charts/heatmap.hbs b/ambari-web/app/templates/main/charts/heatmap.hbs
index a8143fb..c94a0a2 100644
--- a/ambari-web/app/templates/main/charts/heatmap.hbs
+++ b/ambari-web/app/templates/main/charts/heatmap.hbs
@@ -46,10 +46,12 @@
<div class="active-widget" {{bindAttr id="activeWidget.id"}}>
{{view activeWidget.viewClass contentBinding="activeWidget" racksBinding = "racks" idBinding="activeWidget.id"}}
</div>
+ {{else}}
+ <div class="spinner"></div>
{{/if}}
</div>
</div>
{{else}}
<div class="spinner"></div>
{{/if}}
-</div>
\ No newline at end of file
+</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/utils/load_timer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/load_timer.js b/ambari-web/app/utils/load_timer.js
new file mode 100644
index 0000000..8cfa5cb
--- /dev/null
+++ b/ambari-web/app/utils/load_timer.js
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+App.loadTimer = Em.Object.create({
+
+ timeStampCache: {},
+
+ /**
+ * save start timestamp
+ * @param {string} label
+ */
+ start: function(label) {
+ $('.alert.attach-to-bottom-right').remove();
+ if (App.get('supports.showPageLoadTime')) {
+ this.get('timeStampCache')[label] = window.performance.now();
+ }
+ },
+
+ /**
+ * calculate time difference
+ * @param {string} label
+ * @returns {undefined|string}
+ */
+ finish: function(label) {
+ var result;
+
+ if (typeof(this.get('timeStampCache')[label]) === "number") {
+ result = Number(window.performance.now() - this.get('timeStampCache')[label]).toFixed(2);
+ console.debug(label + " loaded in: " + result + "ms");
+ this.display(label + " loaded in: " + result + "ms");
+ delete this.get('timeStampCache')[label];
+ }
+ return result;
+ },
+
+ /**
+ * display time results on the screen
+ * @param {string} result
+ */
+ display: function(result) {
+ var alert = $("<div class='alert attach-to-bottom-right'>" + result + "</div>");
+ var closeButton = $("<i class='icon-remove-circle'></i>").click(function () {
+ $(this).remove();
+ $(alert).remove();
+ });
+ alert.append(" ", closeButton);
+ $('body').append(alert);
+ }
+});
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/views/common/widget/heatmap_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/widget/heatmap_widget_view.js b/ambari-web/app/views/common/widget/heatmap_widget_view.js
index 4c888e5..62c6cd2 100644
--- a/ambari-web/app/views/common/widget/heatmap_widget_view.js
+++ b/ambari-web/app/views/common/widget/heatmap_widget_view.js
@@ -62,6 +62,8 @@ App.HeatmapWidgetView = Em.View.extend(App.WidgetMixin, {
});
this.set('controller.selectedMetric', metricObject);
+ App.loadTimer.finish('Heatmaps Page');
+ App.loadTimer.finish('Service Heatmaps Page');
}
},
@@ -116,4 +118,4 @@ App.HeatmapWidgetView = Em.View.extend(App.WidgetMixin, {
return hostToValueMap;
}
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/views/main/dashboard/config_history_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/config_history_view.js b/ambari-web/app/views/main/dashboard/config_history_view.js
index 6bd37b1..7cc95a3 100644
--- a/ambari-web/app/views/main/dashboard/config_history_view.js
+++ b/ambari-web/app/views/main/dashboard/config_history_view.js
@@ -197,6 +197,7 @@ App.MainConfigHistoryView = App.TableView.extend(App.TableServerViewMixin, {
this.set('filteringComplete', true);
this.propertyDidChange('pageContent');
this.set('controller.resetStartIndex', false);
+ App.loadTimer.finish('Config History Page');
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index 79cf392..c3a9941 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -30,6 +30,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, {
this.setInitPrefObject();
this.setOnLoadVisibleWidgets();
this.set('isDataLoaded', true);
+ App.loadTimer.finish('Dashboard Metrics Page');
Em.run.next(this, 'makeSortable');
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/views/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host.js b/ambari-web/app/views/main/host.js
index dc6e904..db857cd 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -81,6 +81,7 @@ App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
* called when trigger property(<code>refreshTriggers</code>) is changed
*/
refresh: function () {
+ App.loadTimer.start('Hosts Page');
this.set('filteringComplete', false);
var updaterMethodName = this.get('updater.tableUpdaterMap')[this.get('tableName')];
this.get('updater')[updaterMethodName](this.updaterSuccessCb.bind(this), this.updaterErrorCb.bind(this), true);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 62407a0..e6a7e68 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -611,6 +611,7 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, {
$(this).find('.hidden-description').stop().hide().end();
});
}, 1000);
+ App.loadTimer.finish('Service Summary Page');
},
willDestroyElement: function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/test/utils/load_timer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/load_timer_test.js b/ambari-web/test/utils/load_timer_test.js
new file mode 100644
index 0000000..5955fc7
--- /dev/null
+++ b/ambari-web/test/utils/load_timer_test.js
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var misc = require('utils/load_timer');
+
+describe('App.loadTimer', function () {
+
+ window.performance = {
+ now: function() {
+ return 1;
+ }
+ };
+
+ beforeEach(function() {
+ App.set('supports.showPageLoadTime', true);
+ });
+
+ afterEach(function () {
+ App.set('supports.showPageLoadTime', false);
+ App.loadTimer.set('timeStampCache', {});
+ });
+
+ describe("#start()", function() {
+ it("", function() {
+ App.loadTimer.start('test');
+ expect(App.loadTimer.get('timeStampCache')['test']).to.be.an('number');
+ });
+ });
+
+ describe("#finish()", function() {
+ it("", function() {
+ App.loadTimer.start('test');
+ expect(App.loadTimer.finish('test')).to.be.not.empty;
+ expect(App.loadTimer.get('timeStampCache')).to.be.empty;
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/fd7bcd4e/ambari-web/test/views/main/dashboard/config_history_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/config_history_view_test.js b/ambari-web/test/views/main/dashboard/config_history_view_test.js
index c3669de..3372ca5 100644
--- a/ambari-web/test/views/main/dashboard/config_history_view_test.js
+++ b/ambari-web/test/views/main/dashboard/config_history_view_test.js
@@ -18,6 +18,7 @@
var App = require('app');
require('views/main/dashboard/config_history_view');
+require('utils/load_timer');
describe('App.MainConfigHistoryView', function() {
var view = App.MainConfigHistoryView.create({