Repository: ambari
Updated Branches:
  refs/heads/trunk f873b147a -> 1be4506a4


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1be4506a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1be4506a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1be4506a

Branch: refs/heads/trunk
Commit: 1be4506a460e2c7a228970a512ba8639c4cf4fd2
Parents: f873b14
Author: Jun Aoki <ja...@apache.org>
Authored: Thu Oct 16 13:32:26 2014 -0700
Committer: Jun Aoki <ja...@apache.org>
Committed: Thu Oct 16 13:32:26 2014 -0700

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  2 +-
 .../app/controllers/wizard/step7_controller.js  |  6 +-
 .../app/controllers/wizard/step8_controller.js  | 12 ++++
 ambari-web/app/messages.js                      |  3 +-
 .../app/models/stack_service_component.js       |  2 +-
 ambari-web/app/views/wizard/controls_view.js    |  4 +-
 .../test/controllers/wizard/step8_test.js       | 61 +++++++++++++-------
 .../test/models/stack_service_component_test.js | 14 ++++-
 8 files changed, 75 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js 
b/ambari-web/app/controllers/main/service/info/configs.js
index c676098..79c11b0 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/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';

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/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 c6ffc3f..44d0a4e 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/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;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index 688f7ce..29e3cd6 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/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');
       }
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 67eed85..e549629 100644
--- a/ambari-web/app/messages.js
+++ b/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',

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/app/models/stack_service_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_service_component.js 
b/ambari-web/app/models/stack_service_component.js
index 5e9c2e9..d88f02a 100644
--- a/ambari-web/app/models/stack_service_component.js
+++ b/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'),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/app/views/wizard/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/controls_view.js 
b/ambari-web/app/views/wizard/controls_view.js
index 198e4a8..ae9f721 100644
--- a/ambari-web/app/views/wizard/controls_view.js
+++ b/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':

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js 
b/ambari-web/test/controllers/wizard/step8_test.js
index 7eed8e1..087badc 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -621,6 +621,13 @@ describe('App.WizardStep8Controller', function () {
         },
         {
           serviceConfigProperties: [
+            {name: 'hive_database', value: 'New PostgreSQL Database'}
+          ],
+          m: 'New PostgreSQL Database',
+          e: 'Postgres (New Database)'
+        },
+        {
+          serviceConfigProperties: [
             {name: 'hive_database', value: 'Existing MySQL Database'},
             {name: 'hive_existing_mysql_database', value: 'dbname'}
           ],
@@ -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');
+
       });
 
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1be4506a/ambari-web/test/models/stack_service_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/stack_service_component_test.js 
b/ambari-web/test/models/stack_service_component_test.js
index aadd818..c6ab457 100644
--- a/ambari-web/test/models/stack_service_component_test.js
+++ b/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() {

Reply via email to