Repository: ambari Updated Branches: refs/heads/branch-2.2 c740cc432 -> 726860a64
AMBARI-14392. Move logic to ambari-web, for adding parameters to hdfs-client.xml for HAWQ when HAWQ is installed on NN HA cluster (mithmatt via odiachenko). Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/726860a6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/726860a6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/726860a6 Branch: refs/heads/branch-2.2 Commit: 726860a646f8a136c27740d09203b0da9668723a Parents: c740cc4 Author: Oleksandr Diachenko <[email protected]> Authored: Wed Dec 30 15:59:11 2015 -0800 Committer: Oleksandr Diachenko <[email protected]> Committed: Wed Dec 30 15:59:11 2015 -0800 ---------------------------------------------------------------------- .../HAWQ/2.0.0/package/scripts/common.py | 15 ---- .../app/controllers/wizard/step7_controller.js | 43 ++++++++++++ .../test/controllers/wizard/step7_test.js | 72 ++++++++++++++++++++ 3 files changed, 115 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/726860a6/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py index eed84ac..564af8c 100644 --- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py +++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py @@ -91,21 +91,6 @@ def __update_hdfs_client(): import params hdfs_client_dict = params.hdfs_client.copy() - dfs_nameservice = params.hdfs_site.get('dfs.nameservices') - - # Adds additional parameters required for HDFS HA, if HDFS HA is enabled - # Temporary logic, this logic will be moved to ambari-web to expose these parameters on UI once HDFS HA is enabled - if dfs_nameservice: - ha_namenodes = 'dfs.ha.namenodes.{0}'.format(dfs_nameservice) - ha_nn_list = [ha_nn.strip() for ha_nn in params.hdfs_site[ha_namenodes].split(',')] - required_keys = ('dfs.nameservices', ha_namenodes, - 'dfs.namenode.rpc-address.{0}.{1}'.format(dfs_nameservice, ha_nn_list[0]), - 'dfs.namenode.http-address.{0}.{1}'.format(dfs_nameservice, ha_nn_list[0]), - 'dfs.namenode.rpc-address.{0}.{1}'.format(dfs_nameservice, ha_nn_list[1]), - 'dfs.namenode.http-address.{0}.{1}'.format(dfs_nameservice, ha_nn_list[1])) - - for key in required_keys: - hdfs_client_dict[key] = params.hdfs_site[key] # security if params.security_enabled: http://git-wip-us.apache.org/repos/asf/ambari/blob/726860a6/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 ffb44bc..10afd29 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -703,6 +703,10 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E if (this.get('allSelectedServiceNames').contains('YARN')) { configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', []); } + // if HA is enabled and HAWQ is selected to be installed -> Add HAWQ related configs + if (this.get('wizardController.name') === 'addServiceController' && App.get('isHaEnabled') && this.get('allSelectedServiceNames').contains('HAWQ')) { + this.addHawqConfigsOnNnHa(configs); + } var dependedServices = ["STORM", "YARN"]; dependedServices.forEach(function (serviceName) { if (this.get('allSelectedServiceNames').contains(serviceName)) { @@ -836,6 +840,45 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E }, /** + * For Namenode HA, HAWQ service requires additional config parameters in hdfs-client.xml + * This method ensures that these additional parameters are added to hdfs-client.xml + * @param configs existing configs on cluster + * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml + * @private + */ + addHawqConfigsOnNnHa: function(configs) { + var hdfsSiteConfigs = configs.filterProperty('filename', 'hdfs-site.xml'); + var nameService = hdfsSiteConfigs.findProperty('name', 'dfs.nameservices').value; + var propertyNames = [ + 'dfs.nameservices', + 'dfs.ha.namenodes.' + nameService, + 'dfs.namenode.rpc-address.'+ nameService +'.nn1', + 'dfs.namenode.rpc-address.'+ nameService +'.nn2', + 'dfs.namenode.http-address.'+ nameService +'.nn1', + 'dfs.namenode.http-address.'+ nameService +'.nn2' + ]; + + propertyNames.forEach(function(propertyName, propertyIndex) { + var propertyFromHdfs = hdfsSiteConfigs.findProperty('name', propertyName); + var newProperty = App.config.createDefaultConfig(propertyName, 'HAWQ', 'hdfs-client.xml', true); + Em.setProperties(newProperty, { + description: propertyFromHdfs.description, + displayName: propertyFromHdfs.displayName, + displayType: 'string', + index: propertyIndex, + isOverridable: false, + isReconfigurable: false, + name: propertyFromHdfs.name, + value: propertyFromHdfs.value, + recommendedValue: propertyFromHdfs.recommendedValue + }); + + configs.push(App.ServiceConfigProperty.create(newProperty)); + }); + return configs; + }, + + /** * render configs, distribute them by service * and wrap each in ServiceConfigProperty object * @param configs http://git-wip-us.apache.org/repos/asf/ambari/blob/726860a6/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 06b08a9..88d8bae 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -1961,6 +1961,78 @@ describe('App.InstallerStep7Controller', function () { }); }); + describe('#addHawqConfigsOnNnHa', function () { + var configs = [ + { + filename: 'hdfs-site.xml', + description: 'dfs.nameservices__hdfs-site', + displayName: 'dfs.nameservices', + displayType: 'string', + name: 'dfs.nameservices', + value: 'haservice', + recommendedValue: 'haservice' + }, + { + filename: 'hdfs-site.xml', + description: 'dfs.ha.namenodes.haservice__hdfs-site', + displayName: 'dfs.ha.namenodes.haservice', + displayType: 'string', + name: 'dfs.ha.namenodes.haservice', + value: 'nn1,nn2', + recommendedValue: 'nn1,nn2' + }, + { + filename: 'hdfs-site.xml', + description: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site', + displayName: 'dfs.namenode.rpc-address.haservice.nn1', + displayType: 'string', + name: 'dfs.namenode.rpc-address.haservice.nn1', + value: 'c6401.ambari.apache.org:8020', + recommendedValue: 'c6401.ambari.apache.org:8020' + }, + { + filename: 'hdfs-site.xml', + description: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site', + displayName: 'dfs.namenode.rpc-address.haservice.nn2', + displayType: 'string', + name: 'dfs.namenode.rpc-address.haservice.nn2', + value: 'c6402.ambari.apache.org:8020', + recommendedValue: 'c6402.ambari.apache.org:8020' + }, + { + filename: 'hdfs-site.xml', + description: 'dfs.namenode.http-address.haservice.nn1__hdfs-site', + displayName: 'dfs.namenode.http-address.haservice.nn1', + displayType: 'string', + name: 'dfs.namenode.http-address.haservice.nn1', + value: 'c6401.ambari.apache.org:50070', + recommendedValue: 'c6401.ambari.apache.org:50070' + }, + { + filename: 'hdfs-site.xml', + description: 'dfs.namenode.http-address.haservice.nn2__hdfs-site', + displayName: 'dfs.namenode.http-address.haservice.nn2', + displayType: 'string', + name: 'dfs.namenode.http-address.haservice.nn2', + value: 'c6402.ambari.apache.org:50070', + recommendedValue: 'c6402.ambari.apache.org:50070' + } + ]; + + it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() { + var oldConfigs = configs.slice(); + installerStep7Controller.addHawqConfigsOnNnHa(configs); + var hdfsClientConfigs = configs.filterProperty('filename', 'hdfs-client.xml'); + oldConfigs.forEach(function(property){ + // find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property's attribute value in hdfs-site + expect(hdfsClientConfigs.findProperty('name', property.name).description).to.be.eql(property.description); + expect(hdfsClientConfigs.findProperty('name', property.name).displayName).to.be.eql(property.displayName); + expect(hdfsClientConfigs.findProperty('name', property.name).value).to.be.eql(property.value); + expect(hdfsClientConfigs.findProperty('name', property.name).recommendedValue).to.be.eql(property.recommendedValue); + }); + }); + }); + describe('#errorsCount', function () { it('should ignore configs with widgets (enhanced configs)', function () {
