You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2014/11/14 18:50:36 UTC

ambari git commit: AMBARI-8281 UI only loads content property from stack for *-env.xml, others are ignored 2. (Max Shepel via ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 71d92ba0c -> 27c239f13


AMBARI-8281 UI only loads content property from stack for *-env.xml, others are ignored 2. (Max Shepel via ababiichuk)


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

Branch: refs/heads/trunk
Commit: 27c239f13ed330ec0c4a962e57d60dd71eb472f5
Parents: 71d92ba
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Fri Nov 14 18:25:44 2014 +0200
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Fri Nov 14 18:25:44 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 58 ++++++++++---------
 ambari-web/app/models/service_config.js         |  8 ++-
 ambari-web/app/utils/config.js                  | 10 ++--
 .../test/controllers/wizard/step7_test.js       | 59 ++++++++++++++++++++
 4 files changed, 100 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/27c239f1/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 5b2a904..2b6f570 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -833,44 +833,48 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
     var self = this;
 
     configsByTags.forEach(function (configSite) {
-      $.extend(configsMap, configSite.properties);
-      for (var name in configSite.properties) {
-        configTypeMap[name] = configSite.type;
-      }
+      configsMap[configSite.type] = configSite.properties;
     });
     configs.forEach(function (_config) {
       var nonServiceTab = require('data/service_configs');
-      if (!Em.isNone(configsMap[_config.name]) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
+      if (_config.filename) {
+        var type = _config.filename.replace(/.xml$/, '');
+      }
+      var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
+      if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
         // prevent overriding already edited properties
-        if (_config.defaultValue != configsMap[_config.name])
-          _config.value = configsMap[_config.name];
-        _config.defaultValue = configsMap[_config.name];
+        if (_config.defaultValue != mappedConfigValue) {
+          _config.value = mappedConfigValue;
+        }
+        _config.defaultValue = mappedConfigValue;
         _config.hasInitialValue = true;
         App.config.handleSpecialProperties(_config);
-        delete configsMap[_config.name];
+        delete configsMap[type][_config.name];
       }
     });
     self.setServiceDatabaseConfigs(configs);
     //add user properties
 
-    for (var name in configsMap) {
-      configs.push(configMixin.addUserProperty({
-        id: 'site property',
-        name: name,
-        serviceName: configMixin.getServiceNameByConfigType(configTypeMap[name]),
-        value: configsMap[name],
-        defaultValue: configsMap[name],
-        filename: (configMixin.get('filenameExceptions').contains(configTypeMap[name])) ? configTypeMap[name] : configTypeMap[name] + '.xml',
-        category: 'Advanced',
-        hasInitialValue: true,
-        isUserProperty: true,
-        isOverridable: true,
-        overrides: [],
-        isRequired: true,
-        isVisible: true,
-        showLabel: true
-      }, false, []));
-    }
+    Em.keys(configsMap).forEach(function (filename) {
+      Em.keys(configsMap[filename]).forEach(function (propertyName) {
+        configs.push(configMixin.addUserProperty({
+          id: 'site property',
+          name: propertyName,
+          serviceName: configMixin.getServiceNameByConfigType(filename),
+          value: configsMap[filename][propertyName],
+          defaultValue: configsMap[filename][propertyName],
+          filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
+          category: 'Advanced',
+          hasInitialValue: true,
+          isUserProperty: true,
+          isOverridable: true,
+          overrides: [],
+          isRequired: true,
+          isVisible: true,
+          showLabel: true
+        }, false, []));
+      });
+    });
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/27c239f1/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 36ac180..255a679 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -653,9 +653,11 @@ App.ServiceConfigProperty = Ember.Object.extend({
         break;
       case 'hbase.tmp.dir':
         temp = slaveComponentHostsInDB.findProperty('componentName', 'HBASE_REGIONSERVER');
-        temp.hosts.forEach(function (host) {
-          setOfHostNames.push(host.hostName);
-        }, this);
+        if (temp) {
+          temp.hosts.forEach(function (host) {
+            setOfHostNames.push(host.hostName);
+          }, this);
+        }
         break;
       case 'storm.local.dir':
         temp = slaveComponentHostsInDB.findProperty('componentName', 'SUPERVISOR');

http://git-wip-us.apache.org/repos/asf/ambari/blob/27c239f1/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index cb44f36..01ac3b9 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -330,10 +330,10 @@ App.config = Em.Object.create({
       for (var index in properties) {
         var configsPropertyDef = preDefinedConfigs.filterProperty('name', index).findProperty('filename', filename);
         if (!configsPropertyDef) {
-          preDefinedConfigs.filterProperty('name', index).forEach(function (_preDefinedConfig) {
-            var isServiceInstalled = selectedServiceNames.contains(_preDefinedConfig.serviceName);
-            if (isServiceInstalled || _preDefinedConfig.serviceName === 'MISC') {
-              configsPropertyDef = _preDefinedConfig;
+          advancedConfigs.filterProperty('name', index).forEach(function (_advancedConfig) {
+            var isServiceInstalled = selectedServiceNames.contains(_advancedConfig.serviceName);
+            if (isServiceInstalled) {
+              configsPropertyDef = _advancedConfig;
             }
           }, this);
         }
@@ -377,7 +377,7 @@ App.config = Em.Object.create({
             serviceConfigObj.displayType = stringUtils.isSingleLine(serviceConfigObj.value) ? 'advanced' : 'multiLine';
           }
 
-          serviceConfigObj.displayName = configsPropertyDef ? configsPropertyDef.displayName : index;
+          serviceConfigObj.displayName = configsPropertyDef && configsPropertyDef.displayName ? configsPropertyDef.displayName : index;
           serviceConfigObj.options = configsPropertyDef ? configsPropertyDef.options : null;
           this.calculateConfigProperties(serviceConfigObj, isAdvanced, advancedConfigs);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/27c239f1/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 4b100af..435ce17 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1272,4 +1272,63 @@ describe('App.InstallerStep7Controller', function () {
     });
   });
 
+  describe('#setInstalledServiceConfigs', function () {
+
+    var controller = App.WizardStep7Controller.create({
+        installedServiceNames: ['HBASE', 'AMS']
+      }),
+      serviceConfigTags = [
+        {
+          siteName: 'hbase-site',
+          tagName: 'version1'
+        },
+        {
+          siteName: 'ams-hbase-site',
+          tagName: 'version1'
+        }
+      ],
+      configs = [
+        {
+          name: 'hbase.client.scanner.caching',
+          value: '1000',
+          serviceName: 'HBASE',
+          filename: 'hbase-site.xml'
+        },
+        {
+          name: 'hbase.client.scanner.caching',
+          value: '2000',
+          serviceName: 'AMS',
+          filename: 'ams-hbase-site.xml'
+        }
+      ],
+      configsByTags = [
+        {
+          type: 'hbase-site',
+          tag: 'version2',
+          properties: {
+            'hbase.client.scanner.caching': '1500'
+          }
+        },
+        {
+          type: 'ams-hbase-site',
+          tag: 'version2',
+          properties: {
+            'hbase.client.scanner.caching': '2500'
+          }
+        }
+      ],
+      installedServiceNames = ['HBASE', 'AMS'];
+
+    it('should handle properties with the same name', function () {
+      controller.setInstalledServiceConfigs(serviceConfigTags, configs, configsByTags, installedServiceNames);
+      var properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
+      expect(properties).to.have.length(2);
+      expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
+      expect(properties.findProperty('filename', 'hbase-site.xml').defaultValue).to.equal('1500');
+      expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
+      expect(properties.findProperty('filename', 'ams-hbase-site.xml').defaultValue).to.equal('2500');
+    });
+
+  });
+
 });