瀏覽代碼

AMBARI-12830 SQLA: UI fixes for oozie SQLA db. (ababiichuk)

aBabiichuk 10 年之前
父節點
當前提交
98727e22cf

+ 15 - 77
ambari-web/app/controllers/wizard/step8_controller.js

@@ -611,46 +611,25 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
         hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
         hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
   },
   },
 
 
+  loadHiveDbValue: function() {
+    return this.loadDbValue('HIVE');
+  },
+
+  loadOozieDbValue: function() {
+    return this.loadDbValue('OOZIE');
+  },
+
   /**
   /**
    * Set displayed Hive DB value based on DB type
    * Set displayed Hive DB value based on DB type
    * @method loadHiveDbValue
    * @method loadHiveDbValue
    */
    */
-  loadHiveDbValue: function () {
-    var db, serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
-      hiveDb = serviceConfigProperties.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') {
-        db = serviceConfigProperties.findProperty('name', 'hive_existing_mysql_database');
-        return db.value + ' (' + hiveDb.value + ')';
-      }
-      else {
-        if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
-          db = serviceConfigProperties.findProperty('name', 'hive_existing_postgresql_database');
-          return db.value + ' (' + hiveDb.value + ')';
-        }
-        else {
-          if (hiveDb.value === 'Existing MSSQL Server database with SQL authentication') {
-            db = serviceConfigProperties.findProperty('name', 'hive_existing_mssql_server_database');
-            return db.value + ' (' + hiveDb.value + ')';
-          }
-          else {
-            if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
-              db = serviceConfigProperties.findProperty('name', 'hive_existing_mssql_server_2_database');
-              return db.value + ' (' + hiveDb.value + ')';
-            }
-            else {
-              // existing oracle database
-              db = serviceConfigProperties.findProperty('name', 'hive_existing_oracle_database');
-              return db.value + ' (' + hiveDb.value + ')';
-            }
-          }
-        }
-      }
+  loadDbValue: function (serviceName) {
+    var dbFull = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', serviceName.toLowerCase() + '_database'),
+      db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', serviceName.toLowerCase() + '_ambari_database');
+    if (db && dbFull) {
+      return db.value + ' (' + dbFull.value + ')';
+    } else {
+      return '';
     }
     }
   },
   },
 
 
@@ -684,47 +663,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
     serverComponent.set('component_value', zkHostNames + hostSuffix);
     serverComponent.set('component_value', zkHostNames + hostSuffix);
   },
   },
 
 
-  /**
-   * Set displayed Oozie DB value based on DB type
-   * @method loadOozieDbValue
-   */
-  loadOozieDbValue: function () {
-    var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
-    if (oozieDb.value === 'New Derby Database') {
-      db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
-      return db.value + ' (' + oozieDb.value + ')';
-    }
-    else {
-      if (oozieDb.value === 'Existing MySQL Database') {
-        db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
-        return db.value + ' (' + oozieDb.value + ')';
-      }
-      else {
-        if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
-          db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
-          return db.value + ' (' + oozieDb.value + ')';
-        }
-        else {
-          if (oozieDb.value === 'Existing MSSQL Server database with SQL authentication') {
-            db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
-            return db.value + ' (' + oozieDb.value + ')';
-          }
-          else {
-            if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
-              db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
-              return db.value + ' (' + oozieDb.value + ')';
-            }
-            else {
-              // existing oracle database
-              db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
-              return db.value + ' (' + oozieDb.value + ')';
-            }
-          }
-        }
-      }
-    }
-  },
-
   /**
   /**
    * Onclick handler for <code>next</code> button
    * Onclick handler for <code>next</code> button
    * @method submit
    * @method submit

+ 5 - 5
ambari-web/app/data/db_properties_info.js

@@ -103,16 +103,16 @@ module.exports = {
       'db_type': 'mssql'
       'db_type': 'mssql'
     },
     },
     'MSSQL2': {
     'MSSQL2': {
-      'connection_url': 'jdbc:sqlserver://{0};databaseName={1}',
+      'connection_url': 'jdbc:sqlserver://{0};databaseName={1};integratedSecurity=true',
       'driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
       'driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
-      'sql_jar_connector': 'jdbc:sqlserver://{0};databaseName={1};integratedSecurity=true',
+      'sql_jar_connector': '/usr/share/java/sqljdbc4.jar',
       'db_type': 'mssql'
       'db_type': 'mssql'
     },
     },
     'SQLA': {
     'SQLA': {
-      'connection_url': 'jdbc:sqlanywhere:database={1};host={0}',
+      'connection_url': 'jdbc:sqlanywhere:uid={2};pwd={3};database={1};host={0}',
       'driver': 'sap.jdbc4.sqlanywhere.IDriver',
       'driver': 'sap.jdbc4.sqlanywhere.IDriver',
-      'sql_jar_connector': '/path_to_driver/sajdbc4.jar',
-      'db_type': 'sqla'
+      'sql_jar_connector': '/path_to_driver/sqla-client-jdbc.tar.gz',
+      'db_type': 'sqlanywhere'
     },
     },
     'DERBY': {
     'DERBY': {
       'connection_url': 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',
       'connection_url': 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',

+ 1 - 1
ambari-web/app/messages.js

@@ -1772,7 +1772,7 @@ Em.I18n.translations = {
   'services.service.config.kdc.btn.idle': 'Test KDC Connection',
   'services.service.config.kdc.btn.idle': 'Test KDC Connection',
   'services.service.config.database.btn.connecting': 'Connecting...',
   'services.service.config.database.btn.connecting': 'Connecting...',
   'services.service.config.database.msg.jdbcSetup': 'Be sure you have run:<br/>' +
   'services.service.config.database.msg.jdbcSetup': 'Be sure you have run:<br/>' +
-    '<b>ambari-server setup --jdbc-db={0} --jdbc-driver=/path/to/{1}/driver.jar</b> ' +
+    '<b>ambari-server setup --jdbc-db={0} --jdbc-driver=/path/to/{0}/{1}</b> ' +
     'on the Ambari Server host to make the JDBC driver available and to enable testing the database connection.',
     'on the Ambari Server host to make the JDBC driver available and to enable testing the database connection.',
 
 
   'services.service.config.configHistory.configGroup': 'Config Group',
   'services.service.config.configHistory.configGroup': 'Config Group',

+ 25 - 5
ambari-web/app/views/common/controls_view.js

@@ -508,10 +508,10 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
         this.get('hostNameProperty').set('isEditable', true);
         this.get('hostNameProperty').set('isEditable', true);
       }
       }
       this.setRequiredProperties(['driver', 'sql_jar_connector', 'db_type']);
       this.setRequiredProperties(['driver', 'sql_jar_connector', 'db_type']);
-      this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'));
+      this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'), this.get('userProperty.value'), this.get('passwordProperty.value'));
       this.handleSpecialUserPassProperties();
       this.handleSpecialUserPassProperties();
     }
     }
-  }.observes('databaseProperty.value', 'hostNameProperty.value', 'serviceConfig.value'),
+  }.observes('databaseProperty.value', 'hostNameProperty.value', 'serviceConfig.value', 'userProperty.value', 'passwordProperty.value'),
 
 
   nameBinding: 'serviceConfig.radioName',
   nameBinding: 'serviceConfig.radioName',
 
 
@@ -539,6 +539,22 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
     return host;
     return host;
   }.property('serviceConfig.serviceName', 'serviceConfig.value'),
   }.property('serviceConfig.serviceName', 'serviceConfig.value'),
 
 
+  /**
+   * Just property object for database name
+   * @type {App.ServiceConfigProperty}
+   */
+  userProperty: function () {
+    return this.getPropertyByType('user_name');
+  }.property('serviceConfig.serviceName'),
+
+  /**
+   * Just property object for database name
+   * @type {App.ServiceConfigProperty}
+   */
+  passwordProperty: function () {
+    return this.getPropertyByType('password');
+  }.property('serviceConfig.serviceName'),
+
   /**
   /**
    *
    *
    * @param propertyType
    * @param propertyType
@@ -569,13 +585,15 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
    * and sets hostName as dbName in appropriate position of <code>connection_url<code> string
    * and sets hostName as dbName in appropriate position of <code>connection_url<code> string
    * @param {String} hostName
    * @param {String} hostName
    * @param {String} dbName
    * @param {String} dbName
+   * @param {String} user
+   * @param {String} password
    * @method setConnectionUrl
    * @method setConnectionUrl
    */
    */
-  setConnectionUrl: function(hostName, dbName) {
+  setConnectionUrl: function(hostName, dbName, user, password) {
     var connectionUrlProperty = this.getPropertyByType('connection_url');
     var connectionUrlProperty = this.getPropertyByType('connection_url');
     var connectionUrlTemplate = this.getDefaultPropertyValue('connection_url');
     var connectionUrlTemplate = this.getDefaultPropertyValue('connection_url');
     try {
     try {
-      var connectionUrlValue = connectionUrlTemplate.format(hostName, dbName);
+      var connectionUrlValue = connectionUrlTemplate.format(hostName, dbName, user, password);
       connectionUrlProperty.set('value', connectionUrlValue);
       connectionUrlProperty.set('value', connectionUrlValue);
       connectionUrlProperty.set('recommendedValue', connectionUrlValue);
       connectionUrlProperty.set('recommendedValue', connectionUrlValue);
     } catch(e) {
     } catch(e) {
@@ -657,10 +675,12 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
       propertyAppendTo2.set('additionalView', null);
       propertyAppendTo2.set('additionalView', null);
     }
     }
     var shouldAdditionalViewsBeSet = currentDB && checkDatabase && handledProperties.contains(this.get('serviceConfig.name')),
     var shouldAdditionalViewsBeSet = currentDB && checkDatabase && handledProperties.contains(this.get('serviceConfig.name')),
+      driver = this.getDefaultPropertyValue('sql_jar_connector') ? this.getDefaultPropertyValue('sql_jar_connector').split("/").pop() : 'driver.jar',
+      dbType = this.getDefaultPropertyValue('db_type'),
       additionalView1 = shouldAdditionalViewsBeSet ? App.CheckDBConnectionView.extend({databaseName: currentDB}) : null,
       additionalView1 = shouldAdditionalViewsBeSet ? App.CheckDBConnectionView.extend({databaseName: currentDB}) : null,
       additionalView2 = shouldAdditionalViewsBeSet ? Ember.View.extend({
       additionalView2 = shouldAdditionalViewsBeSet ? Ember.View.extend({
         template: Ember.Handlebars.compile('<div class="alert">{{{view.message}}}</div>'),
         template: Ember.Handlebars.compile('<div class="alert">{{{view.message}}}</div>'),
-        message: Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(currentDBType.toLowerCase(), currentDBType.toLowerCase())
+        message: Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(dbType, driver)
       }) : null;
       }) : null;
     if (propertyAppendTo1) {
     if (propertyAppendTo1) {
       Em.run.next(function () {
       Em.run.next(function () {

+ 0 - 124
ambari-web/test/controllers/wizard/step8_test.js

@@ -1281,79 +1281,6 @@ describe('App.WizardStep8Controller', function () {
     });
     });
   });
   });
 
 
-  describe('#loadHiveDbValue', function() {
-    beforeEach(function() {
-      installerStep8Controller.set('wizardController', Em.Object.create({
-        getDBProperty: Em.K
-      }));
-    });
-    Em.A([
-        {
-          serviceConfigProperties: [
-            {name: 'hive_database', value: 'New MySQL Database'}
-          ],
-          m: 'New MySQL Database',
-          e: 'MySQL (New Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'hive_database', value: 'Existing MSSQL Server database with SQL authentication'},
-            {name: 'hive_existing_mssql_server_database', value: 'dbname'}
-          ],
-          m: 'Existing MSSQL Server database with SQL authentication',
-          e: 'dbname (Existing MSSQL Server database with SQL authentication)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'hive_database', value: 'Existing MSSQL Server database with integrated authentication'},
-            {name: 'hive_existing_mssql_server_2_database', value: 'dbname'}
-          ],
-          m: 'Existing MSSQL Server database with integrated authentication',
-          e: 'dbname (Existing MSSQL Server database with integrated authentication)'
-        },
-        {
-          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'}
-          ],
-          m: 'Existing MySQL Database',
-          e: 'dbname (Existing MySQL Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'hive_database', value: 'Existing PostgreSQL Database'},
-            {name: 'hive_existing_postgresql_database', value: 'dbname'}
-          ],
-          m: 'Existing PostgreSQL Database',
-          e: 'dbname (Existing PostgreSQL Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'hive_database', value: 'Existing Oracle Database'},
-            {name: 'hive_existing_oracle_database', value: 'dbname'}
-          ],
-          m: 'Existing Oracle Database',
-          e: 'dbname (Existing Oracle Database)'
-        }
-      ]).forEach(function(test) {
-        it(test.m, function() {
-          sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
-            return test.serviceConfigProperties;
-          });
-          var dbComponent = installerStep8Controller.loadHiveDbValue();
-          expect(dbComponent).to.equal(test.e);
-          installerStep8Controller.get('wizardController').getDBProperty.restore();
-        });
-      });
-  });
-
   describe('#loadHbaseMasterValue', function () {
   describe('#loadHbaseMasterValue', function () {
     Em.A([
     Em.A([
         {
         {
@@ -1400,57 +1327,6 @@ describe('App.WizardStep8Controller', function () {
       });
       });
   });
   });
 
 
-  describe('#loadOozieDbValue', function() {
-    beforeEach(function() {
-      installerStep8Controller.set('wizardController', Em.Object.create({
-        getDBProperty: Em.K
-      }));
-    });
-    Em.A([
-        {
-          serviceConfigProperties: [
-            {name: 'oozie_database', value: 'New Derby Database'},
-            {name: 'oozie_derby_database', value: 'dbname'}
-          ],
-          m: 'New Derby Database',
-          e: 'dbname (New Derby Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'oozie_database', value: 'Existing MySQL Database'},
-            {name: 'oozie_existing_mysql_database', value: 'dbname'}
-          ],
-          m: 'Existing MySQL Database',
-          e: 'dbname (Existing MySQL Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
-            {name: 'oozie_existing_postgresql_database', value: 'dbname'}
-          ],
-          m: 'Existing PostgreSQL Database',
-          e: 'dbname (Existing PostgreSQL Database)'
-        },
-        {
-          serviceConfigProperties: [
-            {name: 'oozie_database', value: 'Existing Oracle Database'},
-            {name: 'oozie_existing_oracle_database', value: 'dbname'}
-          ],
-          m: 'Existing Oracle Database',
-          e: 'dbname (Existing Oracle Database)'
-        }
-      ]).forEach(function(test) {
-        it(test.m, function() {
-          sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
-            return test.serviceConfigProperties;
-          });
-          var dbComponent = installerStep8Controller.loadOozieDbValue();
-          expect(dbComponent).to.equal(test.e);
-          installerStep8Controller.get('wizardController').getDBProperty.restore();
-        });
-      });
-  });
-
   describe('#submit', function() {
   describe('#submit', function() {
     beforeEach(function() {
     beforeEach(function() {
       sinon.stub(installerStep8Controller, 'submitProceed', Em.K);
       sinon.stub(installerStep8Controller, 'submitProceed', Em.K);

+ 7 - 1
ambari-web/test/views/common/controls_view_test.js

@@ -85,6 +85,7 @@ describe('App.ServiceConfigRadioButtons', function () {
       cases = [
       cases = [
         {
         {
           dbType: 'mysql',
           dbType: 'mysql',
+          driver: 'mysql-connector-java.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'hive_database',
             name: 'hive_database',
             value: 'New MySQL Database',
             value: 'New MySQL Database',
@@ -109,6 +110,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         },
         },
         {
         {
           dbType: 'postgres',
           dbType: 'postgres',
+          driver: 'postgresql.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'hive_database',
             name: 'hive_database',
             value: 'Existing PostgreSQL Database',
             value: 'Existing PostgreSQL Database',
@@ -133,6 +135,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         },
         },
         {
         {
           dbType: 'derby',
           dbType: 'derby',
+          driver: 'driver.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'oozie_database',
             name: 'oozie_database',
             value: 'New Derby Database',
             value: 'New Derby Database',
@@ -157,6 +160,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         },
         },
         {
         {
           dbType: 'oracle',
           dbType: 'oracle',
+          driver: 'ojdbc6.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'oozie_database',
             name: 'oozie_database',
             value: 'Existing Oracle Database',
             value: 'Existing Oracle Database',
@@ -181,6 +185,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         },
         },
         {
         {
           dbType: 'mysql',
           dbType: 'mysql',
+          driver: 'mysql-connector-java.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'DB_FLAVOR',
             name: 'DB_FLAVOR',
             value: 'MYSQL',
             value: 'MYSQL',
@@ -203,6 +208,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         },
         },
         {
         {
           dbType: 'mssql',
           dbType: 'mssql',
+          driver: 'sqljdbc4.jar',
           serviceConfig: {
           serviceConfig: {
             name: 'DB_FLAVOR',
             name: 'DB_FLAVOR',
             value: 'MSSQL',
             value: 'MSSQL',
@@ -255,7 +261,7 @@ describe('App.ServiceConfigRadioButtons', function () {
         expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
         expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
         expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
         expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
         if (!item.isAdditionalView2Null) {
         if (!item.isAdditionalView2Null) {
-          expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.dbType));
+          expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver));
         }
         }
       });
       });
     });
     });