Repository: ambari Updated Branches: refs/heads/branch-2.1 ad2092cd7 -> 32aa51d9f
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/32aa51d9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32aa51d9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32aa51d9 Branch: refs/heads/branch-2.1 Commit: 32aa51d9f54c10154b064c6955691ec6c9c938b0 Parents: ad2092c Author: Andrii Tkach <atk...@hortonworks.com> Authored: Tue Jul 21 22:19:05 2015 +0300 Committer: Andrii Tkach <atk...@hortonworks.com> Committed: Tue Jul 21 22:19:05 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/32aa51d9/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/32aa51d9/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'); } } });