浏览代码

AMBARI-6443. Add Service Wizard: Hive "Database host" config empty and disabled. (Buzhor Denys via alexantonenko)

Alex Antonenko 11 年之前
父节点
当前提交
3b62427a41

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

@@ -340,6 +340,16 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     App.config.loadServiceConfigGroupOverrides(allConfigs, this.loadedGroupToOverrideSiteToTagMap, this.get('configGroups'), this.onLoadOverrides, this);
   }.observes('selectedConfigGroup'),
 
+  checkDatabaseProperties: function (serviceConfig) {
+    if (!['OOZIE', 'HIVE'].contains(this.get('content.serviceName'))) return;
+    var configsToHide = ['oozie_hostname'];
+    configsToHide.forEach(function(configName) {
+      var property = serviceConfig.configs.findProperty('name', configName);
+      if (property) property.set('isVisible', false);
+    });
+  },
+
+
   onLoadOverrides: function (allConfigs) {
     var serviceName = this.get('content.serviceName');
     var advancedConfigs = this.get('advancedConfigs');
@@ -357,6 +367,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       this.setRecommendedDefaults(advancedConfigs).done(function () {
         self.loadConfigs(allConfigs, serviceConfig);
         self.checkOverrideProperty(serviceConfig);
+        self.checkDatabaseProperties(serviceConfig);
         self.get('stepConfigs').pushObject(serviceConfig);
         self.set('selectedService', self.get('stepConfigs').objectAt(0));
         self.checkForSecureConfig(self.get('selectedService'));
@@ -627,7 +638,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     });
     return dfd.promise();
   },
-
   /**
    * set isEditable property of config for admin
    * if default cfg group and not on the host config page
@@ -1199,6 +1209,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
    * @param globals
    */
   setOozieHostName: function (globals) {
+    var dbHostPropertyName = null;
     if (globals.someProperty('name', 'oozie_database')) {
       var oozieDb = globals.findProperty('name', 'oozie_database');
       if (oozieDb.value === 'New Derby Database') {
@@ -1226,7 +1237,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       } else if (oozieDb.value === 'Existing MySQL Database') {
         var existingMySqlHost = globals.findProperty('name', 'oozie_existing_mysql_host');
         if (existingMySqlHost) {
-          existingMySqlHost.name = 'oozie_hostname';
+          dbHostPropertyName = 'oozie_existing_mysql_host';
         }
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
@@ -1238,7 +1249,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       } else if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
         var existingPostgreSqlHost = globals.findProperty('name', 'oozie_existing_postgresql_host');
         if (existingPostgreSqlHost) {
-          existingPostgreSqlHost.name = 'oozie_hostname';
+          dbHostPropertyName = 'oozie_existing_postgresql_host';
         }
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
@@ -1250,7 +1261,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       else { //existing oracle database
         var existingOracleHost = globals.findProperty('name', 'oozie_existing_oracle_host');
         if (existingOracleHost) {
-          existingOracleHost.name = 'oozie_hostname';
+          dbHostPropertyName = 'oozie_existing_oracle_host';
         }
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
         globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
@@ -1260,6 +1271,12 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       }
 
     }
+
+    if (dbHostPropertyName) {
+      var oozieHostNameProperty = App.ServiceConfigProperty.create(App.config.get('preDefinedGlobalProperties').findProperty('name','oozie_hostname'));
+      oozieHostNameProperty.set('value', globals.findProperty('name', dbHostPropertyName).get('value'));
+      globals.pushObject(oozieHostNameProperty);
+    }
   },
 
   /**
@@ -1778,13 +1795,13 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
     if (serviceName === 'HIVE') {
       var hiveDb = globalConfigs.findProperty('name', 'hive_database').value;
-      if (['Existing MySQL Database', 'Existing Oracle Database'].contains(hiveDb)) {
+      if (['Existing MySQL Database', 'Existing Oracle Database', 'Existing PostgreSQL Database'].contains(hiveDb)) {
         globalConfigs.findProperty('name', 'hive_hostname').isVisible = true;
       }
     }
     if (serviceName === 'OOZIE') {
       var oozieDb = globalConfigs.findProperty('name', 'oozie_database').value;
-      if (['Existing MySQL Database', 'Existing Oracle Database'].contains(oozieDb)) {
+      if (['Existing MySQL Database', 'Existing Oracle Database', 'Existing PostgreSQL Database'].contains(oozieDb)) {
         globalConfigs.findProperty('name', 'oozie_hostname').isVisible = true;
       }
     }

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

@@ -819,6 +819,7 @@ App.WizardStep7Controller = Em.Controller.extend({
       }
     });
 
+    this.setServiceDatabaseConfigs(configs);
     //add user properties
     for (var name in configsMap) {
       configs.push(configMixin.addUserProperty({
@@ -838,7 +839,26 @@ App.WizardStep7Controller = Em.Controller.extend({
       }, false, []));
     }
   },
-
+  /**
+   * Check if Oozie or Hive use existing database then need
+   * to restore missed properties
+   *
+   * @param {Object[]} configs
+   **/
+  setServiceDatabaseConfigs: function(configs) {
+    var serviceNames = this.get('installedServiceNames').filter(function(serviceName) {
+      return ['OOZIE', 'HIVE'].contains(serviceName);
+    });
+    serviceNames.forEach(function(serviceName) {
+      var dbTypeConfig = configs.findProperty('name', serviceName.toLowerCase() + '_database');
+      if (!/existing/gi.test(dbTypeConfig.value)) return;
+      var dbHostName = serviceName.toLowerCase() + '_hostname';
+      var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby/gi)[0];
+      var existingDBConfig = configs.findProperty('name', serviceName.toLowerCase() + '_existing_' + database.toLowerCase() + '_host');
+      if (!existingDBConfig.value)
+        existingDBConfig.value = existingDBConfig.defaultValue = configs.findProperty('name', dbHostName).value;
+    }, this);
+  },
   /**
    * Add group ids to <code>groupsToDelete</code>
    * Also save <code>groupsToDelete</code> to local storage

+ 1 - 32
ambari-web/app/controllers/wizard/step8_controller.js

@@ -858,37 +858,6 @@ App.WizardStep8Controller = Em.Controller.extend({
       return this.submitProceed();
     }
   },
-
-  /**
-   * Update configurations for installed services.
-   * Do separated PUT-request for each siteName for each service
-   *
-   * @param {Array} configsToUpdate - configs need to update
-   * Format:
-   * <code>
-   *   [
-   *    {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n1', value: 'v1'},
-   *    {serviceName: 's2', id: 'site property', filename: 'f1.xml', name: 'n2', value: 'v2'},
-   *    {serviceName: 's2', id: '', filename: 'f2.xml', name: 'n3', value: 'v3'}
-   *   ]
-   * </code>
-   * @method updateConfigurations
-   */
-  updateConfigurations: function (configsToUpdate) {
-    var configurationController = App.router.get('mainServiceInfoConfigsController');
-    var serviceNames = configsToUpdate.mapProperty('serviceName').uniq();
-    serviceNames.forEach(function (serviceName) {
-      var configs = configsToUpdate.filterProperty('serviceName', serviceName);
-      configurationController.setNewTagNames(configs);
-      var tagName = configs.objectAt(0).newTagName;
-      var siteConfigs = configs.filterProperty('id', 'site property');
-      siteConfigs.mapProperty('filename').uniq().forEach(function (siteName) {
-        var formattedConfigs = configurationController.createSiteObj(siteName.replace(".xml", ""), tagName, configs.filterProperty('filename', siteName));
-        configurationController.doPUTClusterConfigurationSite(formattedConfigs);
-      });
-    });
-  },
-
   /**
    * Prepare <code>ajaxQueue</code> and start to execute it
    * @method submitProceed
@@ -1003,7 +972,7 @@ App.WizardStep8Controller = Em.Controller.extend({
   deleteClustersCallback: function (response, request, data) {
     if (data.isLast) {
       if (this.get('wizardController').getDBProperty('configsToUpdate')) {
-        this.updateConfigurations(this.get('wizardController').getDBProperty('configsToUpdate'));
+        $.extend(true, this.get('configs'), this.get('wizardController').getDBProperty('configsToUpdate'));
       }
       this.setLocalRepositories();
       this.createCluster();

+ 0 - 4
ambari-web/app/data/HDP2/global_properties.js

@@ -783,7 +783,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "displayType": "host",
       "isOverridable": false,
       "isRequiredByAgent": false,
@@ -1089,7 +1088,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "displayType": "host",
       "isVisible": false,
@@ -1104,7 +1102,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "displayType": "host",
       "isVisible": false,
@@ -1119,7 +1116,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "displayType": "host",
       "isVisible": false,

+ 14 - 20
ambari-web/app/data/global_properties.js

@@ -734,7 +734,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "displayType": "host",
       "isRequiredByAgent": false,
       "isOverridable": false,
@@ -750,7 +749,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "displayType": "host",
       "isOverridable": false,
       "isRequiredByAgent": false,
@@ -761,21 +759,20 @@ module.exports =
       "index": 3
     },
     {
-        "id": "puppet var",
-        "name": "hive_existing_postgresql_host",
-        "displayName": "Database Host",
-        "description": "Specify the host on which the existing database is hosted",
-        "defaultValue": "",
-        "isReconfigurable": false,
-        "displayType": "host",
-        "isOverridable": false,
-        "isRequiredByAgent": false,
-        "isVisible": false,
-        "isObserved": true,
-        "serviceName": "HIVE",
-        "category": "HIVE_METASTORE",
-        "index": 3
-      },
+      "id": "puppet var",
+      "name": "hive_existing_postgresql_host",
+      "displayName": "Database Host",
+      "description": "Specify the host on which the existing database is hosted",
+      "defaultValue": "",
+      "displayType": "host",
+      "isOverridable": false,
+      "isRequiredByAgent": false,
+      "isVisible": false,
+      "isObserved": true,
+      "serviceName": "HIVE",
+      "category": "HIVE_METASTORE",
+      "index": 3
+    },
     {
       "id": "puppet var",
       "name": "hive_ambari_host",
@@ -1021,7 +1018,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "displayType": "host",
       "isRequiredByAgent": false,
@@ -1037,7 +1033,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "displayType": "host",
       "isRequiredByAgent": false,
@@ -1053,7 +1048,6 @@ module.exports =
       "displayName": "Database Host",
       "description": "Specify the host on which the existing database is hosted",
       "defaultValue": "",
-      "isReconfigurable": false,
       "isOverridable": false,
       "isRequiredByAgent": false,
       "displayType": "host",

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

@@ -203,6 +203,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
   },
 
   configs: function () {
+    if (this.get('controller.name') == 'mainServiceInfoConfigsController') return this.get('categoryConfigsAll');
     return this.get('categoryConfigsAll').filterProperty('isObserved', true);
   }.property('categoryConfigsAll'),
 
@@ -735,6 +736,9 @@ App.CheckDBConnectionView = Ember.View.extend({
   pollInterval: 3000,
   /** @property {string} hostNameProperty - host name property based on service and database names **/
   hostNameProperty: function() {
+    if (!/wizard/i.test(this.get('controller.name')) && this.get('parentView.service.serviceName') === 'HIVE') {
+      return this.get('parentView.service.serviceName').toLowerCase() + '_hostname';
+    }
     return '{0}_existing_{1}_host'.format(this.get('parentView.service.serviceName').toLowerCase(), this.get('databaseName').toLowerCase());
   }.property('databaseName'),
   /** @property {boolean} isBtnDisabled - disable button on failed validation or active request **/
@@ -808,7 +812,8 @@ App.CheckDBConnectionView = Ember.View.extend({
     var properties = [].concat(this.get('requiredProperties'));
     properties.push(this.get('hostNameProperty'));
     properties.forEach(function(propertyName) {
-      if(!this.get('parentView.categoryConfigsAll').findProperty('name', propertyName).get('isValid')) isValid = false;
+      var property = this.get('parentView.categoryConfigsAll').findProperty('name', propertyName);
+      if(property && !property.get('isValid')) isValid = false;
     }, this);
     this.set('isValidationPassed', isValid);
   }.observes('parentView.categoryConfigsAll.@each.isValid', 'parentView.categoryConfigsAll.@each.value', 'databaseName'),