ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-13175. Ranger Database related property values should be recommended by stack advisor. (jaimin)
Date Tue, 22 Sep 2015 01:25:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 6d165213e -> f596785cd


AMBARI-13175. Ranger Database related property values should be recommended by stack advisor.
(jaimin)


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

Branch: refs/heads/trunk
Commit: f596785cdec78a1a975509d72ba305904749f2c2
Parents: 6d16521
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Mon Sep 21 18:23:03 2015 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Mon Sep 21 18:24:50 2015 -0700

----------------------------------------------------------------------
 .../0.4.0/configuration/admin-properties.xml    |  6 ++++++
 .../stacks/HDP/2.0.6/services/stack_advisor.py  | 21 ++++++++++++++++++-
 .../RANGER/configuration/ranger-admin-site.xml  | 20 ++++++++++++++++++
 .../stacks/HDP/2.3/services/stack_advisor.py    | 22 ++++++++++++++++++++
 ambari-web/app/data/db_properties_info.js       | 10 ---------
 ambari-web/app/views/common/controls_view.js    | 12 +++++------
 6 files changed, 73 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-server/src/main/resources/common-services/RANGER/0.4.0/configuration/admin-properties.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/configuration/admin-properties.xml
b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/configuration/admin-properties.xml
index 5fdb1b9..936c332 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/configuration/admin-properties.xml
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/configuration/admin-properties.xml
@@ -49,6 +49,12 @@
     <value-attributes>
       <overridable>false</overridable>
     </value-attributes>
+    <depends-on>
+      <property>
+        <type>admin-properties</type>
+        <name>DB_FLAVOR</name>
+      </property>
+    </depends-on>
   </property>
 
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index 5568e60..b825d31 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -86,7 +86,8 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
       "MAPREDUCE2": self.recommendMapReduce2Configurations,
       "HDFS": self.recommendHDFSConfigurations,
       "HBASE": self.recommendHbaseConfigurations,
-      "AMBARI_METRICS": self.recommendAmsConfigurations
+      "AMBARI_METRICS": self.recommendAmsConfigurations,
+      "RANGER": self.recommendRangerConfigurations
     }
 
   def putProperty(self, config, configType, services=None):
@@ -241,6 +242,24 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
       and services['configurations']['hbase-env']['properties']['hbase_user'] != services['configurations']['hbase-site']['properties']['hbase.superuser']:
       putHbaseSiteProperty("hbase.superuser", services['configurations']['hbase-env']['properties']['hbase_user'])
 
+
+  def recommendRangerConfigurations(self, configurations, clusterData, services, hosts):
+    ranger_sql_connector_dict = {
+      'MYSQL': '/usr/share/java/mysql-connector-java.jar',
+      'ORACLE': '/usr/share/java/ojdbc6.jar',
+      'POSTGRES': '/usr/share/java/postgresql.jar',
+      'MSSQL': '/usr/share/java/sqljdbc4.jar',
+      'SQLA': '/path_to_driver/sqla-client-jdbc.tar.gz'
+    }
+
+    putRangerAdminProperty = self.putProperty(configurations, "admin-properties", services)
+
+    if 'admin-properties' in services['configurations'] and 'DB_FLAVOR' in services['configurations']['admin-properties']['properties']:
+      rangerDbFlavor = services['configurations']["admin-properties"]["properties"]["DB_FLAVOR"]
+      rangerSqlConnectorProperty = ranger_sql_connector_dict.get(rangerDbFlavor, ranger_sql_connector_dict['MYSQL'])
+      putRangerAdminProperty('SQL_CONNECTOR_JAR', rangerSqlConnectorProperty)
+
+
   def getAmsMemoryRecommendation(self, services, hosts):
     # MB per sink in hbase heapsize
     HEAP_PER_MASTER_COMPONENT = 50

http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
b/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
index 62f098b..7bd7bb3 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
@@ -96,6 +96,12 @@
     <value-attributes>
       <overridable>false</overridable>
     </value-attributes>
+    <depends-on>
+      <property>
+        <type>admin-properties</type>
+        <name>DB_FLAVOR</name>
+      </property>
+    </depends-on>
   </property>
 
   <property>
@@ -106,6 +112,20 @@
     <value-attributes>
       <overridable>false</overridable>
     </value-attributes>
+    <depends-on>
+      <property>
+        <type>admin-properties</type>
+        <name>DB_FLAVOR</name>
+      </property>
+      <property>
+        <type>admin-properties</type>
+        <name>db_host</name>
+      </property>
+      <property>
+        <type>admin-properties</type>
+        <name>db_name</name>
+      </property>
+    </depends-on>
   </property> 
 
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
index d7ea10f..16fb7a5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
@@ -30,6 +30,7 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
       "HIVE": self.recommendHIVEConfigurations,
       "HBASE": self.recommendHBASEConfigurations,
       "KAFKA": self.recommendKAFKAConfigurations,
+      "RANGER": self.recommendRangerConfigurations
     }
     parentRecommendConfDict.update(childRecommendConfDict)
     return parentRecommendConfDict
@@ -251,6 +252,27 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
       if ("RANGER" in servicesList) and (rangerPluginEnabled.lower() == "Yes".lower()):
         putKafkaBrokerProperty("authorizer.class.name", 'org.apache.ranger.authorization.kafka.authorizer.RangerKafkaAuthorizer')
 
+  def recommendRangerConfigurations(self, configurations, clusterData, services, hosts):
+    super(HDP23StackAdvisor, self).recommendRangerConfigurations(configurations, clusterData,
services, hosts)
+    putRangerAdminProperty = self.putProperty(configurations, "ranger-admin-site", services)
+
+    if 'admin-properties' in services['configurations'] and ('DB_FLAVOR' in services['configurations']['admin-properties']['properties'])\
+      and ('db_host' in services['configurations']['admin-properties']['properties']) and
('db_name' in services['configurations']['admin-properties']['properties']):
+
+      rangerDbFlavor = services['configurations']["admin-properties"]["properties"]["DB_FLAVOR"]
+      rangerDbHost =   services['configurations']["admin-properties"]["properties"]["db_host"]
+      rangerDbName =   services['configurations']["admin-properties"]["properties"]["db_name"]
+      ranger_db_driver_dict = {
+        'MYSQL': {'ranger.jpa.jdbc.driver': 'com.mysql.jdbc.Driver', 'ranger.jpa.jdbc.url':
'jdbc:mysql://' + rangerDbHost + '/' + rangerDbName},
+        'ORACLE': {'ranger.jpa.jdbc.driver': 'oracle.jdbc.driver.OracleDriver', 'ranger.jpa.jdbc.url':
'jdbc:oracle:thin:@/' + rangerDbHost + ':1521/' + rangerDbName},
+        'POSTGRES': {'ranger.jpa.jdbc.driver': 'org.postgresql.Driver', 'ranger.jpa.jdbc.url':
'jdbc:postgresql://' + rangerDbHost + ':5432/' + rangerDbName},
+        'MSSQL': {'ranger.jpa.jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'ranger.jpa.jdbc.url': 'jdbc:sqlserver://' + rangerDbHost + ';databaseName=' + rangerDbName},
+        'SQLA': {'ranger.jpa.jdbc.driver': 'sap.jdbc4.sqlanywhere.IDriver', 'ranger.jpa.jdbc.url':
'jdbc:sqlanywhere:host=' + rangerDbHost + ';database=' + rangerDbName}
+      }
+      rangerDbProperties = ranger_db_driver_dict.get(rangerDbFlavor, ranger_db_driver_dict['MYSQL'])
+      for key in rangerDbProperties:
+        putRangerAdminProperty(key, rangerDbProperties.get(key))
+
   def getServiceConfigurationValidators(self):
       parentValidators = super(HDP23StackAdvisor, self).getServiceConfigurationValidators()
       childValidators = {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-web/app/data/db_properties_info.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/db_properties_info.js b/ambari-web/app/data/db_properties_info.js
index d48dc98..0477677 100644
--- a/ambari-web/app/data/db_properties_info.js
+++ b/ambari-web/app/data/db_properties_info.js
@@ -54,16 +54,6 @@ module.exports = {
 
       user_name: 'oozie.service.JPAService.jdbc.username',
       password: 'oozie.service.JPAService.jdbc.password'
-    },
-    'RANGER': {
-      db_selector: 'DB_FLAVOR',
-
-      host_name: 'db_host',
-      db_name: 'db_name',
-
-      connection_url:  App.get('isHadoop23Stack') ? 'ranger.jpa.jdbc.url' : 'ranger_jdbc_connection_url',
-      driver: App.get('isHadoop23Stack') ? 'ranger.jpa.jdbc.driver' : 'ranger_jdbc_driver',
-      sql_jar_connector: 'SQL_CONNECTOR_JAR'
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f596785c/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 3531691..f3ff7cb 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -505,13 +505,13 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
       } else {
         this.get('hostNameProperty').set('isEditable', true);
       }
-      this.setRequiredProperties(['driver', 'sql_jar_connector', 'db_type']);
+      this.setRequiredProperties(['driver', 'db_type']);
       if (this.getPropertyByType('connection_url')) {
-        this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'),
this.get('userProperty.value'), this.get('passwordProperty.value'));
+        this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'));
       }
       this.handleSpecialUserPassProperties();
     }
-  }.observes('databaseProperty.value', 'hostNameProperty.value', 'serviceConfig.value', 'userProperty.value',
'passwordProperty.value'),
+  }.observes('databaseProperty.value', 'hostNameProperty.value', 'serviceConfig.value'),
 
   nameBinding: 'serviceConfig.radioName',
 
@@ -586,15 +586,13 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
    * and sets hostName as dbName in appropriate position of <code>connection_url<code>
string
    * @param {String} hostName
    * @param {String} dbName
-   * @param {String} user
-   * @param {String} password
    * @method setConnectionUrl
    */
-  setConnectionUrl: function(hostName, dbName, user, password) {
+  setConnectionUrl: function(hostName, dbName) {
     var connectionUrlProperty = this.getPropertyByType('connection_url');
     var connectionUrlTemplate = this.getDefaultPropertyValue('connection_url');
     try {
-      var connectionUrlValue = connectionUrlTemplate.format(hostName, dbName, user, password);
+      var connectionUrlValue = connectionUrlTemplate.format(hostName, dbName);
       connectionUrlProperty.set('value', connectionUrlValue);
       connectionUrlProperty.set('recommendedValue', connectionUrlValue);
     } catch(e) {


Mime
View raw message