You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/06/06 17:46:02 UTC
git commit: AMBARI-6050. Error in loading stale_configs. (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk a771980bf -> 296c2508b
AMBARI-6050. Error in loading stale_configs. (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/296c2508
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/296c2508
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/296c2508
Branch: refs/heads/trunk
Commit: 296c2508b844a868db727682e4fa9771380b5a70
Parents: a771980
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Fri Jun 6 18:44:08 2014 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Jun 6 18:44:08 2014 +0300
----------------------------------------------------------------------
.../app/controllers/global/update_controller.js | 2 +-
.../app/mappers/component_config_mapper.js | 62 +++++++++-----------
ambari-web/app/mappers/server_data_mapper.js | 3 +-
.../app/mappers/service_metrics_mapper.js | 6 +-
4 files changed, 36 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/296c2508/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 2c7bf29..643eea8 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -280,7 +280,7 @@ App.UpdateController = Em.Controller.extend({
},
updateComponentConfig: function (callback) {
var testUrl = '/data/services/host_component_stale_configs.json';
- var componentConfigUrl = this.getUrl(testUrl, '/host_components?fields=HostRoles/host_name&HostRoles/stale_configs=true&minimal_response=true');
+ 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&minimal_response=true');
App.HttpClient.get(componentConfigUrl, App.componentConfigMapper, {
complete: callback
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/296c2508/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 c0d2726..4f0b69a 100644
--- a/ambari-web/app/mappers/component_config_mapper.js
+++ b/ambari-web/app/mappers/component_config_mapper.js
@@ -17,44 +17,40 @@
var App = require('app');
-/**
- * The usage of previousResponse is due to detect
- * which exactly components has stale_configs changed in comparison to previous response
- */
-var previousResponse = {};
-
App.componentConfigMapper = App.QuickDataMapper.create({
+ model: App.HostComponent,
+ config: {
+ id: 'id',
+ work_status: 'state',
+ passive_state: 'maintenance_state',
+ component_name: 'component_name',
+ $ha_status: 'none',
+ $display_name_advanced: 'none',
+ stale_configs: 'stale_configs',
+ host_id: 'host_name',
+ service_id: 'service_name'
+ },
map: function (json) {
console.time('App.componentConfigMapper execution time');
- if (json.items) {
- var hostComponentRecordsMap = App.cache['hostComponentRecordsMap'];
- var staleConfigsTrue = [];
- var currentResponse = {};
- json.items.forEach(function (component) {
- var id = component.HostRoles.component_name + "_" + component.HostRoles.host_name;
- if (previousResponse[id]) {
- delete previousResponse[id];
- } else {
- staleConfigsTrue.push(id);
+ var hostComponents = [];
+ var serviceToHostComponentIdMap = {};
+ json.items.forEach(function (item) {
+ item.host_components.forEach(function (host_component) {
+ host_component = host_component.HostRoles;
+ host_component.id = host_component.component_name + '_' + host_component.host_name;
+ hostComponents.push(this.parseIt(host_component, this.get('config')));
+ if (!serviceToHostComponentIdMap[host_component.service_name]) {
+ serviceToHostComponentIdMap[host_component.service_name] = [];
}
- currentResponse[id] = true;
- });
-
- /**
- * if stale_configs of components became
- * true:
- * then they will be in "staleConfigsTrue" object
- * false:
- * then they will be in "previousResponse" object
- * if stale_configs haven't changed then both objects will be empty and components stay the same
- */
- staleConfigsTrue.forEach(function (id) {
- hostComponentRecordsMap[id].set('staleConfigs', true);
- });
- for (var id in previousResponse) {
- hostComponentRecordsMap[id].set('staleConfigs', false)
+ serviceToHostComponentIdMap[host_component.service_name].push(host_component.id);
+ }, this);
+ }, this);
+ App.store.loadMany(this.get('model'), hostComponents);
+ for (var serviceName in serviceToHostComponentIdMap) {
+ var service = App.cache['services'].findProperty('ServiceInfo.service_name', serviceName);
+ if (service) {
+ service.host_components.pushObjects(serviceToHostComponentIdMap[serviceName]);
}
- previousResponse = currentResponse;
}
console.timeEnd('App.componentConfigMapper execution time');
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/296c2508/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 2c94c5c..2c9e152 100644
--- a/ambari-web/app/mappers/server_data_mapper.js
+++ b/ambari-web/app/mappers/server_data_mapper.js
@@ -28,8 +28,7 @@ App.cache = {
'previousComponentStatuses': {},
'previousComponentPassiveStates': {},
'hostComponentsOnService': {},
- 'services': [],
- 'hostComponentRecordsMap': {}
+ 'services': []
};
App.ServerDataMapper = Em.Object.extend({
http://git-wip-us.apache.org/repos/asf/ambari/blob/296c2508/ambari-web/app/mappers/service_metrics_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_metrics_mapper.js b/ambari-web/app/mappers/service_metrics_mapper.js
index 9e9dcc4..4b5702d 100644
--- a/ambari-web/app/mappers/service_metrics_mapper.js
+++ b/ambari-web/app/mappers/service_metrics_mapper.js
@@ -213,7 +213,11 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
services.forEach(function (item) {
var finalJson = [];
- item.host_components = hostComponents.filterProperty('service_id', item.ServiceInfo.service_name).mapProperty('id');
+ hostComponents.filterProperty('service_id', item.ServiceInfo.service_name).mapProperty('id').forEach(function (hostComponent) {
+ if (!item.host_components.contains(hostComponent)) {
+ item.host_components.push(hostComponent);
+ }
+ }, this);
item.host_components.sort();
if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {