You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/08/17 14:03:57 UTC
ambari git commit: AMBARI-12785. App.componentConfigMapper takes too
much time (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 0f693987c -> 63134a7b6
AMBARI-12785. App.componentConfigMapper takes too much time (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/63134a7b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/63134a7b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/63134a7b
Branch: refs/heads/trunk
Commit: 63134a7b6ebfef1ab82cd4a91b837c34bdc8a003
Parents: 0f69398
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Aug 17 14:40:58 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Aug 17 15:03:48 2015 +0300
----------------------------------------------------------------------
.../app/controllers/global/update_controller.js | 2 +-
.../app/mappers/component_config_mapper.js | 6 +--
.../configs/stack_config_properties_mapper.js | 4 +-
ambari-web/app/mappers/server_data_mapper.js | 37 +++++++++++++++
.../test/mappers/server_data_mapper_test.js | 49 ++++++++++++++++++--
5 files changed, 88 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/63134a7b/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 34dcde1..23d9ff2 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -493,7 +493,7 @@ App.UpdateController = Em.Controller.extend({
},
updateComponentConfig: function (callback) {
var testUrl = '/data/services/host_component_stale_configs.json';
- var componentConfigUrl = this.getUrl(testUrl, '/components?ServiceComponentInfo/category.in(SLAVE,CLIENT)&host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/stale_configs,host_components/HostRoles/desired_admin_state&minimal_response=true');
+ var componentConfigUrl = this.getUrl(testUrl, '/components?host_components/HostRoles/stale_configs=true&fields=host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,host_components/HostRoles/host_name,host_components/HostRoles/stale_configs,host_components/HostRoles/desired_admin_state&minimal_response=true');
App.HttpClient.get(componentConfigUrl, App.componentConfigMapper, {
complete: callback
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/63134a7b/ambari-web/app/mappers/component_config_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/component_config_mapper.js b/ambari-web/app/mappers/component_config_mapper.js
index 50b537f..8ff3416 100644
--- a/ambari-web/app/mappers/component_config_mapper.js
+++ b/ambari-web/app/mappers/component_config_mapper.js
@@ -57,13 +57,11 @@ App.componentConfigMapper = App.QuickDataMapper.create({
var currentStaleConfigsState = Boolean(hostComponentJson);
var stateChanged = hostComponent.get('staleConfigs') !== currentStaleConfigsState;
- if (stateChanged && !hostComponent.get('isMaster')) {
+ if (stateChanged) {
hostComponent.set('staleConfigs', currentStaleConfigsState);
}
//delete loaded host-components, so only new ones left
- if (hostComponent.get('service.hostComponents').someProperty('id', id)) {
- delete hostComponentJsonMap[id];
- }
+ delete hostComponentJsonMap[id];
});
hostComponentJsonIds.forEach(function (hcId) {
var newHostComponent = hostComponentJsonMap[hcId];
http://git-wip-us.apache.org/repos/asf/ambari/blob/63134a7b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 3c11fa1..29507df 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -45,7 +45,7 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
},
map: function (json) {
- console.time('stackConfigPropertiesMapper execution time');
+ console.time('App.stackConfigPropertiesMapper execution time');
if (json && json.Versions) {
//hack for cluster versions
json = {items: [json]};
@@ -99,7 +99,7 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
}, this);
App.store.loadMany(this.get('model'), configs);
}
- console.timeEnd('stackConfigPropertiesMapper execution time');
+ console.timeEnd('App.stackConfigPropertiesMapper execution time');
},
/******************* METHODS TO MERGE STACK PROPERTIES WITH STORED ON UI *********************************/
http://git-wip-us.apache.org/repos/asf/ambari/blob/63134a7b/ambari-web/app/mappers/server_data_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/server_data_mapper.js b/ambari-web/app/mappers/server_data_mapper.js
index a87cf78..99fd80f 100644
--- a/ambari-web/app/mappers/server_data_mapper.js
+++ b/ambari-web/app/mappers/server_data_mapper.js
@@ -159,5 +159,42 @@ App.QuickDataMapper = App.ServerDataMapper.extend({
return result;
}
return current;
+ },
+
+ /**
+ * Binary search <code>searchElement</code> in the array (should be sorted!)
+ * @param {number[]|string[]} array
+ * @param {number|string} searchElement
+ * @returns {number} position of the needed element or negative value, if value wasn't found
+ * @method binaryIndexOf
+ */
+ binaryIndexOf: function (array, searchElement) {
+ var minIndex = 0;
+ var maxIndex = array.length - 1;
+ var currentIndex;
+ var currentElement;
+ var resultIndex;
+
+ if (array[0] > searchElement || array[array.length - 1] < searchElement) {
+ return -1;
+ }
+ while (minIndex <= maxIndex) {
+ resultIndex = currentIndex = (minIndex + maxIndex) / 2 | 0;
+ currentElement = array[currentIndex];
+
+ if (currentElement < searchElement) {
+ minIndex = currentIndex + 1;
+ }
+ else
+ if (currentElement > searchElement) {
+ maxIndex = currentIndex - 1;
+ }
+ else {
+ return currentIndex;
+ }
+ }
+
+ return ~maxIndex;
}
+
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/63134a7b/ambari-web/test/mappers/server_data_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/server_data_mapper_test.js b/ambari-web/test/mappers/server_data_mapper_test.js
index da873d5..9c4adbb 100644
--- a/ambari-web/test/mappers/server_data_mapper_test.js
+++ b/ambari-web/test/mappers/server_data_mapper_test.js
@@ -18,6 +18,7 @@
var Ember = require('ember');
var App = require('app');
+var mapper;
require('mappers/server_data_mapper');
@@ -47,6 +48,10 @@ describe('App.QuickDataMapper', function () {
}
};
+ beforeEach(function () {
+ mapper = App.QuickDataMapper.create();
+ });
+
describe('#getJsonProperty', function() {
var tests = [
{i:'a1.b1.c1',e:'val1'},
@@ -57,7 +62,6 @@ describe('App.QuickDataMapper', function () {
];
tests.forEach(function(test) {
it(test.i, function() {
- var mapper = App.QuickDataMapper.create();
expect(mapper.getJsonProperty(test_json, test.i)).to.equal(test.e);
});
});
@@ -75,8 +79,12 @@ describe('App.QuickDataMapper', function () {
item: 'c2'
}
};
- var mapper = App.QuickDataMapper.create();
- var result = mapper.parseIt(test_json, config);
+ var result;
+
+ beforeEach(function () {
+ result = mapper.parseIt(test_json, config);
+ });
+
it('Property starts with $', function() {
expect(result.a2).to.equal('a2');
});
@@ -94,4 +102,39 @@ describe('App.QuickDataMapper', function () {
});
});
+ describe('#binaryIndexOf', function () {
+
+ var array1 = [1,2,3,4,5,6,7,8,9];
+ var array2 = ['b','c','d','e','f','g'];
+
+ array1.forEach(function(item, index) {
+ it('numeric array. test ' + (index + 1), function () {
+ expect(mapper.binaryIndexOf(array1, item)).to.equal(index);
+ });
+ });
+
+ it('numeric array. element doesn\'t exists', function () {
+ expect(mapper.binaryIndexOf(array1, 0) < 0).to.be.true;
+ });
+
+ it('numeric array. element doesn\'t exists 2', function () {
+ expect(mapper.binaryIndexOf(array1, 10) < 0).to.be.true;
+ });
+
+ array2.forEach(function(item, index) {
+ it('string array. test ' + (index + 1), function () {
+ expect(mapper.binaryIndexOf(array2, item)).to.equal(index);
+ });
+ });
+
+ it('string array. element doesn\'t exists', function () {
+ expect(mapper.binaryIndexOf(array2, 'a') < 0).to.be.true;
+ });
+
+ it('string array. element doesn\'t exists 2', function () {
+ expect(mapper.binaryIndexOf(array2, 'q') < 0).to.be.true;
+ });
+
+ });
+
});