You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ha...@apache.org on 2016/04/23 06:45:39 UTC
sentry git commit: SENTRY-1153: Ensure AccessURI work with S3 (Hao
Hao, Reviewed by: Sravya Tirukkovalur)
Repository: sentry
Updated Branches:
refs/heads/master ed39dc855 -> 383cfd3ca
SENTRY-1153: Ensure AccessURI work with S3 (Hao Hao, Reviewed by: Sravya Tirukkovalur)
Change-Id: I8d0ee3e13ce602c3e0938b9c7ad5e9c717e756ac
Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/383cfd3c
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/383cfd3c
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/383cfd3c
Branch: refs/heads/master
Commit: 383cfd3ca9f71068a328974a6c280a560999ea61
Parents: ed39dc8
Author: hahao <ha...@cloudera.com>
Authored: Fri Apr 22 21:44:34 2016 -0700
Committer: hahao <ha...@cloudera.com>
Committed: Fri Apr 22 21:44:34 2016 -0700
----------------------------------------------------------------------
.../sentry/binding/hive/HiveAuthzBindingHookBase.java | 8 ++++++--
.../java/org/apache/sentry/binding/hive/TestURI.java | 8 ++++++++
.../test/java/org/apache/sentry/core/db/TestURI.java | 13 +++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sentry/blob/383cfd3c/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
index a00f2d5..df68dd3 100644
--- a/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
+++ b/sentry-binding/sentry-binding-hive-common/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHookBase.java
@@ -212,9 +212,13 @@ public abstract class HiveAuthzBindingHookBase extends AbstractSemanticAnalyzerH
HiveConf conf = SessionState.get().getConf();
String warehouseDir = conf.getVar(ConfVars.METASTOREWAREHOUSE);
Path warehousePath = new Path(warehouseDir);
+
+ // If warehousePath is an absolute path and a scheme is null and authority is null as well,
+ // qualified it with default file system scheme and authority.
if (warehousePath.isAbsoluteAndSchemeAuthorityNull()) {
- FileSystem fs = FileSystem.get(conf);
- warehouseDir = fs.makeQualified(warehousePath).toUri().toString();
+ URI defaultUri = FileSystem.getDefaultUri(conf);
+ warehousePath = warehousePath.makeQualified(defaultUri, warehousePath);
+ warehouseDir = warehousePath.toUri().toString();
}
return new AccessURI(PathUtils.parseURI(warehouseDir, uri, isLocal));
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/sentry/blob/383cfd3c/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
index c7ac070..b920d49 100644
--- a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
+++ b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
@@ -81,6 +81,14 @@ public class TestURI {
HiveAuthzBindingHookBase.parseURI("/some/path").getName());
}
+ @Test
+ public void testS3URIWithoutPrefix() throws SemanticException {
+ conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "s3n://123:456@my-bucket");
+ conf.set(ConfVars.METASTOREWAREHOUSE.varname, "/path/to/warehouse");
+ Assert.assertEquals("s3n://123:456@my-bucket/some/path",
+ HiveAuthzBindingHookBase.parseURI("/some/path").getName());
+ }
+
@AfterClass
public static void clear() {
if(baseDir != null) {
http://git-wip-us.apache.org/repos/asf/sentry/blob/383cfd3c/sentry-core/sentry-core-model-db/src/test/java/org/apache/sentry/core/db/TestURI.java
----------------------------------------------------------------------
diff --git a/sentry-core/sentry-core-model-db/src/test/java/org/apache/sentry/core/db/TestURI.java b/sentry-core/sentry-core-model-db/src/test/java/org/apache/sentry/core/db/TestURI.java
index b639a95..40b60f7 100644
--- a/sentry-core/sentry-core-model-db/src/test/java/org/apache/sentry/core/db/TestURI.java
+++ b/sentry-core/sentry-core-model-db/src/test/java/org/apache/sentry/core/db/TestURI.java
@@ -30,14 +30,17 @@ public class TestURI {
public void testBadUriNull() {
new AccessURI(null);
}
+
@Test(expected=IllegalArgumentException.class)
public void testBadUriNoFilePrefix() {
new AccessURI("/");
}
+
@Test(expected=IllegalArgumentException.class)
public void testBadUriIncorrectFilePrefix() {
new AccessURI("file:/some/path");
}
+
@Test(expected=IllegalArgumentException.class)
public void testBadUriIncorrectHdfsPrefix() {
new AccessURI("hdfs:/some/path");
@@ -49,6 +52,16 @@ public class TestURI {
}
@Test
+ public void testS3Uri() {
+ new AccessURI("s3://my-bucket/my/funny/picture.jpg");
+ }
+
+ @Test
+ public void testS3UriWithAuthority() {
+ new AccessURI("s3n://123:456@my-bucket/my/funny/picture.jpg");
+ }
+
+ @Test
public void testUriWithAuthority() {
new AccessURI("hdfs://localhost:9999/some/path");
}