Browse Source

AMBARI-7352 Support create new PostgreSQL database for hive metastore when deploy hive.(adenisso via jaoki)

Jun Aoki 10 years ago
parent
commit
1be4506a46

+ 1 - 1
ambari-web/app/controllers/main/service/info/configs.js

@@ -1668,7 +1668,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   setHiveHostName: function (configs) {
     if (configs.someProperty('name', 'hive_database')) {
       var hiveDb = configs.findProperty('name', 'hive_database');
-      if (hiveDb.value === 'New MySQL Database') {
+      if (hiveDb.value === 'New MySQL Database' || hiveDb.value === 'New PostgreSQL Database') {
         var ambariHost = configs.findProperty('name', 'hive_ambari_host');
         if (ambariHost) {
           ambariHost.name = 'hive_hostname';

+ 3 - 3
ambari-web/app/controllers/wizard/step7_controller.js

@@ -1288,11 +1288,11 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
     var configMap = [
       {
         serviceName: 'OOZIE',
-        ignored: Em.I18n.t('installer.step7.oozie.database.new')
+        ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
       },
       {
         serviceName: 'HIVE',
-        ignored: Em.I18n.t('installer.step7.hive.database.new')
+        ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
       }
     ];
     configMap.forEach(function (config) {
@@ -1301,7 +1301,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
       if (service && service.get('isSelected') && !service.get('isInstalled')) {
         var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
         var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
-        if (serviceDatabase !== config.ignored) {
+        if (!config.ignored.contains(serviceDatabase)) {
           var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
           if (!filledProperties || App.isEmptyObject(filledProperties)) {
             isConnectionNotTested = true;

+ 12 - 0
ambari-web/app/controllers/wizard/step8_controller.js

@@ -246,6 +246,14 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
           hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
             'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
           break;
+        case 'New PostgreSQL Database':
+          if (configs.someProperty('name', 'hive_ambari_host')) {
+            configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
+            hiveDbType.value = 'postgres';
+          }
+          hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
+            'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
+          break;
         case 'Existing MySQL Database':
           configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
           hiveDbType.value = 'mysql';
@@ -723,6 +731,8 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
       hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
     if (hiveDb.value === 'New MySQL Database') {
       return 'MySQL (New Database)';
+    } else if (hiveDb.value === 'New PostgreSQL Database') {
+      return 'Postgres (New Database)';
     }
     else {
       if (hiveDb.value === 'Existing MySQL Database') {
@@ -1298,6 +1308,8 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
       var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
       if (hiveDb.value == "New MySQL Database") {
         this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
+      } else if (hiveDb.value === "New PostgreSQL Database") {
+        this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
       }
     }
   },

+ 2 - 1
ambari-web/app/messages.js

@@ -660,7 +660,8 @@ Em.I18n.translations = {
   'installer.step7.popup.validation.warning.header': 'Configurations',
   'installer.step7.popup.validation.warning.body': 'Some service configurations are not configured properly. We recommend you review and change the highlighted configuration values. Are you sure you want to proceed without correcting configurations?',
   'installer.step7.oozie.database.new': 'New Derby Database',
-  'installer.step7.hive.database.new': 'New MySQL Database',
+  'installer.step7.hive.database.new.mysql': 'New MySQL Database',
+  'installer.step7.hive.database.new.postgres': 'New PostgreSQL Database',
 
   'installer.step8.header':'Review',
   'installer.step8.body':'Please review the configuration before installation',

+ 1 - 1
ambari-web/app/models/stack_service_component.js

@@ -109,7 +109,7 @@ App.StackServiceComponent = DS.Model.extend({
   /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/
   isShownOnInstallerAssignMasterPage: function() {
     var component = this.get('componentName');
-    var mastersNotShown = ['MYSQL_SERVER'];
+    var mastersNotShown = ['MYSQL_SERVER', 'POSTGRESQL_SERVER'];
     return this.get('isMaster') && !mastersNotShown.contains(component);
   }.property('isMaster','componentName'),
 

+ 3 - 1
ambari-web/app/views/wizard/controls_view.js

@@ -216,7 +216,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
   didInsertElement: function () {
     // on page render, automatically populate JDBC URLs only for default database settings
     // so as to not lose the user's customizations on these fields
-    if (['addServiceController', 'installerController'].contains(App.clusterStatus.wizardControllerName) && ['New MySQL Database', 'New Derby Database'].contains(this.get('serviceConfig.value'))) {
+    if (['addServiceController', 'installerController'].contains(App.clusterStatus.wizardControllerName) && ['New PostgreSQL Database', 'New MySQL Database', 'New Derby Database'].contains(this.get('serviceConfig.value'))) {
       this.onOptionsChange();
     }
   },
@@ -242,6 +242,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
               connectionUrl.set('value', "jdbc:mysql://" + this.get('hostName') + "/" + this.get('databaseName') + "?createDatabaseIfNotExist=true");
               dbClass.set('value', "com.mysql.jdbc.Driver");
               break;
+            case 'New PostgreSQL Database':
             case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
               connectionUrl.set('value', "jdbc:postgresql://" + this.get('hostName') + ":5432/" + this.get('databaseName'));
               dbClass.set('value', "org.postgresql.Driver");
@@ -297,6 +298,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
     if (this.get('serviceConfig.serviceName') === 'HIVE') {
       switch (value) {
         case 'New MySQL Database':
+        case 'New PostgreSQL Database':
           hostname = this.get('categoryConfigsAll').findProperty('name', 'hive_ambari_host');
           break;
         case 'Existing MySQL Database':

+ 40 - 21
ambari-web/test/controllers/wizard/step8_test.js

@@ -619,6 +619,13 @@ describe('App.WizardStep8Controller', function () {
           m: 'New MySQL Database',
           e: 'MySQL (New Database)'
         },
+        {
+          serviceConfigProperties: [
+            {name: 'hive_database', value: 'New PostgreSQL Database'}
+          ],
+          m: 'New PostgreSQL Database',
+          e: 'Postgres (New Database)'
+        },
         {
           serviceConfigProperties: [
             {name: 'hive_database', value: 'Existing MySQL Database'},
@@ -1414,28 +1421,40 @@ describe('App.WizardStep8Controller', function () {
         expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
       });
 
-      it('should add MYSQL_SERVER', function() {
-        installerStep8Controller.reopen({
-          getRegisteredHosts: function() {
-            return [{hostName: 'h1'}, {hostName: 'h2'}];
-          },
-          content: {
-            masterComponentHosts: [
-              {component: 'HIVE_SERVER', hostName: 'h1'},
-              {component: 'HIVE_SERVER', hostName: 'h2'}
-            ],
-            services: [
-              Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
-            ],
-            serviceConfigProperties: [
-              {name: 'hive_database', value: 'New MySQL Database'}
-            ]
-          }
+      var newDatabases = [
+        {name: 'New MySQL Database',
+         component: 'MYSQL_SERVER'
+        },
+        {name: 'New PostgreSQL Database',
+          component: 'POSTGRESQL_SERVER'
+        },
+      ];
+
+      newDatabases.forEach(function (db) {
+        it('should add {0}'.format(db.component), function() {
+          installerStep8Controller.reopen({
+            getRegisteredHosts: function() {
+              return [{hostName: 'h1'}, {hostName: 'h2'}];
+            },
+            content: {
+              masterComponentHosts: [
+                {component: 'HIVE_SERVER', hostName: 'h1'},
+                {component: 'HIVE_SERVER', hostName: 'h2'}
+              ],
+              services: [
+                Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
+              ],
+              serviceConfigProperties: [
+                {name: 'hive_database', value: db.name}
+              ]
+            }
+          });
+          installerStep8Controller.createAdditionalHostComponents();
+          expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
+          expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
+          expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
         });
-        installerStep8Controller.createAdditionalHostComponents();
-        expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('MYSQL_SERVER');
+
       });
 
     });

+ 13 - 1
ambari-web/test/models/stack_service_component_test.js

@@ -290,7 +290,19 @@ var componentPropertiesValidationTests = [
       isOtherComponentCoHosted: false,
       isCoHostedComponent: false
     }
-  }
+  },
+  {
+    componentName: 'POSTGRESQL_SERVER',
+    expected: {
+      isShownOnInstallerAssignMasterPage: false,
+    }
+  },
+  {
+    componentName: 'MYSQL_SERVER',
+    expected: {
+      isShownOnInstallerAssignMasterPage: false,
+    }
+  },
 ];
 
 describe('App.StackServiceComponent', function() {