incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject git commit: AMBARI-3582. Cleanup UI restart calculations using actual_configs. (srimanth)
Date Wed, 23 Oct 2013 22:07:09 GMT
Updated Branches:
  refs/heads/trunk 629bd3e5f -> 8eb0034ca


AMBARI-3582. Cleanup UI restart calculations using actual_configs. (srimanth)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/8eb0034c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/8eb0034c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/8eb0034c

Branch: refs/heads/trunk
Commit: 8eb0034ca1f8b3a7ed641100f673b8571e78b595
Parents: 629bd3e
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Wed Oct 23 14:55:28 2013 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Wed Oct 23 14:55:33 2013 -0700

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js |   3 -
 .../controllers/main/service/info/configs.js    | 178 +------------------
 ambari-web/app/mappers/service_mapper.js        |  27 ---
 ambari-web/app/models/host_component.js         |   1 -
 ambari-web/app/models/service.js                |  48 +----
 ambari-web/app/utils/config.js                  |  54 ------
 6 files changed, 2 insertions(+), 309 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/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 344fff5..d0faa71 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -96,9 +96,6 @@ App.UpdateController = Em.Controller.extend({
             conditionalFields.push("components/host_components/metrics/" + service.urlParam);
         }
     });
-    if(App.supports.hostOverrides) {
-      conditionalFields.push('components/host_components/HostRoles/actual_configs');
-    }
     var conditionalFieldsString = conditionalFields.length > 0 ? ',' + conditionalFields.join(',')
: '';
     var initialFieldsString = initialFields.length > 0 ? ',' + initialFields.join(',')
: '';
     var methodStartTs = new Date().getTime();

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/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 5dc2251..b3ac88f 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -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,187 +230,11 @@ 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
    */
   loadServiceConfigs: function () {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/ambari-web/app/mappers/service_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_mapper.js b/ambari-web/app/mappers/service_mapper.js
index a99bed0..fc1c90b 100644
--- a/ambari-web/app/mappers/service_mapper.js
+++ b/ambari-web/app/mappers/service_mapper.js
@@ -241,12 +241,10 @@ App.servicesMapper = App.QuickDataMapper.create({
       // Host components
       result = [];
       var hostComponentsMap = {};
-      var hostComponentToActualConfigsMap = {};
       json.items.forEach(function(item){
         item.components.forEach(function(component){
           var service = component.ServiceComponentInfo.service_name;
           component.host_components.forEach(function(host_component){
-            hostComponentToActualConfigsMap[host_component.id] = host_component.HostRoles.actual_configs;
             var comp = this.parseIt(host_component, this.config3);
             comp.service_id = service;
             this.calculateState(comp);
@@ -296,31 +294,6 @@ App.servicesMapper = App.QuickDataMapper.create({
       if (!App.router.get('clusterController.isLoaded') || doHostComponentsLoad) {
         App.store.loadMany(this.get('model3'), result);
       }
-      for(var hostComponentId in hostComponentToActualConfigsMap){
-        var hostComponentObj = App.HostComponent.find(hostComponentId);
-        var actualConfigs = [];
-        // Create actual_configs
-        for(var site in hostComponentToActualConfigsMap[hostComponentId]){
-          var tag = hostComponentToActualConfigsMap[hostComponentId][site].tag;
-          var configObj = {
-            site: site,
-            tag: tag,
-            hostOverrides: {}
-          };
-          var overrides = hostComponentToActualConfigsMap[hostComponentId][site].host_overrides;
-          if(overrides!=null){
-            var hostOverridesArray = {};
-            overrides.forEach(function(override){
-              var hostname = override.host_name;
-              var tag = override.tag;
-              hostOverridesArray[hostname] = tag;
-            });
-            configObj.hostOverrides = hostOverridesArray;
-          }
-          actualConfigs.push(configObj);
-        }
-        hostComponentObj.set('actualConfigs', actualConfigs);
-      }
     }
     console.log('out service mapper.  Took ' + (new Date().getTime() - start) + 'ms');
   },

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js
index 7c99a3d..3997420 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -24,7 +24,6 @@ App.HostComponent = DS.Model.extend({
   haStatus: DS.attr('string'),
   host: DS.belongsTo('App.Host'),
   service: DS.belongsTo('App.Service'),
-  actualConfigs: null,
   isClient:function () {
     if(['PIG', 'SQOOP', 'HCAT', 'MAPREDUCE2_CLIENT'].contains(this.get('componentName'))){
       return true;

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index b49e91c..b19b34e 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -109,55 +109,9 @@ App.Service = DS.Model.extend({
   isRestartRequired: function () {
     var restartRequired = false;
     var restartRequiredHostsAndComponents = {};
-    var clusterDesiredConfigs = App.router.get('mainServiceController.cluster.desiredConfigs');
-    var serviceTemplate = this.serviceConfigsTemplate.findProperty('serviceName', this.get('serviceName'));
-    if (clusterDesiredConfigs != null && serviceTemplate!=null) {
-      var clusterToDesiredMap = {};
-      clusterDesiredConfigs.forEach(function (config) {
-        clusterToDesiredMap[config.site] = config;
-      });
-      this.get('hostComponents').forEach(function(hostComponent){
-        var host = hostComponent.get('host');
-        var hostName = host.get('hostName');
-        hostComponent.get('actualConfigs').forEach(function(config){
-          if(serviceTemplate.sites.contains(config.site)){
-            var desiredClusterTag = clusterToDesiredMap[config.site].tag;
-            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(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
-              }
-              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);
-                }
-              }
-            }
-          }
-        });
-      });
-    }
     this.set('restartRequiredHostsAndComponents', restartRequiredHostsAndComponents);
     return restartRequired;
-  }.property('serviceName', 'hostComponents', 'hostComponents.@each.actualConfigs', 'hostComponents.@each.actualConfigs.@each.tag',

-      'App.router.mainServiceController.cluster.desiredConfigs', 'App.router.mainServiceController.cluster.desiredConfigs.@each.tag'),
+  }.property('serviceName', 'hostComponents'),
   
   /**
    * Contains a map of which hosts and host_components

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8eb0034c/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 47c2150..0ca60a2 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -692,60 +692,6 @@ App.config = Em.Object.create({
   },
   
   /**
-   * 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(service) > -1;
-                if(effected){
-                  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
    * the 'overrides' of serviceConfig.


Mime
View raw message