You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/07/09 22:08:58 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 eac111944 -> ffb702b25


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


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

Branch: refs/heads/branch-1.6.1
Commit: ffb702b252a8b979529864ec5579465a122060b5
Parents: eac1119
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Jul 9 23:05:13 2014 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Jul 9 23:05:13 2014 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 29 +++++++++++----
 .../app/controllers/wizard/step7_controller.js  | 22 +++++++++++-
 .../app/controllers/wizard/step8_controller.js  | 33 +----------------
 ambari-web/app/data/HDP2/global_properties.js   |  6 ----
 ambari-web/app/data/global_properties.js        | 38 +++++++++-----------
 ambari-web/app/views/wizard/controls_view.js    |  7 +++-
 6 files changed, 67 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/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 c137e5c..c985389 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -341,6 +341,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');
@@ -358,6 +368,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'));
@@ -610,7 +621,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
     return serviceConfigProperty;
   },
-
   /**
    * trigger addOverrideProperty
    * @param {Object} componentConfig
@@ -1237,6 +1247,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') {
@@ -1264,7 +1275,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'));
@@ -1276,7 +1287,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'));
@@ -1288,7 +1299,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'));
@@ -1298,6 +1309,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);
+    }
   },
 
   /**
@@ -1816,13 +1833,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;
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/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 d59c1fd..833c672 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -816,6 +816,7 @@ App.WizardStep7Controller = Em.Controller.extend({
       }
     });
 
+    this.setServiceDatabaseConfigs(configs);
     //add user properties
     for (var name in configsMap) {
       configs.push(configMixin.addUserProperty({
@@ -835,7 +836,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

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/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 4c97e41..de3ad48 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -809,37 +809,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
@@ -887,7 +856,7 @@ App.WizardStep8Controller = Em.Controller.extend({
       this.deleteClusters(this.getExistingClusterNames());
     }
     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();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/ambari-web/app/data/HDP2/global_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/global_properties.js b/ambari-web/app/data/HDP2/global_properties.js
index f4868ca..f30ce58 100644
--- a/ambari-web/app/data/HDP2/global_properties.js
+++ b/ambari-web/app/data/HDP2/global_properties.js
@@ -777,7 +777,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,
@@ -793,7 +792,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,
@@ -809,7 +807,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,
@@ -1127,7 +1124,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,
@@ -1142,7 +1138,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,
@@ -1157,7 +1152,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,

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/ambari-web/app/data/global_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/global_properties.js b/ambari-web/app/data/global_properties.js
index 4812eb2..bb5cf2a 100644
--- a/ambari-web/app/data/global_properties.js
+++ b/ambari-web/app/data/global_properties.js
@@ -696,8 +696,8 @@ module.exports =
         },
         {
           displayName: 'Existing PostgreSQL Database',
-          foreignKeys: ['hive_existing_postgresql_database', 'hive_existing_postgresql_host'],
-          },
+          foreignKeys: ['hive_existing_postgresql_database', 'hive_existing_postgresql_host']
+        },
         {
           displayName: 'Existing Oracle Database',
           foreignKeys: ['hive_existing_oracle_database', 'hive_existing_oracle_host'],
@@ -735,7 +735,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,
@@ -751,7 +750,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,
@@ -762,21 +760,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",
@@ -1034,7 +1031,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,
@@ -1050,7 +1046,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,
@@ -1066,7 +1061,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",

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb702b2/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 031d887..8fb971a 100644
--- a/ambari-web/app/views/wizard/controls_view.js
+++ b/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'),