|
@@ -174,7 +174,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
|
|
|
* This method also compares the actual_configs with the desired_configs
|
|
|
* and builds a diff structure.
|
|
|
*
|
|
|
- * Internall it calculates an array of host-components which need restart.
|
|
|
+ * Internally it calculates an array of host-components which need restart.
|
|
|
* Example:
|
|
|
* [
|
|
|
* {
|
|
@@ -230,186 +230,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
|
|
|
propertyToHostAndComponent: {}
|
|
|
};
|
|
|
var self = this;
|
|
|
- var actualConfigsUrl = this.getUrl('/data/services/host_component_actual_configs.json',
|
|
|
- '/services/'+currentService+'?fields=components/host_components/HostRoles/actual_configs');
|
|
|
- $.ajax({
|
|
|
- type: 'GET',
|
|
|
- url: actualConfigsUrl,
|
|
|
- async: false,
|
|
|
- timeout: 10000,
|
|
|
- dataType: 'json',
|
|
|
- success: function (data) {
|
|
|
- var diffHostComponents = [];
|
|
|
- console.debug("loadActualConfigs(" + actualConfigsUrl + "): Data=", data);
|
|
|
- var configsToDownload = [];
|
|
|
- data.components.forEach(function (serviceComponent) {
|
|
|
- // For current service, do any of the host_components differ in
|
|
|
- // configuration?
|
|
|
- if (currentService === serviceComponent.ServiceComponentInfo.service_name) {
|
|
|
- serviceComponent.host_components.forEach(function (hostComponent) {
|
|
|
- if (hostComponent.HostRoles.actual_configs) {
|
|
|
- for (var site in hostComponent.HostRoles.actual_configs) {
|
|
|
- var actualConfigsTags = hostComponent.HostRoles.actual_configs[site];
|
|
|
- var desiredConfigTags = self.getDesiredConfigTag(site, hostComponent.HostRoles.host_name);
|
|
|
- var desiredConfigOverrideTag = desiredConfigTags.host_override != null ?
|
|
|
- desiredConfigTags.host_override : null;
|
|
|
- var actualConfigOverrideTag = (actualConfigsTags.host_overrides!=null &&
|
|
|
- actualConfigsTags.host_overrides.length>0) ?
|
|
|
- actualConfigsTags.host_overrides[0].tag : null;
|
|
|
- if ((actualConfigsTags.tag &&
|
|
|
- desiredConfigTags.tag &&
|
|
|
- desiredConfigTags.tag !== actualConfigsTags.tag) ||
|
|
|
- (desiredConfigOverrideTag !== actualConfigOverrideTag)) {
|
|
|
- actualConfigsTags.host_override = actualConfigOverrideTag;
|
|
|
- // Restart may be necessary for this host-component
|
|
|
- diffHostComponents.push({
|
|
|
- componentName: hostComponent.HostRoles.component_name,
|
|
|
- serviceName: serviceComponent.ServiceComponentInfo.service_name,
|
|
|
- host: hostComponent.HostRoles.host_name,
|
|
|
- type: site,
|
|
|
- desiredConfigTags: desiredConfigTags,
|
|
|
- actualConfigTags: actualConfigsTags
|
|
|
- });
|
|
|
- self.addConfigDownloadParam(site, actualConfigsTags.tag, configsToDownload);
|
|
|
- self.addConfigDownloadParam(site, actualConfigsTags.host_override, configsToDownload);
|
|
|
- self.addConfigDownloadParam(site, desiredConfigTags.tag, configsToDownload);
|
|
|
- self.addConfigDownloadParam(site, desiredConfigTags.host_override, configsToDownload);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- if (configsToDownload.length > 0) {
|
|
|
- var url = self.getUrl('/data/configurations/cluster_level_actual_configs.json?' + configsToDownload.join('|'), '/configurations?' + configsToDownload.join('|'));
|
|
|
- $.ajax({
|
|
|
- type: 'GET',
|
|
|
- url: url,
|
|
|
- async: false,
|
|
|
- timeout: 10000,
|
|
|
- dataType: 'json',
|
|
|
- success: function (data) {
|
|
|
- console.log("configsToDownload(): In success for ", url);
|
|
|
- if (data.items) {
|
|
|
- data.items.forEach(function (item) {
|
|
|
- App.config.loadedConfigurationsCache[item.type + "_" + item.tag] = item.properties;
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- error: function (request, ajaxOptions, error) {
|
|
|
- console.log("TRACE: In error function for the configsToDownload call");
|
|
|
- console.log("TRACE: value of the url is: " + url);
|
|
|
- console.log("TRACE: error code status is: " + request.status);
|
|
|
- },
|
|
|
- statusCode: require('data/statusCodes')
|
|
|
- });
|
|
|
- }
|
|
|
- // Now all the configurations are loaded.
|
|
|
- // Find the diff in properties
|
|
|
- if (diffHostComponents.length > 0) {
|
|
|
- diffHostComponents.forEach(function (diffHostComponent) {
|
|
|
- // The differences can be both in the base-site config version
|
|
|
- // and also the host override config version. Hence we need to do
|
|
|
- // a config union of both those tags and then see if there are any
|
|
|
- // differences.
|
|
|
- var baseActualConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.actualConfigTags.tag];
|
|
|
- var actualConfigsOverride = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.actualConfigTags.host_override];
|
|
|
- var baseDesiredConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.tag];
|
|
|
- var desiredConfigsOverride = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.host_override];
|
|
|
- var actualConfigs = {};
|
|
|
- var desiredConfigs = {};
|
|
|
- $.extend(actualConfigs, baseActualConfigs);
|
|
|
- $.extend(desiredConfigs, baseDesiredConfigs);
|
|
|
- if (actualConfigsOverride != null) {
|
|
|
- $.extend(actualConfigs, actualConfigsOverride); // Need to override with host override configs
|
|
|
- }
|
|
|
- if (desiredConfigsOverride != null) {
|
|
|
- $.extend(actualConfigs, desiredConfigsOverride); // Need to override with host override configs
|
|
|
- }
|
|
|
- var diffs = self.getConfigDifferences(actualConfigs, desiredConfigs);
|
|
|
- if (!jQuery.isEmptyObject(diffs)) {
|
|
|
- var skip = false;
|
|
|
- if (diffHostComponent.type == 'global') {
|
|
|
- if (!App.config.isServiceEffectedByGlobalChange(
|
|
|
- diffHostComponent.serviceName,
|
|
|
- diffHostComponent.desiredConfigTags.tag,
|
|
|
- diffHostComponent.actualConfigTags.tag)) {
|
|
|
- skip = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!skip) {
|
|
|
- // 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] = {};
|
|
|
- }
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- console.log("loadActualConfigs(): Finished loading. Restart host components = ", diffHostComponents);
|
|
|
- },
|
|
|
- error: function (request, ajaxOptions, error) {
|
|
|
- console.log("loadActualConfigs(): URL:" + actualConfigsUrl + ". Status:", request.status, ", Error:", error);
|
|
|
- },
|
|
|
- statusCode: require('data/statusCodes')
|
|
|
- });
|
|
|
console.log("loadActualConfigsAndCalculateRestarts(): Restart data = ", restartData);
|
|
|
return restartData;
|
|
|
},
|
|
|
|
|
|
- /**
|
|
|
- * Determines the differences between desired and actual configs and returns
|
|
|
- * them as an object. The key is the property, and value is actual_config.
|
|
|
- */
|
|
|
- getConfigDifferences: function (actualConfigs, desiredConfigs) {
|
|
|
- var differences = {};
|
|
|
- if (actualConfigs != null && desiredConfigs != null) {
|
|
|
- for (var desiredProp in desiredConfigs) {
|
|
|
- if (desiredConfigs[desiredProp] !== actualConfigs[desiredProp]) {
|
|
|
- differences[desiredProp] = actualConfigs[desiredProp];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return differences;
|
|
|
- },
|
|
|
-
|
|
|
- addConfigDownloadParam: function (site, tag, configsToDownload) {
|
|
|
- if (tag != null && !(site + "_" + tag in App.config.loadedConfigurationsCache)) {
|
|
|
- var configParam = "(type=" + site + "&tag=" + tag + ")";
|
|
|
- if (!configsToDownload.contains(configParam)) {
|
|
|
- configsToDownload.push(configParam);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- getDesiredConfigTag: function (site, hostName) {
|
|
|
- var tag = {tag: this.loadedClusterSiteToTagMap[site], host_override: null};
|
|
|
- if (hostName in this.loadedHostToOverrideSiteToTagMap) {
|
|
|
- var map = this.loadedHostToOverrideSiteToTagMap[hostName];
|
|
|
- if (site in map) {
|
|
|
- tag.host_override = map[site];
|
|
|
- }
|
|
|
- }
|
|
|
- return tag;
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* Loads service configurations
|
|
|
*/
|