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 2017/03/15 23:19:36 UTC

sentry git commit: SENTRY-1663: UpdateableAuthzPermissions has mutable static fields (Jan Hentschel, Reviewed by: Alexander Kolbasov and Hao Hao)

Repository: sentry
Updated Branches:
  refs/heads/master 6f4a88bd1 -> 8fa5fa54f


SENTRY-1663: UpdateableAuthzPermissions has mutable static fields (Jan Hentschel, Reviewed by: Alexander Kolbasov and Hao Hao)

Change-Id: I078c8536b0135766cc570ea09ce638b6ef0bb240


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

Branch: refs/heads/master
Commit: 8fa5fa54fd022c2cd6db9d53a42598ee10966906
Parents: 6f4a88b
Author: hahao <ha...@cloudera.com>
Authored: Wed Mar 15 16:18:17 2017 -0700
Committer: hahao <ha...@cloudera.com>
Committed: Wed Mar 15 16:18:17 2017 -0700

----------------------------------------------------------------------
 .../sentry/hdfs/UpdateableAuthzPermissions.java | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/8fa5fa54/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java
----------------------------------------------------------------------
diff --git a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java
index 3d3fc8d..30f06c4 100644
--- a/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java
+++ b/sentry-hdfs/sentry-hdfs-namenode-plugin/src/main/java/org/apache/sentry/hdfs/UpdateableAuthzPermissions.java
@@ -17,7 +17,6 @@
  */
 package org.apache.sentry.hdfs;
 
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -25,6 +24,7 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReadWriteLock;
 
+import com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.sentry.hdfs.SentryPermissions.PrivilegeInfo;
@@ -35,7 +35,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable<PermissionsUpdate> {
-  public static final Map<String, FsAction> ACTION_MAPPING = new HashMap<String, FsAction>();
+  public static final ImmutableMap<String, FsAction> ACTION_MAPPING = ImmutableMap.<String, FsAction>builder()
+          .put("ALL", FsAction.ALL)
+          .put("*", FsAction.ALL)
+          .put("SELECT", FsAction.READ_EXECUTE)
+          .put("select", FsAction.READ_EXECUTE)
+          .put("INSERT", FsAction.WRITE_EXECUTE)
+          .put("insert", FsAction.WRITE_EXECUTE)
+          .build();
   
   private static final int MAX_UPDATES_PER_LOCK_USE = 99;
   private static final String UPDATABLE_TYPE_NAME = "perm_authz_update";
@@ -43,15 +50,6 @@ public class UpdateableAuthzPermissions implements AuthzPermissions, Updateable<
   private volatile SentryPermissions perms = new SentryPermissions();
   private final AtomicLong seqNum = new AtomicLong(0);
 
-  static {
-    ACTION_MAPPING.put("ALL", FsAction.ALL);
-    ACTION_MAPPING.put("*", FsAction.ALL);
-    ACTION_MAPPING.put("SELECT", FsAction.READ_EXECUTE);
-    ACTION_MAPPING.put("select", FsAction.READ_EXECUTE);
-    ACTION_MAPPING.put("INSERT", FsAction.WRITE_EXECUTE);
-    ACTION_MAPPING.put("insert", FsAction.WRITE_EXECUTE);
-  }
-
   @Override
   public List<AclEntry> getAcls(String authzObj) {
     return perms.getAcls(authzObj);