sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject sentry git commit: SENTRY-1663: UpdateableAuthzPermissions has mutable static fields (Jan Hentschel, Reviewed by: Alexander Kolbasov and Hao Hao)
Date Wed, 15 Mar 2017 23:26:26 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 8aaa73de7 -> 2a4d9c50f


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/2a4d9c50
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/2a4d9c50
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/2a4d9c50

Branch: refs/heads/sentry-ha-redesign
Commit: 2a4d9c50fb4b347c1dc61669d58b4b53c0d96170
Parents: 8aaa73d
Author: hahao <hao.hao@cloudera.com>
Authored: Wed Mar 15 16:18:17 2017 -0700
Committer: hahao <hao.hao@cloudera.com>
Committed: Wed Mar 15 16:26:14 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/sentry/blob/2a4d9c50/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 03b4cac..431c7fe 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);


Mime
View raw message