You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2013/04/09 01:31:57 UTC
svn commit: r1465823 [3/3] - in /incubator/ambari/trunk: ./ ambari-web/app/
ambari-web/app/assets/data/wizard/stack/hdp/version130/
ambari-web/app/controllers/main/service/info/ ambari-web/app/models/
ambari-web/app/utils/
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js?rev=1465823&r1=1465822&r2=1465823&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js Mon Apr 8 23:31:57 2013
@@ -292,25 +292,36 @@ App.MainServiceInfoConfigsController = E
var desiredConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.tag];
var diffs = self.getConfigDifferences(actualConfigs, desiredConfigs);
if (!jQuery.isEmptyObject(diffs)) {
- // Populate restartData.hostAndHostComponents
- if (!(diffHostComponent.host in restartData.hostAndHostComponents)) {
- restartData.hostAndHostComponents[diffHostComponent.host] = {};
- }
- if (!(diffHostComponent.componentName in restartData.hostAndHostComponents[diffHostComponent.host])) {
- restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName] = {};
+ var skip = false;
+ if (diffHostComponent.type == 'global') {
+ if(!App.config.isServiceEffectedByGlobalChange(
+ diffHostComponent.serviceName,
+ diffHostComponent.desiredConfigTags.tag,
+ diffHostComponent.actualConfigTags.tag)){
+ skip = true;
+ }
}
- jQuery.extend(restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName], diffs);
-
- // Populate restartData.propertyToHostAndComponent
- for ( var diff in diffs) {
- if (!(diff in restartData.propertyToHostAndComponent)) {
- restartData.propertyToHostAndComponent[diff] = {};
+ if(!skip){
+ // Populate restartData.hostAndHostComponents
+ if (!(diffHostComponent.host in restartData.hostAndHostComponents)) {
+ restartData.hostAndHostComponents[diffHostComponent.host] = {};
}
- if (!(diffHostComponent.host in restartData.propertyToHostAndComponent[diff])) {
- restartData.propertyToHostAndComponent[diff][diffHostComponent.host] = [];
+ if (!(diffHostComponent.componentName in restartData.hostAndHostComponents[diffHostComponent.host])) {
+ restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName] = {};
}
- if (!(restartData.propertyToHostAndComponent[diff][diffHostComponent.host].contains(diffHostComponent.componentName))) {
- restartData.propertyToHostAndComponent[diff][diffHostComponent.host].push(diffHostComponent.componentName);
+ jQuery.extend(restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName], diffs);
+
+ // Populate restartData.propertyToHostAndComponent
+ for ( var diff in diffs) {
+ if (!(diff in restartData.propertyToHostAndComponent)) {
+ restartData.propertyToHostAndComponent[diff] = {};
+ }
+ if (!(diffHostComponent.host in restartData.propertyToHostAndComponent[diff])) {
+ restartData.propertyToHostAndComponent[diff][diffHostComponent.host] = [];
+ }
+ if (!(restartData.propertyToHostAndComponent[diff][diffHostComponent.host].contains(diffHostComponent.componentName))) {
+ restartData.propertyToHostAndComponent[diff][diffHostComponent.host].push(diffHostComponent.componentName);
+ }
}
}
}
Modified: incubator/ambari/trunk/ambari-web/app/models/service.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/service.js?rev=1465823&r1=1465822&r2=1465823&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/service.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/service.js Mon Apr 8 23:31:57 2013
@@ -184,16 +184,30 @@ App.Service = DS.Model.extend({
var desiredHostOverrideTag = clusterToDesiredMap[config.site].hostOverrides[hostName];
var actualClusterTag = config.tag;
var actualHostOverrideTag = config.hostOverrides[hostName];
+ var siteRestartRequired = false;
if(actualClusterTag !== desiredClusterTag || actualHostOverrideTag !== desiredHostOverrideTag){
var publicHostName = host.get('publicHostName');
- if(!(publicHostName in restartRequiredHostsAndComponents)){
- restartRequiredHostsAndComponents[publicHostName] = [];
+ if(config.site=='global'){
+ var serviceName = hostComponent.get('service.serviceName');
+ if(actualClusterTag !== desiredClusterTag){
+ siteRestartRequired = App.config.isServiceEffectedByGlobalChange(serviceName, actualClusterTag, desiredClusterTag);
+ }
+ if(actualHostOverrideTag !== desiredHostOverrideTag){
+ siteRestartRequired = App.config.isServiceEffectedByGlobalChange(serviceName, actualHostOverrideTag, desiredHostOverrideTag);
+ }
+ }else{
+ siteRestartRequired = true
}
- var hostComponentName = hostComponent.get('displayName');
- if(restartRequiredHostsAndComponents[publicHostName].indexOf(hostComponentName)<0){
- restartRequiredHostsAndComponents[publicHostName].push(hostComponentName);
+ if(siteRestartRequired){
+ restartRequired = true;
+ if(!(publicHostName in restartRequiredHostsAndComponents)){
+ restartRequiredHostsAndComponents[publicHostName] = [];
+ }
+ var hostComponentName = hostComponent.get('displayName');
+ if(restartRequiredHostsAndComponents[publicHostName].indexOf(hostComponentName)<0){
+ restartRequiredHostsAndComponents[publicHostName].push(hostComponentName);
+ }
}
- restartRequired = true;
}
}
});
Modified: incubator/ambari/trunk/ambari-web/app/utils/ajax.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/ajax.js?rev=1465823&r1=1465822&r2=1465823&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/ajax.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/ajax.js Mon Apr 8 23:31:57 2013
@@ -207,6 +207,15 @@ var urls = {
};
}
},
+ 'config.advanced.global': {
+ 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/filename',
+ 'mock': '/data/wizard/stack/hdp/version130/global.json',
+ 'format': function(data){
+ return {
+ async: false
+ };
+ }
+ },
'config.tags': {
'real': '/clusters/{clusterName}',
'mock': '/data/clusters/cluster.json'
Modified: incubator/ambari/trunk/ambari-web/app/utils/config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/config.js?rev=1465823&r1=1465822&r2=1465823&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/config.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/config.js Mon Apr 8 23:31:57 2013
@@ -20,6 +20,7 @@ var App = require('app');
var serviceComponents = {};
var configGroupsByTag = [];
+var globalPropertyToServicesMap = null;
App.config = Em.Object.create({
@@ -42,6 +43,13 @@ App.config = Em.Object.create({
* }
*/
loadedConfigurationsCache: {},
+ /**
+ * Array of global "service/desired_tag/actual_tag" strings which
+ * indicate different configurations. We cache these so that
+ * we dont have to recalculate if two tags are difference.
+ */
+ differentGlobalTagsCache:[],
+
identifyCategory: function(config){
var category = null;
var serviceConfigMetaData = this.get('preDefinedServiceConfigs').findProperty('serviceName', config.serviceName);
@@ -458,6 +466,100 @@ App.config = Em.Object.create({
data.properties.setEach('serviceName', params.serviceName);
serviceComponents[params.serviceName] = data.properties;
},
+
+ /**
+ * Determine the map which shows which services
+ * each global property effects.
+ *
+ * @return {*}
+ * Example:
+ * {
+ * 'hive_pid_dir': ['HIVE'],
+ * ...
+ * }
+ */
+ loadGlobalPropertyToServicesMap: function () {
+ if (globalPropertyToServicesMap == null) {
+ App.ajax.send({
+ name: 'config.advanced.global',
+ sender: this,
+ data: {
+ stack2VersionUrl: App.get('stack2VersionURL')
+ },
+ success: 'loadGlobalPropertyToServicesMapSuccess'
+ });
+ }
+ return globalPropertyToServicesMap;
+ },
+
+ loadGlobalPropertyToServicesMapSuccess: function (data) {
+ globalPropertyToServicesMap = {};
+ if(data.items!=null){
+ data.items.forEach(function(service){
+ service.configurations.forEach(function(config){
+ if("global.xml" === config.StackConfigurations.filename){
+ if(!(config.StackConfigurations.property_name in globalPropertyToServicesMap)){
+ globalPropertyToServicesMap[config.StackConfigurations.property_name] = [];
+ }
+ globalPropertyToServicesMap[config.StackConfigurations.property_name].push(service.StackServices.service_name);
+ }
+ });
+ });
+ }
+ },
+
+ /**
+ * When global configuration changes, not all services are effected
+ * by all properties. This method determines if a given service
+ * is effected by the difference in desired and actual configs.
+ *
+ * This method might make a call to server to determine the actual
+ * key/value pairs involved.
+ */
+ isServiceEffectedByGlobalChange: function (service, desiredTag, actualTag) {
+ var effected = false;
+ if (service != null && desiredTag != null && actualTag != null) {
+ if(this.differentGlobalTagsCache.indexOf(service+"/"+desiredTag+"/"+actualTag) < 0){
+ this.loadGlobalPropertyToServicesMap();
+ var desiredConfigs = this.loadedConfigurationsCache['global_' + desiredTag];
+ var actualConfigs = this.loadedConfigurationsCache['global_' + actualTag];
+ var requestTags = [];
+ if (!desiredConfigs) {
+ requestTags.push({
+ siteName: 'global',
+ tagName: desiredTag
+ });
+ }
+ if (!actualConfigs) {
+ requestTags.push({
+ siteName: 'global',
+ tagName: actualTag
+ });
+ }
+ if (requestTags.length > 0) {
+ this.loadConfigsByTags(requestTags);
+ desiredConfigs = this.loadedConfigurationsCache['global_' + desiredTag];
+ actualConfigs = this.loadedConfigurationsCache['global_' + actualTag];
+ }
+ if (desiredConfigs != null && actualConfigs != null) {
+ for ( var property in desiredConfigs) {
+ if (!effected) {
+ var dpv = desiredConfigs[property];
+ var apv = actualConfigs[property];
+ if (dpv !== apv && globalPropertyToServicesMap[property] != null) {
+ effected = globalPropertyToServicesMap[property].indexOf(serviceName) > -1;
+ this.differentGlobalTagsCache.push(service+"/"+desiredTag+"/"+actualTag);
+ }
+ }
+ }
+ }
+ }else{
+ effected = true; // We already know they are different
+ }
+ }
+ return effected;
+ },
+
/**
* Hosts can override service configurations per property. This method GETs
* the overriden configurations and sets only the changed properties into