sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject sentry git commit: SENTRY-1413: Changes to get the Fencer working with Oracle and MySQL (Rahul Sharma, Reviewed by: Hao Hao)
Date Fri, 02 Sep 2016 23:31:01 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign e3f0a9f87 -> 92ebf1d46


SENTRY-1413: Changes to get the Fencer working with Oracle and MySQL (Rahul Sharma, Reviewed
by: Hao Hao)

Change-Id: Ic447a933b13a75fd7f7a4eb44ea1c83547cd741f


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

Branch: refs/heads/sentry-ha-redesign
Commit: 92ebf1d465493efdf85771ef6c16329dccab5b35
Parents: e3f0a9f
Author: hahao <hao.hao@cloudera.com>
Authored: Fri Sep 2 16:29:45 2016 -0700
Committer: hahao <hao.hao@cloudera.com>
Committed: Fri Sep 2 16:29:45 2016 -0700

----------------------------------------------------------------------
 .../sentry/provider/db/service/persistent/SqlAccessor.java     | 6 +++---
 .../java/org/apache/sentry/service/thrift/LeaderStatus.java    | 6 +++++-
 .../org/apache/sentry/service/thrift/TestLeaderStatus.java     | 4 ++--
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/92ebf1d4/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SqlAccessor.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SqlAccessor.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SqlAccessor.java
index 9879e67..93fa92c 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SqlAccessor.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/provider/db/service/persistent/SqlAccessor.java
@@ -189,7 +189,7 @@ abstract class SqlAccessor {
     @Override
     String getFindTableByPrefixSql(String prefix) {
       return "SELECT table_name FROM information_schema.tables " +
-          "WHERE table_name LIKE " + prefix + "%";
+          "WHERE table_name LIKE '" + prefix + "%'";
     }
 
     @Override
@@ -222,7 +222,7 @@ abstract class SqlAccessor {
     @Override
     String getFindTableByPrefixSql(String prefix) {
       return "SELECT table_name FROM all_tables " +
-          "WHERE table_name LIKE " + prefix + "%";
+          "WHERE table_name LIKE '" + prefix + "%'";
     }
 
     @Override
@@ -232,7 +232,7 @@ abstract class SqlAccessor {
 
     @Override
     String getRenameTableSql(String src, String dst) {
-      return "RENAME TABLE " + src + " TO " + dst;
+      return "RENAME " + src + " TO " + dst;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/sentry/blob/92ebf1d4/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatus.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatus.java
b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatus.java
index 02ff7ff..2467921 100644
--- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatus.java
+++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/LeaderStatus.java
@@ -88,7 +88,11 @@ final class LeaderStatus implements Closeable {
    */
   static String generateIncarnationId() {
     SecureRandom srand = new SecureRandom();
-    byte[] buf = new byte[33];
+    // Why 12? Base64 encodes 12 bytes to a 16 length char array(12 * 8 /6).
+    // We need a encoded string of length <= 17, as the length of a
+    // fencing table which is prefixed with SENTRY_FENCE_(13 chars)
+    // cannot be greater than 30 chars(Oracle limitation)
+    byte[] buf = new byte[12];
     srand.nextBytes(buf);
     char[] cbuf = Base64.encode(buf);
     StringBuilder bld = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/sentry/blob/92ebf1d4/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestLeaderStatus.java
----------------------------------------------------------------------
diff --git a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestLeaderStatus.java
b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestLeaderStatus.java
index b1c4b31..c796fab 100644
--- a/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestLeaderStatus.java
+++ b/sentry-provider/sentry-provider-db/src/test/java/org/apache/sentry/service/thrift/TestLeaderStatus.java
@@ -229,9 +229,9 @@ final public class TestLeaderStatus {
     // Assert that there were no ID collisions
     Assert.assertEquals(NUM_UNIQUE_IDS, ids.size());
 
-    // Assert that all IDs are 44 characters long and begin with a letter.
+    // Assert that all IDs are 16 characters long and begin with a letter.
     for (String id : ids) {
-      Assert.assertEquals(44, id.length());
+      Assert.assertEquals(16, id.length());
       Assert.assertTrue(Character.isAlphabetic(id.charAt(0)));
     }
 


Mime
View raw message