This is an automated email from the ASF dual-hosted git repository.
atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new c7a83ae AMBARI-23542 UI Performance Tuning
c7a83ae is described below
commit c7a83ae3ffbe8d7d573639fae0d6f3f6be3dea65
Author: Andrii Tkach <[email protected]>
AuthorDate: Wed Apr 11 16:31:33 2018 +0300
AMBARI-23542 UI Performance Tuning
---
.../app/controllers/global/cluster_controller.js | 4 --
.../main/admin/highAvailability_controller.js | 4 +-
.../main/dashboard/config_history_controller.js | 15 +++--
ambari-web/app/controllers/main/host.js | 50 +--------------
.../app/mixins/main/service/themes_mapping.js | 24 ++++---
ambari-web/app/routes/reassign_master_routes.js | 2 +-
.../templates/main/dashboard/config_history.hbs | 4 +-
ambari-web/app/utils/ajax/ajax.js | 13 ----
ambari-web/app/utils/config.js | 75 +++++++++++++---------
.../views/main/dashboard/config_history_view.js | 7 +-
ambari-web/app/views/main/host.js | 5 --
.../views/main/host/details/host_component_view.js | 2 +-
.../main/admin/highAvailability_controller_test.js | 10 +--
.../dashboard/config_history_controller_test.js | 4 +-
ambari-web/test/controllers/main/host_test.js | 45 -------------
.../main/host/details/host_component_view_test.js | 9 ++-
ambari-web/test/views/main/host_test.js | 19 ------
17 files changed, 91 insertions(+), 201 deletions(-)
diff --git a/ambari-web/app/controllers/global/cluster_controller.js
b/ambari-web/app/controllers/global/cluster_controller.js
index 349a73c..20b0e8a 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -177,10 +177,6 @@ App.ClusterController =
Em.Controller.extend(App.ReloadPopupMixin, {
App.router.get('userSettingsController').getAllUserSettings();
App.router.get('errorsHandlerController').loadErrorLogs();
- var hostsController = App.router.get('mainHostController');
- hostsController.set('isCountersUpdating', true);
- hostsController.updateStatusCounters();
-
this.loadClusterInfo();
this.restoreUpgradeState();
App.router.get('wizardWatcherController').getUser();
diff --git
a/ambari-web/app/controllers/main/admin/highAvailability_controller.js
b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
index e9a86df..5a18e57 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
@@ -43,7 +43,7 @@ App.MainAdminHighAvailabilityController =
App.WizardController.extend({
message.push(Em.I18n.t('admin.highAvailability.error.maintenanceMode'));
}
- if (App.router.get('mainHostController.hostsCountMap.TOTAL') < 3) {
+ if (App.get('allHostNames.length') < 3) {
message.push(Em.I18n.t('admin.highAvailability.error.hostsNum'));
}
if (message.length > 0) {
@@ -69,7 +69,7 @@ App.MainAdminHighAvailabilityController =
App.WizardController.extend({
message.push(Em.I18n.t('admin.rm_highAvailability.error.zooKeeperNum'));
}
- if (App.router.get('mainHostController.hostsCountMap.TOTAL') < 3) {
+ if (App.get('allHostNames.length') < 3) {
message.push(Em.I18n.t('admin.rm_highAvailability.error.hostsNum'));
}
if (message.length > 0) {
diff --git
a/ambari-web/app/controllers/main/dashboard/config_history_controller.js
b/ambari-web/app/controllers/main/dashboard/config_history_controller.js
index 73c5386..ffef7e4 100644
--- a/ambari-web/app/controllers/main/dashboard/config_history_controller.js
+++ b/ambari-web/app/controllers/main/dashboard/config_history_controller.js
@@ -106,12 +106,15 @@ App.MainConfigHistoryController =
Em.ArrayController.extend(App.TableServerMixin
* - total counter of service config versions(called in parallel)
* - current versions
* - filtered versions
+ * @param {boolean} shouldUpdateCounter
* @return {*}
*/
- load: function () {
- var dfd = $.Deferred();
- this.updateTotalCounter();
- this.loadConfigVersionsToModel().done(function () {
+ load: function (shouldUpdateCounter = false) {
+ const dfd = $.Deferred();
+ this.loadConfigVersionsToModel().done(() => {
+ if (shouldUpdateCounter) {
+ this.updateTotalCounter();
+ }
dfd.resolve();
});
return dfd.promise();
@@ -143,7 +146,7 @@ App.MainConfigHistoryController =
Em.ArrayController.extend(App.TableServerMixin
},
updateTotalCounterSuccess: function (data, opt, params) {
- this.set('totalCount', data.itemTotal);
+ this.set('totalCount', Number(data.itemTotal));
},
getUrl: function (queryParams) {
@@ -160,7 +163,7 @@ App.MainConfigHistoryController =
Em.ArrayController.extend(App.TableServerMixin
},
subscribeToUpdates: function() {
- App.StompClient.addHandler('/events/configs', 'history',
this.load.bind(this));
+ App.StompClient.addHandler('/events/configs', 'history',
this.load.bind(this, true));
},
unsubscribeOfUpdates: function() {
diff --git a/ambari-web/app/controllers/main/host.js
b/ambari-web/app/controllers/main/host.js
index 23daf6a..cac664e 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -30,9 +30,7 @@ App.MainHostController =
Em.ArrayController.extend(App.TableServerMixin, {
* total number of installed hosts
* @type {number}
*/
- totalCount: function () {
- return this.get('hostsCountMap')['TOTAL'] || 0;
- }.property('hostsCountMap'),
+ totalCount: Em.computed.alias('App.allHostNames.length'),
/**
* @type {boolean}
@@ -40,13 +38,6 @@ App.MainHostController =
Em.ArrayController.extend(App.TableServerMixin, {
*/
resetStartIndex: false,
- /**
- * flag responsible for updating status counters of hosts
- */
- isCountersUpdating: false,
-
- hostsCountMap: {},
-
startIndex: 1,
/**
@@ -337,45 +328,6 @@ App.MainHostController =
Em.ArrayController.extend(App.TableServerMixin, {
return queryParams;
},
- /**
- * update status counters of hosts
- */
- updateStatusCounters: function () {
- var self = this;
-
- if (this.get('isCountersUpdating')) {
- App.ajax.send({
- name: 'host.status.total_count',
- sender: this,
- data: {},
- success: 'updateStatusCountersSuccessCallback',
- error: 'updateStatusCountersErrorCallback',
- callback: function() {
- setTimeout(function () {
- self.updateStatusCounters();
- }, App.get('hostStatusCountersUpdateInterval'));
- }
- });
- }
- },
-
- /**
- * success callback on <code>updateStatusCounters()</code>
- * map counters' value to categories
- * @param data
- */
- updateStatusCountersSuccessCallback: function (data) {
- var hostsCountMap = {
- 'TOTAL': data.Clusters.total_hosts
- };
-
- this.set('hostsCountMap', hostsCountMap);
- },
-
- /**
- * success callback on <code>updateStatusCounters()</code>
- */
- updateStatusCountersErrorCallback: Em.K,
/**
* Return value without predicate
diff --git a/ambari-web/app/mixins/main/service/themes_mapping.js
b/ambari-web/app/mixins/main/service/themes_mapping.js
index 2dc2698..d2aee28 100644
--- a/ambari-web/app/mixins/main/service/themes_mapping.js
+++ b/ambari-web/app/mixins/main/service/themes_mapping.js
@@ -32,15 +32,21 @@ App.ThemesMappingMixin = Em.Mixin.create({
* @method loadConfigTheme
*/
loadConfigTheme: function(serviceName) {
- return App.ajax.send({
- name: 'configs.theme',
- sender: this,
- data: {
- serviceName: serviceName,
- stackVersionUrl: App.get('stackVersionURL')
- },
- success: '_saveThemeToModel'
- });
+ const dfd = $.Deferred();
+ if (App.Tab.find().mapProperty('serviceName').contains(serviceName)) {
+ dfd.resolve();
+ } else {
+ App.ajax.send({
+ name: 'configs.theme',
+ sender: this,
+ data: {
+ serviceName: serviceName,
+ stackVersionUrl: App.get('stackVersionURL')
+ },
+ success: '_saveThemeToModel'
+ }).complete(dfd.resolve);
+ }
+ return dfd.promise();
},
/**
diff --git a/ambari-web/app/routes/reassign_master_routes.js
b/ambari-web/app/routes/reassign_master_routes.js
index 374bd53..d7f84ff 100644
--- a/ambari-web/app/routes/reassign_master_routes.js
+++ b/ambari-web/app/routes/reassign_master_routes.js
@@ -39,7 +39,7 @@ module.exports = App.WizardRoute.extend({
var reassignMasterController = router.get('reassignMasterController');
reassignMasterController.dataLoading().done(function () {
- if (App.router.get('mainHostController.hostsCountMap.TOTAL') > 1) {
+ if (App.get('allHostNames.length') > 1) {
Em.run.next(function () {
App.router.get('updateController').set('isWorking', false);
var popup = App.ModalPopup.show({
diff --git a/ambari-web/app/templates/main/dashboard/config_history.hbs
b/ambari-web/app/templates/main/dashboard/config_history.hbs
index 0436f56..120b3d4 100644
--- a/ambari-web/app/templates/main/dashboard/config_history.hbs
+++ b/ambari-web/app/templates/main/dashboard/config_history.hbs
@@ -18,8 +18,8 @@
<div id="config_history" class="container-wrap-table">
<div class="row">
- <h2 class="table-title col-md-2">{{t dashboard.configHistory.title}}</h2>
- <div class="table-controls row col-sm-10 pull-right">
+ <h2 class="table-title col-md-6">{{t dashboard.configHistory.title}}</h2>
+ <div class="table-controls row col-sm-6 pull-right">
<div class="col-sm-12">
<div class="VS-open-box pull-right">
<button class="btn btn-default">
diff --git a/ambari-web/app/utils/ajax/ajax.js
b/ambari-web/app/utils/ajax/ajax.js
index 41c355e..898c3ba 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1518,15 +1518,6 @@ var urls = {
};
}
},
- 'admin.security.add.cluster_configs': {
- 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
- 'mock': '',
- 'format': function () {
- return {
- timeout: 10000
- };
- }
- },
'kerberos.session.state': {
'real':
'/clusters/{clusterName}/services/KERBEROS?fields=Services/attributes/kdc_validation_result,Services/attributes/kdc_validation_failure_details',
@@ -2608,10 +2599,6 @@ var urls = {
};
}
},
- 'host.status.total_count': {
- 'real':
'/clusters/{clusterName}?fields=Clusters/total_hosts&minimal_response=true',
- 'mock': '/data/hosts/HDP2/host_status_counters.json'
- },
'host.stack_versions.install': {
'real': '/clusters/{clusterName}/hosts/{hostName}/stack_versions',
'mock': '',
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 18bbf29..5419bcc 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1320,38 +1320,53 @@ App.config = Em.Object.create({
* @return {*|{then}}
*/
getConfigsByTypes: function (sites) {
- var dfd = $.Deferred();
- App.ajax.send({
- name: 'config.tags.selected',
- sender: this,
- data: {
- tags: sites.mapProperty('site').join(',')
- }
- }).done(function (data) {
-
App.router.get('configurationController').getConfigsByTags(data.items.map(function
(item) {
- return {siteName: item.type, tagName: item.tag};
- })).done(function (configs) {
- var result = [];
- configs.forEach(function(config){
- var configsArray = [];
- var configsObject = config.properties;
- for (var property in configsObject) {
- if (configsObject.hasOwnProperty(property)) {
- configsArray.push(Em.Object.create({
- name: property,
- value: configsObject[property],
- filename: App.config.getOriginalFileName(config.type)
- }));
- }
- }
- result.push(Em.Object.create({
- serviceName: sites.findProperty('site', config.type).serviceName,
- configs: configsArray
- }));
+ const dfd = $.Deferred();
+ if (_.isEqual(sites.mapProperty('site'), ['cluster-env'])) {
+ // if only cluster-env requested the use cached data
+
dfd.resolve(this.getMappedConfigs([App.router.get('clusterController.clusterEnv')],
sites));
+ } else {
+ App.ajax.send({
+ name: 'config.tags.selected',
+ sender: this,
+ data: {
+ tags: sites.mapProperty('site').join(',')
+ }
+ }).done((data) => {
+
App.router.get('configurationController').getConfigsByTags(data.items.map(function
(item) {
+ return {siteName: item.type, tagName: item.tag};
+ })).done((configs) => {
+ dfd.resolve(this.getMappedConfigs(configs, sites));
});
- dfd.resolve(result);
});
- });
+ }
return dfd.promise();
+ },
+
+ /**
+ *
+ * @param configs
+ * @param sites
+ */
+ getMappedConfigs: function (configs, sites) {
+ const result = [];
+ configs.forEach(function (config) {
+ var configsArray = [];
+ var configsObject = config.properties;
+ for (var property in configsObject) {
+ if (configsObject.hasOwnProperty(property)) {
+ configsArray.push(Em.Object.create({
+ name: property,
+ value: configsObject[property],
+ filename: App.config.getOriginalFileName(config.type)
+ }));
+ }
+ }
+ result.push(Em.Object.create({
+ serviceName: sites.findProperty('site', config.type).serviceName,
+ configs: configsArray
+ }));
+ });
+
+ return result;
}
});
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 aa2bbb6..6e6fa7e 100644
--- a/ambari-web/app/views/main/dashboard/config_history_view.js
+++ b/ambari-web/app/views/main/dashboard/config_history_view.js
@@ -59,7 +59,7 @@ App.MainConfigHistoryView =
App.TableView.extend(App.TableServerViewMixin, {
this.addObserver('startIndex', this, 'updatePagination');
this.addObserver('displayLength', this, 'updatePagination');
this.set('isInitialRendering', true);
- this.refresh();
+ this.refresh(true);
this.get('controller').subscribeToUpdates();
},
@@ -116,11 +116,12 @@ App.MainConfigHistoryView =
App.TableView.extend(App.TableServerViewMixin, {
/**
* refresh table content
+ * @param {boolean} shouldUpdateCounter
*/
- refresh: function () {
+ refresh: function (shouldUpdateCounter) {
var self = this;
this.set('filteringComplete', false);
- this.get('controller').load().done(function () {
+ this.get('controller').load(shouldUpdateCounter).done(function () {
self.refreshDone.apply(self);
});
},
diff --git a/ambari-web/app/views/main/host.js
b/ambari-web/app/views/main/host.js
index cf3c847..e6ca992 100644
--- a/ambari-web/app/views/main/host.js
+++ b/ambari-web/app/views/main/host.js
@@ -17,9 +17,7 @@
*/
var App = require('app');
-var filters = require('views/common/filter_view');
var sort = require('views/common/sort_view');
-var date = require('utils/date/date');
App.MainHostView = App.TableView.extend(App.TableServerViewMixin, {
templateName:require('templates/main/host'),
@@ -211,14 +209,11 @@ App.MainHostView =
App.TableView.extend(App.TableServerViewMixin, {
this.addObserver('filteredCount', this, this.updatePaging);
// should show overlay even when filtering has begun before observer was
added
this.overlayObserver();
- this.set('controller.isCountersUpdating', true);
- this.get('controller').updateStatusCounters();
this.combineSelectedFilter();
},
willDestroyElement: function () {
$('.tooltip').remove();
- this.set('controller.isCountersUpdating', false);
},
onInitialLoad: function () {
diff --git a/ambari-web/app/views/main/host/details/host_component_view.js
b/ambari-web/app/views/main/host/details/host_component_view.js
index 45b2b0a..e785259 100644
--- a/ambari-web/app/views/main/host/details/host_component_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_view.js
@@ -245,7 +245,7 @@ App.HostComponentView = Em.View.extend({
* @type {bool}
*/
isReassignable: function () {
- return
App.get('components.reassignable').contains(this.get('content.componentName'))
&& App.router.get('mainHostController.hostsCountMap')['TOTAL'] > 1;
+ return
App.get('components.reassignable').contains(this.get('content.componentName'))
&& App.get('allHostNames.length') > 1;
}.property('content.componentName'),
/**
diff --git
a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
index 08cddaf..eb9535c 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
@@ -43,7 +43,7 @@ describe('App.MainAdminHighAvailabilityController', function
() {
App.router.transitionTo.restore();
controller.showErrorPopup.restore();
App.HostComponent.find.restore();
- App.router.get.restore();
+ App.get.restore();
});
describe('NAMENODE in INSTALLED state', function () {
@@ -66,7 +66,7 @@ describe('App.MainAdminHighAvailabilityController', function
() {
workStatus: 'INSTALLED'
})
];
- sinon.stub(App.router, 'get', function() {
+ sinon.stub(App, 'get', function() {
return 3;
});
this.result = controller.enableHighAvailability();
@@ -91,7 +91,7 @@ describe('App.MainAdminHighAvailabilityController', function
() {
];
beforeEach(function () {
- sinon.stub(App.router, 'get', function(){
+ sinon.stub(App, 'get', function(){
return 3;
});
this.result = controller.enableHighAvailability();
@@ -128,7 +128,7 @@ describe('App.MainAdminHighAvailabilityController',
function () {
];
beforeEach(function () {
- sinon.stub(App.router, 'get', function () {
+ sinon.stub(App, 'get', function () {
return 1;
});
this.result = controller.enableHighAvailability();
@@ -164,7 +164,7 @@ describe('App.MainAdminHighAvailabilityController',
function () {
workStatus: 'INSTALLED'
})
];
- sinon.stub(App.router, 'get', function() {
+ sinon.stub(App, 'get', function() {
return 3;
});
this.result = controller.enableHighAvailability();
diff --git
a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
index b2b0442..24c1bbd 100644
---
a/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
+++
b/ambari-web/test/controllers/main/dashboard/config_history_controller_test.js
@@ -48,8 +48,8 @@ describe('MainConfigHistoryController', function () {
beforeEach(function () {
sinon.stub(controller, 'updateTotalCounter', Em.K);
- sinon.stub(controller, 'loadConfigVersionsToModel').returns({done:
Em.K});
- controller.load();
+ sinon.stub(controller, 'loadConfigVersionsToModel').returns({done:
Em.clb});
+ controller.load(true);
});
afterEach(function () {
diff --git a/ambari-web/test/controllers/main/host_test.js
b/ambari-web/test/controllers/main/host_test.js
index ee1e149..94dfbec 100644
--- a/ambari-web/test/controllers/main/host_test.js
+++ b/ambari-web/test/controllers/main/host_test.js
@@ -35,21 +35,6 @@ describe('MainHostController', function () {
hostController.destroy();
});
- describe("#totalCount()", function () {
-
- it("TOTAL is undefined", function () {
- hostController.set('hostsCountMap', {});
- hostController.propertyDidChange('totalCount');
- expect(hostController.get('totalCount')).to.be.equal(0);
- });
-
- it("TOTAL is 1", function () {
- hostController.set('hostsCountMap', {TOTAL: 1});
- hostController.propertyDidChange('totalCount');
- expect(hostController.get('totalCount')).to.be.equal(1);
- });
- });
-
describe('#getRegExp()', function () {
var message = '`{0}` should convert to `{1}`',
tests = [
@@ -130,36 +115,6 @@ describe('MainHostController', function () {
});
- describe("#updateStatusCounters()", function() {
-
- it("isCountersUpdating is false", function() {
- hostController.set('isCountersUpdating', false);
- hostController.updateStatusCounters();
- expect(testHelpers.findAjaxRequest('name',
'host.status.total_count')).to.be.undefined;
- });
-
- it("isCountersUpdating is true", function() {
- hostController.set('isCountersUpdating', true);
- hostController.updateStatusCounters();
- expect(testHelpers.findAjaxRequest('name',
'host.status.total_count')).to.be.exist;
- });
- });
-
- describe("#updateStatusCountersSuccessCallback()", function() {
- var data = {
- Clusters: {
- total_hosts: 21
- }
- };
-
- it("hostsCountMap should be set", function() {
- hostController.updateStatusCountersSuccessCallback(data);
- expect(hostController.get('hostsCountMap')).to.be.eql({
- "TOTAL": 21
- });
- });
- });
-
describe("#getProperValue()", function() {
var testCases = [
diff --git
a/ambari-web/test/views/main/host/details/host_component_view_test.js
b/ambari-web/test/views/main/host/details/host_component_view_test.js
index 1ac6fe0..fa33de2 100644
--- a/ambari-web/test/views/main/host/details/host_component_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_view_test.js
@@ -375,21 +375,20 @@ describe('App.HostComponentView', function() {
describe("#isReassignable", function() {
beforeEach(function(){
- sinon.stub(App, 'get').returns(['C1']);
- this.mock = sinon.stub(App.router, 'get');
+ this.mock = sinon.stub(App, 'get');
+ this.mock.withArgs('components.reassignable').returns(['C1'])
});
afterEach(function(){
- App.get.restore();
this.mock.restore();
});
it("component reassignable and count is 2", function() {
- this.mock.returns({TOTAL: 2});
+ this.mock.withArgs('allHostNames.length').returns(2);
hostComponentView.set('content.componentName', 'C1');
hostComponentView.propertyDidChange('isReassignable');
expect(hostComponentView.get('isReassignable')).to.be.true;
});
it("component reassignable and count is 1", function() {
- this.mock.returns({TOTAL: 1});
+ this.mock.withArgs('allHostNames.length').returns(1);
hostComponentView.set('content.componentName', 'C1');
hostComponentView.propertyDidChange('isReassignable');
expect(hostComponentView.get('isReassignable')).to.be.false;
diff --git a/ambari-web/test/views/main/host_test.js
b/ambari-web/test/views/main/host_test.js
index 15bdab2..38cb554 100644
--- a/ambari-web/test/views/main/host_test.js
+++ b/ambari-web/test/views/main/host_test.js
@@ -105,25 +105,6 @@ describe('App.MainHostView', function () {
view.didInsertElement();
expect(view.overlayObserver.calledOnce).to.be.true;
});
-
- it('isCountersUpdating should be true', function () {
- view.didInsertElement();
- expect(view.get('controller.isCountersUpdating')).to.be.true;
- });
-
- it('updateStatusCounters should be called', function () {
- view.didInsertElement();
-
expect(view.get('controller').updateStatusCounters.calledOnce).to.be.true;
- });
- });
-
- describe('#willDestroyElement', function() {
-
- it("isCountersUpdating should be false", function() {
- view.set('controller.isCountersUpdating', true);
- view.willDestroyElement();
- expect(view.get('controller.isCountersUpdating')).to.be.false;
- });
});
describe("#onRequestErrorHandler()", function () {
--
To stop receiving notification emails like this one, please contact
[email protected].