Repository: ambari
Updated Branches:
  refs/heads/trunk d1c4a93fe -> ebe04d4b8


AMBARI-5907. Usability: Do not allow user to install default mysql when using 
ambari mysql on same host.(xiwang)


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

Branch: refs/heads/trunk
Commit: ebe04d4b82131f32ca357f07b77f3f578abe5932
Parents: d1c4a93
Author: Xi Wang <[email protected]>
Authored: Tue May 27 17:25:06 2014 -0700
Committer: Xi Wang <[email protected]>
Committed: Wed May 28 18:29:03 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            |  4 +-
 .../app/controllers/wizard/step7_controller.js  | 63 +++++++++++++++++++-
 ambari-web/app/messages.js                      |  6 ++
 ambari-web/app/utils/ajax/ajax.js               |  9 +++
 4 files changed, 79 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ebe04d4b/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js 
b/ambari-web/app/controllers/wizard.js
index 05931f7c..f599b2d 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -145,7 +145,7 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, {
     return this.get('currentStep') == 10;
   }.property('currentStep'),
 
-  gotoStep: function (step) {
+  gotoStep: function (step, disableNaviWarning) {
     if (this.get('isStepDisabled').findProperty('step', step).get('value') !== 
false) {
       return false;
     }
@@ -159,7 +159,7 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, {
         localdb: App.db.data
       });
     }
-    if ((this.get('currentStep') - step) > 1) {
+    if ((this.get('currentStep') - step) > 1 && !disableNaviWarning) {
       App.ModalPopup.show({
         header: Em.I18n.t('installer.navigation.warning.header'),
         onPrimary: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebe04d4b/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 5de14f5..b07ca74 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -944,12 +944,73 @@ App.WizardStep7Controller = Em.Controller.extend({
   },
 
   /**
+    * Check whether hive New MySQL database is on the same host as Ambari 
server MySQL server
+    * @return {$.ajax|null}
+    * @method checkMySQLHost
+    */
+  checkMySQLHost: function () {
+    // get ambari database type and hostname
+    return App.ajax.send({
+      name: 'config.ambari.database.info',
+      sender: this,
+      success: 'getAmbariDatabaseSuccess'
+    });
+  },
+
+  /**
+   * Success callback for ambari database, get Ambari DB type and DB server 
hostname, then
+   * Check whether hive New MySQL database is on the same host as Ambari 
server MySQL server
+   * @param {object} data
+   * @method getAmbariDatabaseSuccess
+   */
+  getAmbariDatabaseSuccess: function (data) {
+    var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 
'HIVE').configs.findProperty('name', 'hivemetastore_host').value;
+    var ambariDBInfo = 
JSON.stringify(data.hostComponents[0].RootServiceHostComponents.properties);
+    this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && 
ambariDBInfo.indexOf(hiveDBHostname) > 0);
+  },
+
+  /**
    * Click-handler on Next button
    * @method submit
    */
   submit: function () {
     if (!this.get('isSubmitDisabled')) {
-      App.router.send('next');
+      var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 
'HIVE').configs.findProperty('name', 'hive_database').value;
+      if (hiveDBType == 'New MySQL Database') {
+        var self= this;
+        this.checkMySQLHost().done(function () {
+          if (self.get('mySQLServerConflict')) {
+            // error popup before you can proceed
+            return App.ModalPopup.show({
+              header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
+              bodyClass: Ember.View.extend({
+                template: Ember.Handlebars.compile( 
Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
+              }),
+              secondary: 
Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
+              primary: 
Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
+              onSecondary: function (){
+                var parent = this;
+                return App.ModalPopup.show({
+                  header: 
Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
+                  bodyClass: Ember.View.extend({
+                    template: Ember.Handlebars.compile( 
Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
+                  }),
+                  onPrimary: function (){
+                    this.hide();
+                    parent.hide();
+                    // go back to step 5: assign masters and disable default 
navigation warning
+                    App.router.get('installerController').gotoStep(5, true);
+                  }
+                });
+              }
+            });
+          } else {
+            App.router.send('next');
+          }
+        });
+      } else {
+        App.router.send('next');
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebe04d4b/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 33e8c9f..80b677e 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -598,6 +598,12 @@ Em.I18n.translations = {
   'installer.step7.popup.adjustedValue':'Adjusted Value',
   'installer.step7.popup.rddWarning.header':'Warning: disk space low on {0}',
   'installer.step7.popup.rddWarning.body':'A minimum of 16GB is recommended 
for the Ganglia Server logs but the disk mount "{0}" on {1} does not have 
enough space ({2} free). Go to the Misc tab and change Ganglia rrdcached base 
directory with more than 16GB of disk space. If you proceed without changing 
it, {1} will likely run out of disk space and become inoperable.',
+  'installer.step7.popup.mySQLWarning.header':'Error: New MySQL Database for 
Hive Conflict',
+  'installer.step7.popup.mySQLWarning.body':'You cannot install a \"New MySQL 
Database\" for Hive on the same host as the Ambari Server MySQL Server. Please 
go back to <b>Assign Masters</b> and reassign Hive to another host <b>OR</b> 
choose \"Existing MySQL Database\" option to specify the Database Credentials 
and URL for the Ambari Server MySQL Server instance. If you choose \"Existing 
MySQL Database\" option, you need to perform the Hive prerequisite steps to 
prepare the MySQL Server instance for Hive.',
+  'installer.step7.popup.mySQLWarning.button.gotostep5': 'Go to Assign 
Masters',
+  'installer.step7.popup.mySQLWarning.button.dismiss': 'Dismiss',
+  'installer.step7.popup.mySQLWarning.confirmation.header': 'Confirmation: Go 
to Assign Masters',
+  'installer.step7.popup.mySQLWarning.confirmation.body': 'You will be brought 
back to the \"Assign Masters\" step and will lose all your current 
customizations. Are you sure?',
 
   'installer.step8.header':'Review',
   'installer.step8.body':'Please review the configuration before installation',

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebe04d4b/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index 1b11ee1..0cf3937 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -357,6 +357,15 @@ var urls = {
       };
     }
   },
+  'config.ambari.database.info': {
+    'real': 
'/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
+    'mock': '',
+    'format': function() {
+      return {
+        async: false
+      };
+    }
+  },
   'config_groups.all_fields': {
     'real': '/clusters/{clusterName}/config_groups?fields=*',
     'mock': ''

Reply via email to