Explorar el Código

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).

Oleksandr Diachenko hace 9 años
padre
commit
746e90d1de

+ 1 - 16
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/common.py

@@ -91,22 +91,7 @@ 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:
     hdfs_client_dict["hadoop.security.authentication"] = "kerberos"

+ 42 - 0
ambari-web/app/controllers/wizard/step7_controller.js

@@ -688,6 +688,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);
+    }
     if (App.get('isKerberosEnabled') && this.get('wizardController.name') == 'addServiceController') {
       this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || []);
     }
@@ -793,6 +797,44 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     return stepConfigs;
   },
 
+  /**
+   * 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 nameService = configs.findProperty('id', 'dfs.nameservices__hdfs-site').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 = configs.findProperty('id', propertyName + '__hdfs-site');
+      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

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

@@ -1608,6 +1608,77 @@ describe('App.InstallerStep7Controller', function () {
     });
   });
 
+  describe('#addHawqConfigsOnNnHa', function () {
+    var configs = [
+      {
+        id: 'dfs.nameservices__hdfs-site',
+        description: 'dfs.nameservices__hdfs-site',
+        displayName: 'dfs.nameservices',
+        displayType: 'string',
+        name: 'dfs.nameservices',
+        value: 'haservice',
+        recommendedValue: 'haservice'
+      },
+      {
+        id: 'dfs.ha.namenodes.haservice__hdfs-site',
+        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'
+      },
+      {
+        id: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
+        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'
+      },
+      {
+        id: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
+        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'
+      },
+      {
+        id: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
+        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'
+      },
+      {
+        id: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
+        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);
+      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(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description);
+        expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName);
+        expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value);
+        expect(configs.findProperty('id', property.name + '__hdfs-client').recommendedValue).to.be.eql(property.recommendedValue);
+      });
+    });
+  });
+
   describe('#errorsCount', function () {
 
     it('should ignore configs with widgets (enhanced configs)', function () {