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/11 23:10:12 UTC

svn commit: r1467087 - in /incubator/ambari/trunk: CHANGES.txt ambari-web/app/controllers/main/service/info/configs.js ambari-web/app/controllers/wizard/step8_controller.js

Author: srimanth
Date: Thu Apr 11 21:10:12 2013
New Revision: 1467087

URL: http://svn.apache.org/r1467087
Log:
AMBARI-1886. Derived properties not being overridden for hosts. (srimanth)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467087&r1=1467086&r2=1467087&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 11 21:10:12 2013
@@ -692,6 +692,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1886. Derived properties not being overridden for hosts. (srimanth)
+
  AMBARI-1896. Disable editing Capacity Scheduler on host configs. (srimanth)
 
  AMBARI-1894. Refactor configs of Capacity Scheduler category. (srimanth)

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=1467087&r1=1467086&r2=1467087&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 Thu Apr 11 21:10:12 2013
@@ -213,7 +213,6 @@ App.MainServiceInfoConfigsController = E
         hostAndHostComponents: {},
         propertyToHostAndComponent: {}
     };
-    var propertyDifferences = {};
     var self = this;
     var actualConfigsUrl = this.getUrl('/data/services/host_component_actual_configs.json', '/services?fields=components/host_components/HostRoles/actual_configs');
     $.ajax({
@@ -543,7 +542,7 @@ App.MainServiceInfoConfigsController = E
           });
           message += "</ul></li>";
         }
-        message += "</ul>"
+        message += "</ul>";
         serviceConfigProperty.set('restartRequiredMessage', message);
       }
       if (serviceConfigProperty.get('serviceName') === this.get('content.serviceName')) {
@@ -600,13 +599,14 @@ App.MainServiceInfoConfigsController = E
       message = result.message;
       value = result.value;
     }
-
+    var self = this;
     App.ModalPopup.show({
       header: header,
       primary: Em.I18n.t('ok'),
       secondary: null,
       onPrimary: function () {
         this.hide();
+        self.loadStep();
       },
       bodyClass: Ember.View.extend({
         flag: result.flag,
@@ -829,13 +829,14 @@ App.MainServiceInfoConfigsController = E
     var uiConfig = [];
     var configs = configMapping.filterProperty('foreignKey', null);
     configs.forEach(function (_config) {
-      var value = this.getGlobConfigValue(_config.templateName, _config.value, _config.name);
-      if (value !== null) {
+      var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
+      if (valueWithOverrides !== null) {
         uiConfig.pushObject({
           "id": "site property",
           "name": _config.name,
-          "value": value,
-          "filename": _config.filename
+          "value": valueWithOverrides.value,
+          "filename": _config.filename,
+          "overrides": valueWithOverrides.overrides
         });
       }
     }, this);
@@ -847,40 +848,44 @@ App.MainServiceInfoConfigsController = E
    * @param templateName
    * @param expression
    * @param name
-   * @return {*}
+   * @return {
+   *   value: '...',
+   *   overrides: {
+   *    'value1': [h1, h2],
+   *    'value2': [h3]
+   *   }
+   * }
    */
-  getGlobConfigValue: function (templateName, expression, name) {
+  getGlobConfigValueWithOverrides: function (templateName, expression, name) {
     var express = expression.match(/<(.*?)>/g);
     var value = expression;
     if (express == null) {
       return expression;
     }
-
+    var overrideHostToValue = {};
     express.forEach(function (_express) {
       //console.log("The value of template is: " + _express);
       var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
       if (this.get('globalConfigs').someProperty('name', templateName[index])) {
         //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
-        var globValue = this.get('globalConfigs').findProperty('name', templateName[index]).value;
+        var globalObj = this.get('globalConfigs').findProperty('name', templateName[index]);
+        var globValue = globalObj.value;
         // Hack for templeton.zookeeper.hosts
+        var preReplaceValue = null;
         if (value !== null) {   // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
-          if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
-            var zooKeeperPort = '2181';
-            if (typeof globValue === 'string') {
-              var temp = [];
-              temp.push(globValue);
-              globValue = temp;
-            }
-            if (name === "templeton.zookeeper.hosts") {
-              var temp = [];
-              globValue.forEach(function (_host, index) {
-                temp.push(globValue[index] + ':' + zooKeeperPort);
-              }, this);
-              globValue = temp;
-            }
-            value = value.replace(_express, globValue.toString());
-          } else {
-            value = value.replace(_express, globValue);
+          preReplaceValue = value;
+          value = this._replaceConfigValues(name, _express, value, globValue);
+        }
+        if(globalObj.overrides!=null){
+          for(ov in globalObj.overrides){
+            var hostsArray = globalObj.overrides[ov];
+            hostsArray.forEach(function(host){
+              if(!(host in overrideHostToValue)){
+                overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
+              }else{
+                overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
+              }
+            }, this);
           }
         }
       } else {
@@ -893,6 +898,42 @@ App.MainServiceInfoConfigsController = E
         value = null;
       }
     }, this);
+
+    var valueWithOverrides = {
+        value: value,
+        overrides: {}
+    };
+    if(!jQuery.isEmptyObject(overrideHostToValue)){
+      for(var host in overrideHostToValue){
+        var hostVal = overrideHostToValue[host];
+        if(!(hostVal in valueWithOverrides.overrides)){
+          valueWithOverrides.overrides[hostVal] = [];
+        }
+        valueWithOverrides.overrides[hostVal].push(host);
+      }
+    }
+    return valueWithOverrides;
+  },
+  
+  _replaceConfigValues: function (name, express, value, globValue) {
+    if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
+      var zooKeeperPort = '2181';
+      if (typeof globValue === 'string') {
+        var temp = [];
+        temp.push(globValue);
+        globValue = temp;
+      }
+      if (name === "templeton.zookeeper.hosts") {
+        var temp = [];
+        globValue.forEach(function (_host, index) {
+          temp.push(globValue[index] + ':' + zooKeeperPort);
+        }, this);
+        globValue = temp;
+      }
+      value = value.replace(express, globValue.toString());
+    } else {
+      value = value.replace(express, globValue);
+    }
     return value;
   },
 

Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js?rev=1467087&r1=1467086&r2=1467087&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js Thu Apr 11 21:10:12 2013
@@ -187,12 +187,13 @@ App.WizardStep8Controller = Em.Controlle
     var uiConfig = [];
     var configs = this.get('configMapping').filterProperty('foreignKey', null);
     configs.forEach(function (_config) {
-      var value = this.getGlobConfigValue(_config.templateName, _config.value, _config.name);
+      var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
       uiConfig.pushObject({
         "id": "site property",
         "name": _config.name,
-        "value": value,
-        "filename": _config.filename
+        "value": valueWithOverrides.value,
+        "filename": _config.filename,
+        "overrides": valueWithOverrides.overrides
       });
     }, this);
     var dependentConfig = this.get('configMapping').filterProperty('foreignKey');
@@ -222,36 +223,47 @@ App.WizardStep8Controller = Em.Controlle
 
   /**
    * Set all site property that are derived from other puppet-variable
+   * @return {
+   *   value: '...',
+   *   overrides: {
+   *    'value1': [h1, h2],
+   *    'value2': [h3]
+   *   }
+   * }
    */
 
-  getGlobConfigValue: function (templateName, expression, name) {
+  getGlobConfigValueWithOverrides: function (templateName, expression, name) {
     var express = expression.match(/<(.*?)>/g);
     var value = expression;
     if (express == null) {
       return expression;
     }
+    var overrideHostToValue = {};
     express.forEach(function (_express) {
       //console.log("The value of template is: " + _express);
       var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
       if (this.get('globals').someProperty('name', templateName[index])) {
         //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
-        var globValue = this.get('globals').findProperty('name', templateName[index]).value;
+        var globalObj = this.get('globals').findProperty('name', templateName[index]);
+        var globValue = globalObj.value;
         // Hack for templeton.zookeeper.hosts
+        var preReplaceValue = null;
         if (value !== null) {   // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
-          if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
-            // globValue is an array of ZooKeeper Server hosts
-            var zooKeeperPort = '2181';
-            if (name === "templeton.zookeeper.hosts") {
-              var zooKeeperServers = globValue.map(function (item) {
-                return item + ':' + zooKeeperPort;
-              }).join(',');
-              value = value.replace(_express, zooKeeperServers);
-            } else {
-              value = value.replace(_express, globValue.join(','));
-            }
-          } else {
-            value = value.replace(_express, globValue);
-          }
+          preReplaceValue = value;
+          value = this._replaceConfigValues(name, _express, value, globValue);
+        }
+        if(globalObj.overrides!=null){
+          globalObj.overrides.forEach(function(override){
+            var ov = override.value;
+            var hostsArray = override.hosts;
+            hostsArray.forEach(function(host){
+              if(!(host in overrideHostToValue)){
+                overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
+              }else{
+                overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
+              }
+            }, this);
+          }, this);
         }
       } else {
         /*
@@ -263,8 +275,48 @@ App.WizardStep8Controller = Em.Controlle
         value = null;
       }
     }, this);
+    
+    var valueWithOverrides = {
+        value: value,
+        overrides: []
+    };
+    var overrideValueToHostMap = {};
+    if(!jQuery.isEmptyObject(overrideHostToValue)){
+      for(var host in overrideHostToValue){
+        var hostVal = overrideHostToValue[host];
+        if(!(hostVal in overrideValueToHostMap)){
+          overrideValueToHostMap[hostVal] = [];
+        }
+        overrideValueToHostMap[hostVal].push(host);
+      }
+    }
+    for(var val in overrideValueToHostMap){
+      valueWithOverrides.overrides.push({
+        value: val,
+        hosts: overrideValueToHostMap[val]
+      });
+    }
+    return valueWithOverrides;
+  },
+  
+  _replaceConfigValues: function (name, express, value, globValue) {
+    if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
+      // globValue is an array of ZooKeeper Server hosts
+      var zooKeeperPort = '2181';
+      if (name === "templeton.zookeeper.hosts") {
+        var zooKeeperServers = globValue.map(function (item) {
+          return item + ':' + zooKeeperPort;
+        }).join(',');
+        value = value.replace(express, zooKeeperServers);
+      } else {
+        value = value.replace(express, globValue.join(','));
+      }
+    } else {
+      value = value.replace(express, globValue);
+    }
     return value;
   },
+  
   /**
    * Set all site property that are derived from other site-properties
    */