Repository: sentry Updated Branches: refs/heads/sentry-ha-redesign 17a8c4985 -> d5848ef3e
SENTRY-1716: HMSFollower doesn't need to save path info when HDFS sync is disabled (Sergio Pena, reviewed by: Na Li and Alex Kolbasov) Project: http://git-wip-us.apache.org/repos/asf/sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/d5848ef3 Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/d5848ef3 Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/d5848ef3 Branch: refs/heads/sentry-ha-redesign Commit: d5848ef3edc5b5c5ab277fb8e851c90ca15eff50 Parents: 17a8c49 Author: Alexander Kolbasov <[email protected]> Authored: Tue May 16 08:22:15 2017 -0700 Committer: Alexander Kolbasov <[email protected]> Committed: Tue May 16 08:22:15 2017 -0700 ---------------------------------------------------------------------- .../sentry/service/thrift/SentryService.java | 10 +++++++++- .../service/thrift/SentryServiceUtil.java | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sentry/blob/d5848ef3/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java index 6fb224c..35289aa 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryService.java @@ -106,6 +106,7 @@ public class SentryService implements Callable, SigUtils.SigListener { private ScheduledExecutorService sentryStoreCleanService; private final LeaderStatusMonitor leaderMonitor; private final boolean notificationLogEnabled; + private final boolean hdfsSyncEnabled; public SentryService(Configuration conf) throws Exception { this.conf = conf; @@ -166,6 +167,8 @@ public class SentryService implements Callable, SigUtils.SigListener { notificationLogEnabled = conf.getBoolean(ServerConfig.SENTRY_NOTIFICATION_LOG_ENABLED, ServerConfig.SENTRY_NOTIFICATION_LOG_ENABLED_DEFAULT); + hdfsSyncEnabled = SentryServiceUtil.isHDFSSyncEnabled(conf); + status = Status.NOT_STARTED; // Enable signal handler for HA leader/follower status if configured @@ -274,6 +277,11 @@ public class SentryService implements Callable, SigUtils.SigListener { } private void startHMSFollower(Configuration conf) throws Exception{ + if (!hdfsSyncEnabled) { + LOGGER.info("HMS follower is not started because HDFS sync is disabled."); + return; + } + if (!notificationLogEnabled) { return; } @@ -303,7 +311,7 @@ public class SentryService implements Callable, SigUtils.SigListener { } private void stopHMSFollower(Configuration conf) { - if (!notificationLogEnabled) { + if (!notificationLogEnabled || !hdfsSyncEnabled) { return; } http://git-wip-us.apache.org/repos/asf/sentry/blob/d5848ef3/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java index 4019e61..9470437 100644 --- a/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java +++ b/sentry-provider/sentry-provider-db/src/main/java/org/apache/sentry/service/thrift/SentryServiceUtil.java @@ -18,6 +18,7 @@ package org.apache.sentry.service.thrift; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -26,6 +27,7 @@ import java.util.concurrent.TimeUnit; import com.google.common.base.Preconditions; import org.apache.commons.lang.StringUtils; +import org.apache.hadoop.conf.Configuration; import org.apache.sentry.core.common.utils.SentryConstants; import org.apache.sentry.core.common.utils.KeyValue; import org.apache.sentry.core.common.utils.PolicyFileConstants; @@ -192,6 +194,24 @@ public final class SentryServiceUtil { } } + /** + * Checks if Sentry is configured with HDFS sync enabled. + * + * @param conf The Configuration object where HDFS sync configurations are set. + * @return True if enabled; False otherwise. + */ + static boolean isHDFSSyncEnabled(Configuration conf) { + List<String> processorFactories = + Arrays.asList(conf.get(ServiceConstants.ServerConfig.PROCESSOR_FACTORIES, "").split(",")); + + List<String> policyStorePlugins = + Arrays.asList(conf.get(ServiceConstants.ServerConfig.SENTRY_POLICY_STORE_PLUGINS, "").split(",")); + + + return processorFactories.contains("org.apache.sentry.hdfs.SentryHDFSServiceProcessorFactory") + && policyStorePlugins.contains("org.apache.sentry.hdfs.SentryPlugin"); + } + private SentryServiceUtil() { // Make constructor private to avoid instantiation }
