Repository: ambari Updated Branches: refs/heads/trunk 03c757c63 -> 0887d94eb
AMBARI-5137. Strange HDFS and Mapreduce services behavior after FIRST "Save" button click on Config tab. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0887d94e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0887d94e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0887d94e Branch: refs/heads/trunk Commit: 0887d94eb4beb34fd7b2c2cc6b5140813acf0e60 Parents: 03c757c Author: Oleg Nechiporenko <[email protected]> Authored: Wed Mar 19 15:31:40 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Wed Mar 19 15:31:40 2014 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 107 +++++++++++-------- ambari-web/app/utils/ajax.js | 17 ++- 2 files changed, 76 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0887d94e/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index 26a7f6e..33abb98 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -1255,41 +1255,52 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ var filenameExceptions = App.config.get('filenameExceptions'); serviceConfigTags.forEach(function (_serviceTags) { + var loadedProperties; if (_serviceTags.siteName === 'global') { console.log("TRACE: Inside global"); var serverGlobalConfigs = this.createGlobalSiteObj(_serviceTags.newTagName, this.get('globalConfigs')); siteNameToServerDataMap['global'] = serverGlobalConfigs; - var loadedProperties = configController.getConfigsByTags([{siteName: 'global', tagName: this.loadedClusterSiteToTagMap['global']}]); + loadedProperties = configController.getConfigsByTags([{siteName: 'global', tagName: this.loadedClusterSiteToTagMap['global']}]); if (loadedProperties && loadedProperties[0]) { loadedProperties = loadedProperties[0].properties; } if (this.isConfigChanged(loadedProperties, serverGlobalConfigs.properties)) { result = result && this.doPUTClusterConfigurationSite(serverGlobalConfigs); } - } else if (_serviceTags.siteName === 'core-site') { - console.log("TRACE: Inside core-site"); - if (this.get('content.serviceName') === 'HDFS' || this.get('content.serviceName') === 'GLUSTERFS') { - var coreSiteConfigs = this.createCoreSiteObj(_serviceTags.newTagName); - siteNameToServerDataMap['core-site'] = coreSiteConfigs; - var loadedProperties = configController.getConfigsByTags([{siteName: 'core-site', tagName: this.loadedClusterSiteToTagMap['core-site']}]); + } + else { + if (_serviceTags.siteName === 'core-site') { + console.log("TRACE: Inside core-site"); + if (this.get('content.serviceName') === 'HDFS' || this.get('content.serviceName') === 'GLUSTERFS') { + var coreSiteConfigs = this.createCoreSiteObj(_serviceTags.newTagName); + siteNameToServerDataMap['core-site'] = coreSiteConfigs; + loadedProperties = configController.getConfigsByTags([{siteName: 'core-site', tagName: this.loadedClusterSiteToTagMap['core-site']}]); + if (loadedProperties && loadedProperties[0]) { + loadedProperties = loadedProperties[0].properties; + } + if (this.isConfigChanged(loadedProperties, coreSiteConfigs.properties)) { + result = result && this.doPUTClusterConfigurationSite(coreSiteConfigs); + } + } + } + else { + var filename = (filenameExceptions.contains(_serviceTags.siteName)) ? _serviceTags.siteName : _serviceTags.siteName + '.xml'; + var siteConfigs = this.get('uiConfigs').filterProperty('filename', filename); + var serverConfigs = this.createSiteObj(_serviceTags.siteName, _serviceTags.newTagName, siteConfigs); + siteNameToServerDataMap[_serviceTags.siteName] = serverConfigs; + loadedProperties = configController.getConfigsByTags([{siteName: _serviceTags.siteName, tagName: this.loadedClusterSiteToTagMap[_serviceTags.siteName]}]); if (loadedProperties && loadedProperties[0]) { loadedProperties = loadedProperties[0].properties; } - if (this.isConfigChanged(loadedProperties, coreSiteConfigs.properties)) { - result = result && this.doPUTClusterConfigurationSite(coreSiteConfigs); + if (!loadedProperties) { + loadedProperties = {}; + } + if (filename === 'mapred-queue-acls' && !App.supports.capacitySchedulerUi) { + return; + } + if (this.isConfigChanged(loadedProperties, serverConfigs.properties)) { + result = result && this.doPUTClusterConfigurationSite(serverConfigs); } - } - } else { - var filename = (filenameExceptions.contains(_serviceTags.siteName)) ? _serviceTags.siteName : _serviceTags.siteName + '.xml'; - var siteConfigs = this.get('uiConfigs').filterProperty('filename', filename); - var serverConfigs = this.createSiteObj(_serviceTags.siteName, _serviceTags.newTagName, siteConfigs); - siteNameToServerDataMap[_serviceTags.siteName] = serverConfigs; - var loadedProperties = configController.getConfigsByTags([{siteName: _serviceTags.siteName, tagName: this.loadedClusterSiteToTagMap[_serviceTags.siteName]}]); - if (loadedProperties && loadedProperties[0]) { - loadedProperties = loadedProperties[0].properties; - } - if (this.isConfigChanged(loadedProperties, serverConfigs.properties)) { - result = result && this.doPUTClusterConfigurationSite(serverConfigs); } } }, this); @@ -1306,6 +1317,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ if (loadedConfig != null && savingConfig != null) { var seenLoadKeys = []; for (var loadKey in loadedConfig) { + if (!loadedConfig.hasOwnProperty(loadKey)) continue; seenLoadKeys.push(loadKey); var loadValue = loadedConfig[loadKey]; var saveValue = savingConfig[loadKey]; @@ -1335,33 +1347,36 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ * contains the site name and tag to be used. */ doPUTClusterConfigurationSite: function (data) { - var result; - var url = this.getUrl('', ''); - var clusterData = { - Clusters: { - desired_config: data - } - }; - console.log("applyClusterConfigurationToSite(): PUTting data:", clusterData); - $.ajax({ - type: 'PUT', - url: url, - async: false, - dataType: 'text', - data: JSON.stringify(clusterData), - timeout: 5000, - success: function (data) { - console.log("applyClusterConfigurationToSite(): In success for data:", data); - result = true; - }, - error: function (request, ajaxOptions, error) { - console.log('applyClusterConfigurationToSite(): ERROR:', request.responseText, ", error=", error); - result = false; + App.ajax.send({ + name: 'config.cluster_configuration.put', + sender: this, + data: { + data: JSON.stringify({ + Clusters: { + desired_config: data + } + }), + cluster: App.router.getClusterName() }, - statusCode: require('data/statusCodes') + success: 'doPUTClusterConfigurationSiteSuccessCallback', + error: 'doPUTClusterConfigurationSiteErrorCallback' }); - console.log("applyClusterConfigurationToSite(): Exiting with result=" + result); - return result; + return this.get('doPUTClusterConfigurationSiteResult'); + }, + + /** + * @type {bool} + */ + doPUTClusterConfigurationSiteResult: null, + + doPUTClusterConfigurationSiteSuccessCallback: function(data) { + console.log("applyClusterConfigurationToSite(): In success for data:", data); + this.set('doPUTClusterConfigurationSiteResult', true); + }, + + doPUTClusterConfigurationSiteErrorCallback: function(request, ajaxOptions, error) { + console.log('applyClusterConfigurationToSite(): ERROR:', request.responseText, ", error=", error); + this.set('doPUTClusterConfigurationSiteResult', false); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/0887d94e/ambari-web/app/utils/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js index 086c278..6cd7d79 100644 --- a/ambari-web/app/utils/ajax.js +++ b/ambari-web/app/utils/ajax.js @@ -284,6 +284,19 @@ var urls = { } }, + 'config.cluster_configuration.put': { + 'real': '/clusters/{cluster}', + 'mock': '', + 'format': function(data) { + return { + type: 'PUT', + async: false, + dataType: 'text', + data: data.data + } + } + }, + 'config.advanced': { 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*', 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json', @@ -1130,7 +1143,7 @@ var urls = { 'admin.stack_upgrade.run_upgrade': { 'real': '/clusters/{clusterName}', 'mock': '', - 'format': function () { + 'format': function (data) { return { type: 'PUT', async: false, @@ -1141,7 +1154,7 @@ var urls = { 'admin.stack_upgrade.stop_services': { 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED', 'mock': '', - 'format': function () { + 'format': function (data) { return { type: 'PUT', async: false,
