ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-15017 RU/EU has to calculate ranger-env config ranger_privelege_user_jdbc_url (dsen)
Date Thu, 11 Feb 2016 22:21:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9419400da -> a98adb7eb


AMBARI-15017 RU/EU has to calculate ranger-env config ranger_privelege_user_jdbc_url (dsen)


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

Branch: refs/heads/trunk
Commit: a98adb7eb9c61b40a2724f61cc45fc9e70504c2a
Parents: 9419400
Author: Dmytro Sen <dsen@apache.org>
Authored: Fri Feb 12 00:21:51 2016 +0200
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Feb 12 00:21:51 2016 +0200

----------------------------------------------------------------------
 .../upgrades/RangerConfigCalculation.java       | 14 +++++++++-
 .../upgrades/RangerConfigCalculationTest.java   | 27 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a98adb7e/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculation.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculation.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculation.java
index ebec177..ff4a20e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculation.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculation.java
@@ -37,6 +37,8 @@ import com.google.inject.Inject;
  */
 public class RangerConfigCalculation extends AbstractServerAction {
   private static final String SOURCE_CONFIG_TYPE = "admin-properties";
+  private static final String RANGER_ENV_CONFIG_TYPE = "ranger-env";
+  private static final String RANGER_ADMIN_SITE_CONFIG_TYPE = "ranger-admin-site";
 
   @Inject
   private Clusters m_clusters;
@@ -101,6 +103,7 @@ public class RangerConfigCalculation extends AbstractServerAction {
     String url = null;
     String dialect = null;
     String auditUrl = null;
+    String userJDBCUrl = null;
 
     if ("mysql".equals(db)) {
       if (null == dbName) {
@@ -112,19 +115,22 @@ public class RangerConfigCalculation extends AbstractServerAction {
       url = MessageFormat.format("jdbc:mysql://{0}/{1}", dbHost, dbName);
       auditUrl = MessageFormat.format("jdbc:mysql://{0}/{1}", dbHost, auditDbName);
       dialect = "org.eclipse.persistence.platform.database.MySQLPlatform";
+      userJDBCUrl = MessageFormat.format("jdbc:mysql://{0}", dbHost);
     } else if ("oracle".equals(db)) {
       driver = "oracle.jdbc.OracleDriver";
       url = MessageFormat.format("jdbc:oracle:thin:@//{0}", dbHost);
       auditUrl = MessageFormat.format("jdbc:oracle:thin:@//{0}", dbHost);
       dialect = "org.eclipse.persistence.platform.database.OraclePlatform";
+      userJDBCUrl = MessageFormat.format("jdbc:oracle:thin:@//{0}", dbHost);
     }
 
     stdout.append(MessageFormat.format("Database driver: {0}\n", driver));
     stdout.append(MessageFormat.format("Database url: {0}\n", url));
     stdout.append(MessageFormat.format("Database audit url: {0}\n", auditUrl));
     stdout.append(MessageFormat.format("Database dialect: {0}", dialect));
+    stdout.append(MessageFormat.format("Database user jdbc url: {0}", userJDBCUrl));
 
-    Config config = cluster.getDesiredConfigByType("ranger-admin-site");
+    Config config = cluster.getDesiredConfigByType(RANGER_ADMIN_SITE_CONFIG_TYPE);
     Map<String, String> targetValues = config.getProperties();
     targetValues.put("ranger.jpa.jdbc.driver", driver);
     targetValues.put("ranger.jpa.jdbc.url", url);
@@ -137,6 +143,12 @@ public class RangerConfigCalculation extends AbstractServerAction {
     config.setProperties(targetValues);
     config.persist(false);
 
+    config = cluster.getDesiredConfigByType(RANGER_ENV_CONFIG_TYPE);
+    targetValues = config.getProperties();
+    targetValues.put("ranger_privelege_user_jdbc_url", userJDBCUrl);
+    config.setProperties(targetValues);
+    config.persist(false);
+
     return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", stdout.toString(), "");
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a98adb7e/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculationTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculationTest.java
index 1bd0de4..e673714 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/RangerConfigCalculationTest.java
@@ -88,8 +88,27 @@ public class RangerConfigCalculationTest {
       }
     };
 
+    Config rangerEnv = new ConfigImpl("ranger-env") {
+      Map<String, String> mockProperties = new HashMap<String, String>();
+      @Override
+      public Map<String, String> getProperties() {
+        return mockProperties;
+      }
+
+      @Override
+      public void setProperties(Map<String, String> properties) {
+        mockProperties.putAll(properties);
+      }
+
+      @Override
+      public void persist(boolean newConfig) {
+        // no-op
+      }
+    };
+
     expect(cluster.getDesiredConfigByType("admin-properties")).andReturn(adminConfig).atLeastOnce();
     expect(cluster.getDesiredConfigByType("ranger-admin-site")).andReturn(adminSiteConfig).atLeastOnce();
+    expect(cluster.getDesiredConfigByType("ranger-env")).andReturn(rangerEnv).atLeastOnce();
 
     expect(m_clusters.getCluster((String) anyObject())).andReturn(cluster).anyTimes();
     expect(m_injector.getInstance(Clusters.class)).andReturn(m_clusters).atLeastOnce();
@@ -144,6 +163,10 @@ public class RangerConfigCalculationTest {
     assertEquals("jdbc:mysql://host1/ranger_audit", map.get("ranger.jpa.audit.jdbc.url"));
     assertEquals("org.eclipse.persistence.platform.database.MySQLPlatform", map.get("ranger.jpa.audit.jdbc.dialect"));
 
+    config = c.getDesiredConfigByType("ranger-env");
+    map = config.getProperties();
+    assertEquals("jdbc:mysql://host1", map.get("ranger_privelege_user_jdbc_url"));
+
     config = c.getDesiredConfigByType("admin-properties");
     config.getProperties().put("DB_FLAVOR", "oracle");
 
@@ -161,6 +184,10 @@ public class RangerConfigCalculationTest {
     assertEquals("jdbc:oracle:thin:@//host1", map.get("ranger.jpa.audit.jdbc.url"));
     assertEquals("org.eclipse.persistence.platform.database.OraclePlatform", map.get("ranger.jpa.audit.jdbc.dialect"));
 
+    config = c.getDesiredConfigByType("ranger-env");
+    map = config.getProperties();
+    assertEquals("jdbc:oracle:thin:@//host1", map.get("ranger_privelege_user_jdbc_url"));
+
   }
 
 


Mime
View raw message