瀏覽代碼

AMBARI-7747. Add Service Wizard: Storm *.childopts configs doesn't properly setup. (Buzhor Denys via onechiporenko)

Oleg Nechiporenko 10 年之前
父節點
當前提交
c826bcf064

+ 8 - 4
ambari-web/app/controllers/wizard/step7_controller.js

@@ -685,10 +685,14 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
     // if Ganglia selected or installed, set ganglia host to configs
     if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
     if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
-      hosts = this.get('wizardController').getDBProperty('hosts');
-      gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
-      for (var hostName in hosts) {
-        if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
+      if (this.get('wizardController.name') === 'addServiceController') {
+        gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
+      } else {
+        hosts = this.get('wizardController').getDBProperty('hosts');
+        gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
+        for (var hostName in hosts) {
+          if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
+        }
       }
       dependentConfigs.forEach(function (configName) {
         var config = configs.findProperty('name', configName);

+ 29 - 1
ambari-web/test/controllers/wizard/step7_test.js

@@ -389,6 +389,34 @@ describe('App.InstallerStep7Controller', function () {
       });
     });
 
+    it('should replace host name for *.childopts properties if Ganglia is in installedServiceNames for Add Service Wizard', function () {
+      var installedServiceNames = ['GANGLIA'],
+        configs = [
+          {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''},
+          {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''},
+          {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''}
+        ],
+        expected = [
+          {name: 'nimbus.childopts', value: '.jar=host=realhost1', defaultValue: '.jar=host=realhost1', forceUpdate: true},
+          {name: 'supervisor.childopts', value: '.jar=host=realhost1', defaultValue: '.jar=host=realhost1', forceUpdate: true},
+          {name: 'worker.childopts', value: '.jar=host=realhost1', defaultValue: '.jar=host=realhost1', forceUpdate: true}
+        ];
+      installerStep7Controller.reopen({
+        installedServiceNames: installedServiceNames,
+        wizardController: Em.Object.create({
+          name: 'addServiceController',
+          masterComponentHosts: [{component: 'GANGLIA_SERVER', hostName: 'realhost1'}],
+          getDBProperty: function (k) {
+            return this.get(k);
+          }
+        })
+      });
+      installerStep7Controller.resolveStormConfigs(configs);
+      Em.keys(expected[0]).forEach(function (k) {
+        expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
+      });
+    });
+
   });
 
   describe('#resolveServiceDependencyConfigs', function () {
@@ -1151,4 +1179,4 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
-});
+});