ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-6256. Remove synchronous calls that load config groups and properties of them. (akovalenko)
Date Tue, 24 Jun 2014 15:06:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 a06704bb9 -> aa07dc031


AMBARI-6256. Remove synchronous calls that load config groups and properties of them. (akovalenko)


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

Branch: refs/heads/branch-1.6.1
Commit: aa07dc0314691067ab2fa796ab694a327aafe218
Parents: a06704b
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Tue Jun 24 18:04:34 2014 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Tue Jun 24 18:04:34 2014 +0300

----------------------------------------------------------------------
 .../controllers/main/host/configs_service.js    | 75 --------------------
 .../controllers/main/service/info/configs.js    | 10 ++-
 .../app/controllers/wizard/step7_controller.js  | 14 +++-
 ambari-web/app/utils/ajax/ajax.js               | 18 +----
 ambari-web/app/utils/config.js                  | 12 +++-
 5 files changed, 29 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aa07dc03/ambari-web/app/controllers/main/host/configs_service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/configs_service.js b/ambari-web/app/controllers/main/host/configs_service.js
index adf62e0..14b16d2 100644
--- a/ambari-web/app/controllers/main/host/configs_service.js
+++ b/ambari-web/app/controllers/main/host/configs_service.js
@@ -66,81 +66,6 @@ App.MainHostServiceConfigsController = App.MainServiceInfoConfigsController.exte
   },
 
   /**
-   * This method will *not load* the overridden properties. However it will
-   * replace the value shown for properties which this host has override for.
-   * @param serviceConfigs
-   * @param loadedGroupToOverrideSiteToTagMap
-   * @param configGroups
-   */
-  loadServiceConfigHostsOverrides: function (serviceConfigs, loadedGroupToOverrideSiteToTagMap,
configGroups) {
-    var configKeyToConfigMap = {};
-    serviceConfigs.forEach(function (item) {
-      configKeyToConfigMap[item.name] = item;
-    });
-    this.set('configKeyToConfigMap', configKeyToConfigMap);
-    var urlParams = this.constructUrlParams(loadedGroupToOverrideSiteToTagMap, configGroups);
-    if (urlParams.length > 0) {
-      App.ajax.send({
-        name: 'host.service_config_hosts_overrides',
-        sender: this,
-        data: {
-          urlParams: urlParams.join('|')
-        },
-        success: 'loadServiceConfigHostsOverridesSuccessCallback',
-        error: 'loadServiceConfigHostsOverridesErrorCallback'
-      });
-    }
-  },
-  /**
-   * construct URL parameters, based on groups
-   * @param loadedGroupToOverrideSiteToTagMap
-   * @param configGroups
-   * @return {Array}
-   */
-  constructUrlParams: function (loadedGroupToOverrideSiteToTagMap, configGroups) {
-    var typeTagToGroupMap = {};
-    var urlParams = [];
-    var thisHostName = this.get('host.hostName');
-    for (var group in loadedGroupToOverrideSiteToTagMap) {
-      var groupObj = configGroups.findProperty('name', group);
-      if (groupObj.get('hosts').contains(thisHostName)) {
-        var overrideTypeTags = loadedGroupToOverrideSiteToTagMap[group];
-        for (var type in overrideTypeTags) {
-          var tag = overrideTypeTags[type];
-          typeTagToGroupMap[type + "///" + tag] = groupObj;
-          urlParams.push('(type=' + type + '&tag=' + tag + ')');
-        }
-      }
-    }
-    this.set('typeTagToGroupMap', typeTagToGroupMap);
-    return urlParams;
-  },
-  /**
-   * handle configs, override their values
-   * @param data
-   */
-  loadServiceConfigHostsOverridesSuccessCallback: function (data) {
-    var typeTagToGroupMap = this.get('typeTagToGroupMap');
-    var configKeyToConfigMap = this.get('configKeyToConfigMap');
-    data.items.forEach(function (config) {
-      var group = typeTagToGroupMap[config.type + "///" + config.tag];
-      var properties = config.properties;
-      for (var prop in properties) {
-        var serviceConfig = configKeyToConfigMap[prop];
-        var hostOverrideValue = properties[prop];
-        if (serviceConfig) {
-          serviceConfig.value = hostOverrideValue;
-          serviceConfig.isOriginalSCP = false;
-          serviceConfig.group = group;
-          App.config.handleSpecialProperties(serviceConfig);
-        }
-      }
-    });
-  },
-  loadServiceConfigHostsOverridesErrorCallback: function (request, ajaxOptions, error) {
-    console.log("TRACE: error code status is: " + request.status);
-  },
-  /**
    * invoke dialog for switching group of host
    */
   switchHostGroup: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa07dc03/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 b494af4..e119397 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -337,7 +337,12 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
     var allConfigs = this.get('globalConfigs').concat(configs);
     //STEP 9: Load and add overriden configs of group
-    App.config.loadServiceConfigGroupOverrides(allConfigs, this.loadedGroupToOverrideSiteToTagMap,
this.get('configGroups'));
+    App.config.loadServiceConfigGroupOverrides(allConfigs, this.loadedGroupToOverrideSiteToTagMap,
this.get('configGroups'), this.onLoadOverrides, this);
+  }.observes('selectedConfigGroup'),
+
+  onLoadOverrides: function (allConfigs) {
+    var serviceName = this.get('content.serviceName');
+    var advancedConfigs = this.get('advancedConfigs');
     //STEP 10: creation of serviceConfig object which contains configs for current service
     var serviceConfig = App.config.createServiceConfig(serviceName);
     //STEP11: Make SecondaryNameNode invisible on enabling namenode HA
@@ -367,8 +372,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       this.set('hash', this.getHash());
       this.set('isInit', false);
     }
-
-  }.observes('selectedConfigGroup'),
+  },
 
   /**
    * Changes format from Object to Array

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa07dc03/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 506fbaf..e81a095 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -77,6 +77,8 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
   groupsToDelete: [],
 
+  preSelectedConfigGroup: null,
+
   /**
    * Currently selected config group
    * @type {object}
@@ -317,12 +319,20 @@ App.WizardStep7Controller = Em.Controller.extend({
           }, this);
         }, this);
       }
-      App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap,
service.get('configGroups'));
+      this.set('preSelectedConfigGroup', selectedConfigGroup);
+      App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap,
service.get('configGroups'), this.onLoadOverrides, this);
+    }
+  },
+
+  onLoadOverrides: function (configs) {
+    var serviceName = configs[0].serviceName,
+        service = this.get('stepConfigs').findProperty('serviceName', serviceName);
+    if (App.get('supports.hostOverrides')) {
       var serviceConfig = App.config.createServiceConfig(serviceName);
       if (serviceConfig.get('serviceName') === 'HDFS') {
         App.config.OnNnHAHideSnn(serviceConfig);
       }
-      service.set('selectedConfigGroup', selectedConfigGroup);
+      service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
       this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
     }
     service.set('configs', serviceConfig.get('configs'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa07dc03/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index e95e804..25bb2d2 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -369,12 +369,7 @@ var urls = {
   },
   'config.host_overrides': {
     'real': '/clusters/{clusterName}/configurations?{params}',
-    'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
-    'format': function() {
-      return {
-        async: false
-      };
-    }
+    'mock': '/data/configurations/host_level_overrides_configs.json?{params}'
   },
 
   'host.host_component.delete': {
@@ -899,16 +894,6 @@ var urls = {
     'mock': '/data/hosts/metrics/processes.json',
     'testInProduction': true
   },
-  'host.service_config_hosts_overrides': {
-    'real': '/clusters/{clusterName}/configurations?{urlParams}',
-    'mock': '',
-    'format': function() {
-      return {
-        async: false,
-        timeout: 10000
-      };
-    }
-  },
   'admin.security_status': {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
     'mock': '',
@@ -1674,7 +1659,6 @@ var urls = {
     'mock': '',
     'format': function (data) {
       return {
-        async: false,
         type: 'POST',
         data: JSON.stringify([{
           "ConfigGroup": {

http://git-wip-us.apache.org/repos/asf/ambari/blob/aa07dc03/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 9037061..5304eda 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -839,9 +839,9 @@ App.config = Em.Object.create({
 
   /**
    * Get properties from server by type and tag with properties, that belong to group
-   * push them to common {serviceConfigs}
+   * push them to common {serviceConfigs} and call callback function
    */
-  loadServiceConfigGroupOverrides: function (serviceConfigs, loadedGroupToOverrideSiteToTagMap,
configGroups) {
+  loadServiceConfigGroupOverrides: function (serviceConfigs, loadedGroupToOverrideSiteToTagMap,
configGroups, callback, sender) {
     var configKeyToConfigMap = {};
     serviceConfigs.forEach(function (item) {
       configKeyToConfigMap[item.name] = item;
@@ -864,10 +864,15 @@ App.config = Em.Object.create({
         data: {
           params: params,
           configKeyToConfigMap: configKeyToConfigMap,
-          typeTagToGroupMap: typeTagToGroupMap
+          typeTagToGroupMap: typeTagToGroupMap,
+          callback: callback,
+          sender: sender,
+          serviceConfigs: serviceConfigs
         },
         success: 'loadServiceConfigGroupOverridesSuccess'
       });
+    } else {
+      callback.call(sender, serviceConfigs);
     }
   },
   loadServiceConfigGroupOverridesSuccess: function (data, opt, params) {
@@ -906,6 +911,7 @@ App.config = Em.Object.create({
         }
       }
     });
+    params.callback.call(params.sender, params.serviceConfigs);
   },
 
   /**


Mime
View raw message