Browse Source

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

Xi Wang 11 years ago
parent
commit
ebe04d4b82

+ 2 - 2
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 () {

+ 62 - 1
ambari-web/app/controllers/wizard/step7_controller.js

@@ -943,13 +943,74 @@ App.WizardStep7Controller = Em.Controller.extend({
     miscConfigs = App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
   },
 
+  /**
+    * 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');
+      }
     }
   }
 

+ 6 - 0
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',

+ 9 - 0
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': ''