Sfoglia il codice sorgente

AMBARI-14599: Update hawq configs to remove hawq_standby_address_host on single node clusters (bhuvnesh2703 via jaoki)

Jun Aoki 9 anni fa
parent
commit
ff7e363f24

+ 26 - 11
ambari-web/app/controllers/wizard/step7_controller.js

@@ -690,21 +690,36 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     });
   },
 
+  /**
+   * Update hawq configuration depending on the state of the cluster
+   * @param {Array} configs
+   */
+  updateHawqConfigs: function (configs) {
+    if (this.get('wizardController.name') == 'addServiceController') {
+      if (App.get('isHaEnabled')) this.addHawqConfigsOnNnHa(configs);
+      if (App.get('isRMHaEnabled')) this.addHawqConfigsOnRMHa(configs);
+      if (App.get('isKerberosEnabled')) this.addHawqConfigsOnKerberizedCluster(configs);
+    }
+    if (App.get('isSingleNode')) this.removeHawqStandbyHostAddressConfig(configs);
+    return configs
+  },
+
+  /**
+   * Remove hawq_standby_address_host config from HAWQ configs
+   * @param {Array} configs
+   */
+  removeHawqStandbyHostAddressConfig: function(configs) {
+    var hawqStandbyAddressHostIndex = configs.indexOf(configs.findProperty('name', 'hawq_standby_address_host'));
+    if (hawqStandbyAddressHostIndex > -1) configs.removeAt(hawqStandbyAddressHostIndex) ;
+    return configs
+  },
+
   applyServicesConfigs: function (configs) {
     if (this.get('allSelectedServiceNames').contains('YARN')) {
       configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', []);
     }
-    // If HAWQ service is being added, add NN-HA/RM-HA/Kerberos related parameters to hdfs-client/yarn-client if applicable
-    if (this.get('wizardController.name') == 'addServiceController' && !this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
-      if (App.get('isHaEnabled')) {
-        this.addHawqConfigsOnNnHa(configs);
-      }
-      if (App.get('isRMHaEnabled')) {
-        this.addHawqConfigsOnRMHa(configs);
-      }
-      if (App.get('isKerberosEnabled')) {
-        this.addHawqConfigsOnKerberizedCluster(configs);
-      }
+    if (!this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
+      this.updateHawqConfigs(configs);
     }
     if (App.get('isKerberosEnabled') && this.get('wizardController.name') == 'addServiceController') {
       this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || []);

+ 35 - 0
ambari-web/test/controllers/wizard/step7_test.js

@@ -1165,6 +1165,41 @@ describe('App.InstallerStep7Controller', function () {
         }
       });
     });
+
+  });
+
+  describe('#updateHawqConfigs', function() {
+    var testHawqSiteConfigs = [
+      {
+        name: 'hawq_standby_address_host',
+        value: 'h2'
+      },
+      {
+        name: 'hawq_master_address_host',
+        value: 'h1'
+      }
+    ];
+    var oldHawqSiteLength = testHawqSiteConfigs.length;
+    it('hawq_standby_address_host should be removed on single node cluster', function() {
+      sinon.stub(App, 'get').withArgs('isSingleNode').returns(true);
+      var hawqSiteConfigs = testHawqSiteConfigs.slice();
+      var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
+      expect(updatedHawqSiteConfigs.length).to.be.eql(oldHawqSiteLength-1);
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.be.eql(undefined);
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.eql('h1');
+      App.get.restore()
+    });
+
+    it('hawq_standby_address_host should not be removed on multi node clusters', function() {
+      sinon.stub(App, 'get').withArgs('isSingleNode').returns(false);
+      var hawqSiteConfigs = testHawqSiteConfigs.slice();
+      var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
+      expect(updatedHawqSiteConfigs.length).to.be.eql(oldHawqSiteLength);
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.eql('h2');
+      expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.eql('h1');
+      App.get.restore();
+    });
+
   });
 
   describe('#_updateIsEditableFlagForConfig', function () {