Repository: sentry Updated Branches: refs/heads/sentry-ha-redesign a656d39f0 -> f2ac38363
SENTRY-1834: Fix build failures when hive-authz2 profile is enabled (kalyan kumar kalvagadda reviewed by Colm O hEigeartaigh) Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/f2ac3836 Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/f2ac3836 Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/f2ac3836 Branch: refs/heads/sentry-ha-redesign Commit: f2ac38363c5dfef70732a50f8378079465fad0ad Parents: a656d39 Author: Kalyan Kumar Kalvagadda <[email protected]> Authored: Mon Jul 17 11:58:19 2017 -0500 Committer: Kalyan Kumar Kalvagadda <[email protected]> Committed: Mon Jul 17 12:02:51 2017 -0500 ---------------------------------------------------------------------- .../DefaultSentryAccessController.java | 46 ++++++++------------ sentry-tests/pom.xml | 3 ++ .../tests/e2e/hdfs/TestHDFSIntegration.java | 8 ++-- 3 files changed, 25 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/f2ac3836/sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/authorizer/DefaultSentryAccessController.java ---------------------------------------------------------------------- diff --git a/sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/authorizer/DefaultSentryAccessController.java b/sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/authorizer/DefaultSentryAccessController.java index c63cf64..98fba8c 100644 --- a/sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/authorizer/DefaultSentryAccessController.java +++ b/sentry-binding/sentry-binding-hive-v2/src/main/java/org/apache/sentry/binding/hive/v2/authorizer/DefaultSentryAccessController.java @@ -127,9 +127,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error occurred when Sentry client creating role: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } } @@ -150,9 +148,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error occurred when Sentry client creating role: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } } @@ -169,9 +165,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient listRoles: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } return roles; } @@ -243,9 +237,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient listPrivilegesByRoleName: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } return infoList; } @@ -265,9 +257,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient setCurrentRole: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); if (hiveAuthzBinding != null) { hiveAuthzBinding.close(); } @@ -290,9 +280,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient listUserRoles: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); if (hiveAuthzBinding != null) { hiveAuthzBinding.close(); } @@ -335,9 +323,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient listRolesByGroupName: " + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } return hiveRoleGrants; } @@ -463,9 +449,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient grant/revoke privilege:" + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } } /** @@ -524,9 +508,7 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { String msg = "Error when sentryClient grant/revoke role:" + e.getMessage(); executeOnErrorHooks(msg, e); } finally { - if (sentryClient != null) { - sentryClient.close(); - } + closeClient(); } } @@ -564,6 +546,14 @@ public class DefaultSentryAccessController extends SentryHiveAccessController { throw new HiveAuthzPluginException(msg, e); } } - + private void closeClient() { + if (sentryClient != null) { + try { + sentryClient.close(); + } catch (Exception e) { + LOG.error("Error while closing the connection with sentry server", e); + } + } + } } http://git-wip-us.apache.org/repos/asf/sentry/blob/f2ac3836/sentry-tests/pom.xml ---------------------------------------------------------------------- diff --git a/sentry-tests/pom.xml b/sentry-tests/pom.xml index 1909dae..51bbc8d 100644 --- a/sentry-tests/pom.xml +++ b/sentry-tests/pom.xml @@ -48,6 +48,9 @@ limitations under the License. <activation> <activeByDefault>false</activeByDefault> </activation> + <properties> + <pmd.skip>true</pmd.skip> + </properties> <modules> <module>sentry-tests-hive-v2</module> </modules> http://git-wip-us.apache.org/repos/asf/sentry/blob/f2ac3836/sentry-tests/sentry-tests-hive-v2/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java ---------------------------------------------------------------------- diff --git a/sentry-tests/sentry-tests-hive-v2/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java b/sentry-tests/sentry-tests-hive-v2/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java index 1415297..85902ed 100644 --- a/sentry-tests/sentry-tests-hive-v2/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java +++ b/sentry-tests/sentry-tests-hive-v2/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java @@ -240,7 +240,7 @@ public class TestHDFSIntegration { } private static void startHiveAndMetastore(final HiveConf hiveConf) throws IOException, InterruptedException { - startHiveAndMetastore(NUM_RETRIES); + startHiveAndMetastore(hiveConf, NUM_RETRIES); } private static void startHiveAndMetastore(final HiveConf hiveConf, final int retries) throws IOException, InterruptedException { @@ -316,7 +316,7 @@ public class TestHDFSIntegration { public Void run() throws Exception { System.setProperty(MiniDFSCluster.PROP_TEST_BUILD_DATA, "target/test/data"); hadoopConf = new HdfsConfiguration(); - hadoopConfconf.set(DFSConfigKeys.DFS_NAMENODE_INODE_ATTRIBUTES_PROVIDER_KEY, + hadoopConf.set(DFSConfigKeys.DFS_NAMENODE_INODE_ATTRIBUTES_PROVIDER_KEY, SentryINodeAttributesProvider.class.getName()); hadoopConf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, true); hadoopConf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1); @@ -1688,9 +1688,9 @@ public class TestHDFSIntegration { // In the local test environment, EXTERNAL_SENTRY_SERVICE is false, // set the default URI scheme to be hdfs. - boolean testConfOff = new Boolean(System.getProperty(EXTERNAL_SENTRY_SERVICE, "false")); + boolean testConfOff = Boolean.valueOf(System.getProperty(EXTERNAL_SENTRY_SERVICE, "false")); if (!testConfOff) { - PathsUpdate.getConfiguration().set("fs.defaultFS", "hdfs:///"); + PathsUpdate.setDefaultScheme("hdfs"); } tmpHDFSDir = new Path("/tmp/external");
