Repository: ambari Updated Branches: refs/heads/trunk 81b4febe6 -> fb7e4e608
AMBARI-12475 Optimize serviceConfigVersionsMapper execution time. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fb7e4e60 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fb7e4e60 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fb7e4e60 Branch: refs/heads/trunk Commit: fb7e4e608421e50807310bf46b2c35e5ced69bfe Parents: 81b4feb Author: Andrii Tkach <atk...@hortonworks.com> Authored: Tue Jul 21 22:29:52 2015 +0300 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Tue Jul 21 22:30:11 2015 +0300 ---------------------------------------------------------------------- .../main/dashboard/config_history_controller.js | 5 +--- .../mappers/service_config_version_mapper.js | 31 ++++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fb7e4e60/ambari-web/app/controllers/main/dashboard/config_history_controller.js ---------------------------------------------------------------------- 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 a2e6f52..66ae200 100644 --- a/ambari-web/app/controllers/main/dashboard/config_history_controller.js +++ b/ambari-web/app/controllers/main/dashboard/config_history_controller.js @@ -21,10 +21,7 @@ var App = require('app'); App.MainConfigHistoryController = Em.ArrayController.extend(App.TableServerMixin, { name: 'mainConfigHistoryController', - dataSource: App.ServiceConfigVersion.find(), - content: function () { - return this.get('dataSource').filterProperty('isRequested'); - }.property('dataSource.@each.isRequested'), + content: App.ServiceConfigVersion.find(), isPolling: false, totalCount: 0, filteredCount: 0, http://git-wip-us.apache.org/repos/asf/ambari/blob/fb7e4e60/ambari-web/app/mappers/service_config_version_mapper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mappers/service_config_version_mapper.js b/ambari-web/app/mappers/service_config_version_mapper.js index 69bc35c..20d876a 100644 --- a/ambari-web/app/mappers/service_config_version_mapper.js +++ b/ambari-web/app/mappers/service_config_version_mapper.js @@ -36,11 +36,19 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({ is_compatible: 'is_cluster_compatible' }, map: function (json) { + console.time('App.serviceConfigVersionsMapper'); var result = []; var itemIds = {}; var serviceToHostMap = {}; + var currentVersionsMap = {}; if (json && json.items) { + App.ServiceConfigVersion.find().forEach(function (v) { + if (v.get('isCurrent')) { + currentVersionsMap[v.get('serviceName') + "_" + v.get('groupName')] = v; + } + }); + json.items.forEach(function (item, index) { var parsedItem = this.parseIt(item, this.get('config')); parsedItem.id = parsedItem.service_name + '_' + parsedItem.version; @@ -52,18 +60,19 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({ } else { serviceToHostMap[item.service_name] = item.hosts; } + + // if loaded only latest versions(later than current), then current version should be reset + if (parsedItem.is_current && currentVersionsMap[parsedItem.service_name + "_" + parsedItem.group_name]) { + currentVersionsMap[parsedItem.service_name + "_" + parsedItem.group_name].set('isCurrent', false); + } result.push(parsedItem); }, this); - this.get('model').find().forEach(function (item) { - if (!itemIds[item.get('id')]) { - item.set('isRequested', false); - } - }); var itemTotal = parseInt(json.itemTotal); if (!isNaN(itemTotal)) { App.router.set('mainConfigHistoryController.filteredCount', itemTotal); } + /** * this code sets hostNames for default config group * by excluding hostNames that belongs to not default groups @@ -82,17 +91,9 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({ } }); - result.forEach(function(v) { - if (v.is_current) { - var formerCurrent = App.ServiceConfigVersion.find().filterProperty('isCurrent').filterProperty('serviceName', v.service_name).findProperty('groupName', v.group_name); - if (formerCurrent) { - formerCurrent.set('isCurrent', false); - } - } - }); - - App.store.commit(); + this.get('model').find().clear(); App.store.loadMany(this.get('model'), result); + console.timeEnd('App.serviceConfigVersionsMapper'); } } });