Repository: incubator-sentry Updated Branches: refs/heads/master 024faee91 -> 9dba28bd6
SENTRY-695: Sentry service should read the hadoop group mapping properties from core-site ( Prasad Mujumdar via Sravya Tirukkovalur) Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/9dba28bd Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/9dba28bd Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/9dba28bd Branch: refs/heads/master Commit: 9dba28bd693627c07523d9c29d3145fae2dd9de9 Parents: 024faee Author: Sravya Tirukkovalur <[email protected]> Authored: Thu May 21 12:29:08 2015 -0700 Committer: Sravya Tirukkovalur <[email protected]> Committed: Thu May 21 12:29:08 2015 -0700 ---------------------------------------------------------------------- .../provider/common/HadoopGroupMappingService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/9dba28bd/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/HadoopGroupMappingService.java ---------------------------------------------------------------------- diff --git a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/HadoopGroupMappingService.java b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/HadoopGroupMappingService.java index 14e2d05..fb335a3 100644 --- a/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/HadoopGroupMappingService.java +++ b/sentry-provider/sentry-provider-common/src/main/java/org/apache/sentry/provider/common/HadoopGroupMappingService.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.Groups; import org.slf4j.Logger; @@ -30,6 +31,7 @@ public class HadoopGroupMappingService implements GroupMappingService { private static final Logger LOGGER = LoggerFactory .getLogger(HadoopGroupMappingService.class); + private static Configuration hadoopConf; private final Groups groups; public HadoopGroupMappingService(Groups groups) { @@ -37,7 +39,19 @@ public class HadoopGroupMappingService implements GroupMappingService { } public HadoopGroupMappingService(Configuration conf, String resource) { - this(Groups.getUserToGroupsMappingService(conf)); + if (hadoopConf == null) { + synchronized (HadoopGroupMappingService.class) { + if (hadoopConf == null) { + // clone the current config and add resource path + hadoopConf = new Configuration(); + hadoopConf.addResource(conf); + if (!StringUtils.isEmpty(resource)) { + hadoopConf.addResource(resource); + } + } + } + } + this.groups = Groups.getUserToGroupsMappingService(hadoopConf); } @Override
