sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sra...@apache.org
Subject git commit: SENTRY-213: Sentry schema tool doesn't handle sentry.javax.jdo.* properties ( Prasad Mujumdar via Sravya Tirukkovalur)
Date Mon, 19 May 2014 17:12:36 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master cbbb3bd7a -> 953185014


SENTRY-213: Sentry schema tool doesn't handle sentry.javax.jdo.* properties ( Prasad  Mujumdar
via Sravya Tirukkovalur)


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

Branch: refs/heads/master
Commit: 953185014ddedbb9d099845107e948bf4d33003c
Parents: cbbb3bd
Author: Sravya Tirukkovalur <sravya@clouera.com>
Authored: Mon May 19 10:11:53 2014 -0700
Committer: Sravya Tirukkovalur <sravya@clouera.com>
Committed: Mon May 19 10:11:53 2014 -0700

----------------------------------------------------------------------
 .../provider/db/service/persistent/SentryStore.java      |  3 +++
 .../sentry/provider/db/tools/SentrySchemaTool.java       | 11 +++--------
 .../apache/sentry/service/thrift/ServiceConstants.java   |  5 +++--
 .../sentry/provider/db/tools/TestSentrySchemaTool.java   |  4 ++--
 4 files changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/95318501/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
index 09af86d..325dedf 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SentryStore.java
@@ -95,9 +95,12 @@ public class SentryStore {
         SENTRY_STORE_JDBC_USER_DEFAULT).trim();
     String pass = conf.get(ServerConfig.SENTRY_STORE_JDBC_PASS, ServerConfig.
         SENTRY_STORE_JDBC_PASS_DEFAULT).trim();
+    String driverName = conf.get(ServerConfig.SENTRY_STORE_JDBC_DRIVER,
+        ServerConfig.SENTRY_STORE_JDBC_DRIVER_DEFAULT);
     prop.setProperty(ServerConfig.JAVAX_JDO_URL, jdbcUrl);
     prop.setProperty(ServerConfig.JAVAX_JDO_USER, user);
     prop.setProperty(ServerConfig.JAVAX_JDO_PASS, pass);
+    prop.setProperty(ServerConfig.JAVAX_JDO_DRIVER_NAME, driverName);
     for (Map.Entry<String, String> entry : conf) {
       String key = entry.getKey();
       if (key.startsWith(ServerConfig.SENTRY_JAVAX_JDO_PROPERTY_PREFIX) ||

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/95318501/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentrySchemaTool.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentrySchemaTool.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentrySchemaTool.java
index 1ba1345..79977cf 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentrySchemaTool.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/tools/SentrySchemaTool.java
@@ -44,7 +44,6 @@ import org.apache.commons.cli.OptionGroup;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.io.output.NullOutputStream;
-import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hive.beeline.BeeLine;
 import org.apache.sentry.Command;
@@ -53,7 +52,6 @@ import org.apache.sentry.provider.db.service.persistent.SentryStoreSchemaInfo;
 import org.apache.sentry.provider.db.tools.SentrySchemaHelper.NestedScriptParser;
 import org.apache.sentry.service.thrift.SentryService;
 import org.apache.sentry.service.thrift.ServiceConstants;
-import org.apache.sentry.service.thrift.ServiceConstants.ServerConfig;
 
 public class SentrySchemaTool {
   private static final String SENTRY_SCRIP_DIR = File.separatorChar + "scripts"
@@ -177,7 +175,7 @@ public class SentrySchemaTool {
       throws SentryUserException {
     try {
       String connectionURL = getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_URL);
-      String driver = getValidConfVar("javax.jdo.option.ConnectionDriverName");
+      String driver = getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_DRIVER);
       if (printInfo) {
         System.out.println("Metastore connection URL:\t " + connectionURL);
         System.out.println("Metastore Connection Driver :\t " + driver);
@@ -388,7 +386,8 @@ public class SentrySchemaTool {
     argList.add("-u");
     argList.add(getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_URL));
     argList.add("-d");
-    argList.add(getValidConfVar("javax.jdo.option.ConnectionDriverName"));
+    argList
+        .add(getValidConfVar(ServiceConstants.ServerConfig.SENTRY_STORE_JDBC_DRIVER));
     argList.add("-n");
     argList.add(userName);
     argList.add("-p");
@@ -411,10 +410,6 @@ public class SentrySchemaTool {
 
   private String getValidConfVar(String confVar) throws IOException {
     String confVarKey = confVar;
-    if (confVar.startsWith(ServerConfig.SENTRY_DATANUCLEUS_PROPERTY_PREFIX)) {
-      confVarKey = StringUtils.removeStart(confVar,
-          ServerConfig.SENTRY_DB_PROPERTY_PREFIX);
-    }
     String confVarValue = sentryConf.get(confVarKey);
     if (confVarValue == null || confVarValue.isEmpty()) {
       throw new IOException("Empty " + confVar);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/95318501/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
index 2a5553c..d06ac3c 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/ServiceConstants.java
@@ -73,10 +73,13 @@ public class ServiceConstants {
     public static final String SENTRY_STORE_JDBC_USER_DEFAULT = "Sentry";
     public static final String SENTRY_STORE_JDBC_PASS = "sentry.store.jdbc.password";
     public static final String SENTRY_STORE_JDBC_PASS_DEFAULT = "Sentry";
+    public static final String SENTRY_STORE_JDBC_DRIVER = "sentry.store.jdbc.driver";
+    public static final String SENTRY_STORE_JDBC_DRIVER_DEFAULT = "org.apache.derby.jdbc.EmbeddedDriver";
 
     public static final String JAVAX_JDO_URL = "javax.jdo.option.ConnectionURL";
     public static final String JAVAX_JDO_USER = "javax.jdo.option.ConnectionUserName";
     public static final String JAVAX_JDO_PASS = "javax.jdo.option.ConnectionPassword";
+    public static final String JAVAX_JDO_DRIVER_NAME = "javax.jdo.option.ConnectionDriverName";
 
     public static final String SENTRY_DB_PROPERTY_PREFIX = "sentry.";
     public static final String SENTRY_JAVAX_JDO_PROPERTY_PREFIX = SENTRY_DB_PROPERTY_PREFIX
+ "javax.jdo";
@@ -101,8 +104,6 @@ public class ServiceConstants {
     .put("datanucleus.identifierFactory", "datanucleus1")
     .put("datanucleus.rdbms.useLegacyNativeValueStrategy", "true")
     .put("datanucleus.plugin.pluginRegistryBundleCheck", "LOG")
-    .put("javax.jdo.option.ConnectionDriverName",
-                     "org.apache.derby.jdbc.EmbeddedDriver")
     .put("javax.jdo.PersistenceManagerFactoryClass",
                      "org.datanucleus.api.jdo.JDOPersistenceManagerFactory")
     .put("javax.jdo.option.DetachAllOnCommit", "true")

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/95318501/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentrySchemaTool.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentrySchemaTool.java
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentrySchemaTool.java
index 17755e3..ce09f62 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentrySchemaTool.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/provider/db/tools/TestSentrySchemaTool.java
@@ -39,8 +39,8 @@ public class TestSentrySchemaTool {
     File dbDir = new File(Files.createTempDir(), "sentry_policy_db");
     sentryConf.set(ServerConfig.SENTRY_STORE_JDBC_URL,
         "jdbc:derby:;databaseName=" + dbDir.getPath() + ";create=true");
-    sentryConf.set("javax.jdo.option.ConnectionDriverName",
-        "org.apache.derby.jdbc.EmbeddedDriver");
+    sentryConf.set(ServerConfig.SENTRY_STORE_JDBC_DRIVER,
+        ServerConfig.SENTRY_STORE_JDBC_DRIVER_DEFAULT);
     sentryConf.set(ServerConfig.SENTRY_STORE_JDBC_USER,
         ServerConfig.SENTRY_STORE_JDBC_USER_DEFAULT);
     sentryConf.set(ServerConfig.SENTRY_STORE_JDBC_PASS,


Mime
View raw message