sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shreepa...@apache.org
Subject git commit: SENTRY-134: Use BoneCP, add unique constraint to GROUP_NAME, and expose jdo/datanucleus properties (Brock Noland via Shreepadma Venugopalan)
Date Mon, 17 Mar 2014 20:26:28 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master 90cdbefd5 -> fbf042e66


SENTRY-134: Use BoneCP, add unique constraint to GROUP_NAME, and expose jdo/datanucleus properties
(Brock Noland via Shreepadma Venugopalan)


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

Branch: refs/heads/master
Commit: fbf042e664aee35296a0280ba0223bf43749a1cf
Parents: 90cdbef
Author: Shreepadma Venugopalan <shreepadma@apache.org>
Authored: Mon Mar 17 13:26:06 2014 -0700
Committer: Shreepadma Venugopalan <shreepadma@apache.org>
Committed: Mon Mar 17 13:26:06 2014 -0700

----------------------------------------------------------------------
 pom.xml                                            |  6 ++++++
 sentry-provider/sentry-provider-db/pom.xml         |  4 ++++
 .../db/service/persistent/SentryStore.java         | 17 ++++++++++++++++-
 .../sentry/service/thrift/ServiceConstants.java    | 15 +++++++++++++--
 .../src/main/resources/sentry-mysql-1.4.0.sql      |  3 +++
 .../src/main/resources/sentry-oracle-1.4.0.sql     |  3 +++
 .../src/main/resources/sentry-postgres-1.4.0.sql   |  3 +++
 7 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9725102..ddf75f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,7 @@ limitations under the License.
     <maven.enforcer.plugin.version>1.3.1</maven.enforcer.plugin.version>
     <build.helper.maven.plugin.version>1.8</build.helper.maven.plugin.version>
     <commons.lang.version>2.6</commons.lang.version>
+    <bonecp.version>0.7.1.RELEASE</bonecp.version>
     <datanucleus.maven.plugin.version>3.3.0-release</datanucleus.maven.plugin.version>
     <datanucleus-api-jdo.version>3.2.1</datanucleus-api-jdo.version>
     <datanucleus-core.version>3.2.2</datanucleus-core.version>
@@ -100,6 +101,11 @@ limitations under the License.
         <version>${commons.lang.version}</version>
       </dependency>
       <dependency>
+        <groupId>com.jolbox</groupId>
+        <artifactId>bonecp</artifactId>
+        <version>${bonecp.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.derby</groupId>
         <artifactId>derby</artifactId>
         <version>${derby.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/sentry-provider/sentry-provider-db/pom.xml
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/pom.xml b/sentry-provider/sentry-provider-db/pom.xml
index d82a564..3fd5fc9 100644
--- a/sentry-provider/sentry-provider-db/pom.xml
+++ b/sentry-provider/sentry-provider-db/pom.xml
@@ -33,6 +33,10 @@ limitations under the License.
       <artifactId>commons-cli</artifactId>
     </dependency>
     <dependency>
+      <groupId>com.jolbox</groupId>
+      <artifactId>bonecp</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-common</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/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 5c87d95..9c678d5 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
@@ -35,6 +35,7 @@ import javax.jdo.PersistenceManagerFactory;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.sentry.core.model.db.DBModelAuthorizable.AuthorizableType;
 import org.apache.sentry.provider.common.ProviderConstants;
@@ -82,7 +83,21 @@ public class SentryStore {
     String jdbcUrl = conf.get(ServerConfig.SENTRY_STORE_JDBC_URL, "").trim();
     Preconditions.checkArgument(!jdbcUrl.isEmpty(), "Required parameter " +
         ServerConfig.SENTRY_STORE_JDBC_URL + " missing");
-    prop.setProperty("javax.jdo.option.ConnectionURL", jdbcUrl);
+    String user = conf.get(ServerConfig.SENTRY_STORE_JDBC_USER, ServerConfig.
+        SENTRY_STORE_JDBC_USER_DEFAULT).trim();
+    String pass = conf.get(ServerConfig.SENTRY_STORE_JDBC_PASS, ServerConfig.
+        SENTRY_STORE_JDBC_PASS_DEFAULT).trim();
+    prop.setProperty(ServerConfig.JAVAX_JDO_URL, jdbcUrl);
+    prop.setProperty(ServerConfig.JAVAX_JDO_USER, user);
+    prop.setProperty(ServerConfig.JAVAX_JDO_PASS, pass);
+    for (Map.Entry<String, String> entry : conf) {
+      String key = entry.getKey();
+      if (key.startsWith(ServerConfig.SENTRY_JAVAX_JDO_PROPERTY_PREFIX) ||
+          key.startsWith(ServerConfig.SENTRY_DATANUCLEUS_PROPERTY_PREFIX)) {
+        key = StringUtils.removeStart(key, ServerConfig.SENTRY_DB_PROPERTY_PREFIX);
+        prop.setProperty(key, entry.getValue());
+      }
+    }
     pmf = JDOHelper.getPersistenceManagerFactory(prop);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/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 29df4c4..59cb456 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
@@ -60,9 +60,22 @@ public class ServiceConstants {
     public static final String PROCESSOR_FACTORIES_DEFAULT =
         "org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessorFactory";
     public static final String SENTRY_STORE_JDBC_URL = "sentry.store.jdbc.url";
+    public static final String SENTRY_STORE_JDBC_USER = "sentry.store.jdbc.user";
+    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 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 SENTRY_DB_PROPERTY_PREFIX = "sentry.";
+    public static final String SENTRY_JAVAX_JDO_PROPERTY_PREFIX = SENTRY_DB_PROPERTY_PREFIX
+ "javax.jdo";
+    public static final String SENTRY_DATANUCLEUS_PROPERTY_PREFIX = SENTRY_DB_PROPERTY_PREFIX
+ "datanucleus";
 
     public static final ImmutableMap<String, String> SENTRY_STORE_DEFAULTS =
         ImmutableMap.<String, String>builder()
+    .put("datanucleus.connectionPoolingType", "BoneCP")
     .put("datanucleus.validateTables", "false")
     .put("datanucleus.validateColumns", "false")
     .put("datanucleus.validateConstraints", "false")
@@ -83,8 +96,6 @@ public class ServiceConstants {
     .put("javax.jdo.option.DetachAllOnCommit", "true")
     .put("javax.jdo.option.NonTransactionalRead", "false")
     .put("javax.jdo.option.NonTransactionalWrite", "false")
-    .put("javax.jdo.option.ConnectionUserName", "Sentry")
-    .put("javax.jdo.option.ConnectionPassword", "Sentry")
     .put("javax.jdo.option.Multithreaded", "true")
     .build();
 

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-1.4.0.sql
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-1.4.0.sql
b/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-1.4.0.sql
index 85d5085..2d843bc 100644
--- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-1.4.0.sql
+++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-mysql-1.4.0.sql
@@ -94,6 +94,9 @@ ALTER TABLE `SENTRY_DB_PRIVILEGE`
 ALTER TABLE `SENTRY_ROLE`
   ADD CONSTRAINT `SENTRY_ROLE_ROLE_NAME_UNIQUE` UNIQUE (`ROLE_NAME`);
 
+ALTER TABLE `SENTRY_GROUP`
+  ADD CONSTRAINT `SENTRY_GRP_GRP_NAME_UNIQUE` UNIQUE (`GROUP_NAME`);
+
 ALTER TABLE `SENTRY_ROLE_DB_PRIVILEGE_MAP`
   ADD CONSTRAINT `SEN_RLE_DB_PRV_MAP_SN_RLE_FK`
   FOREIGN KEY (`ROLE_ID`) REFERENCES `SENTRY_ROLE`(`ROLE_ID`);

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-1.4.0.sql
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-1.4.0.sql
b/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-1.4.0.sql
index 0508d45..83d972b 100644
--- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-1.4.0.sql
+++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-oracle-1.4.0.sql
@@ -81,6 +81,9 @@ ALTER TABLE "SENTRY_DB_PRIVILEGE"
 ALTER TABLE "SENTRY_ROLE"
   ADD CONSTRAINT "SENTRY_ROLE_ROLE_NAME_UNIQUE" UNIQUE ("ROLE_NAME");
 
+ALTER TABLE "SENTRY_GROUP"
+  ADD CONSTRAINT "SENTRY_GRP_GRP_NAME_UNIQUE" UNIQUE ("GROUP_NAME");
+
 ALTER TABLE "SENTRY_ROLE_DB_PRIVILEGE_MAP"
   ADD CONSTRAINT "SEN_RLE_DB_PRV_MAP_SN_RLE_FK"
   FOREIGN KEY ("ROLE_ID") REFERENCES "SENTRY_ROLE"("ROLE_ID") INITIALLY DEFERRED;

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/fbf042e6/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-1.4.0.sql
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-1.4.0.sql
b/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-1.4.0.sql
index 7298923..5bf0471 100644
--- a/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-1.4.0.sql
+++ b/sentry-provider/sentry-provider-db/src/main/resources/sentry-postgres-1.4.0.sql
@@ -94,6 +94,9 @@ ALTER TABLE ONLY "SENTRY_DB_PRIVILEGE"
 ALTER TABLE ONLY "SENTRY_ROLE"
   ADD CONSTRAINT "SENTRY_ROLE_ROLE_NAME_UNIQUE" UNIQUE ("ROLE_NAME");
 
+ALTER TABLE ONLY "SENTRY_GROUP"
+  ADD CONSTRAINT "SENTRY_GRP_GRP_NAME_UNIQUE" UNIQUE ("GROUP_NAME");
+
 ALTER TABLE ONLY "SENTRY_ROLE_DB_PRIVILEGE_MAP"
   ADD CONSTRAINT "SEN_RLE_DB_PRV_MAP_SN_RLE_FK"
   FOREIGN KEY ("ROLE_ID") REFERENCES "SENTRY_ROLE"("ROLE_ID") DEFERRABLE;


Mime
View raw message