diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index eb33836841..d52558620d 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -178,6 +178,8 @@ Trunk (Unreleased) HADOOP-10736. Add key attributes to the key shell. (Mike Yoder via wang) + HADOOP-10824. Refactor KMSACLs to avoid locking. (Benoy Antony via umamahesh) + BUG FIXES HADOOP-9451. Fault single-layer config if node group topology is enabled. diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSACLs.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSACLs.java index d04a7142bd..e3e6ce0900 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSACLs.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSACLs.java @@ -28,8 +28,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; /** * Provides access to the AccessControlLists used by KMS, @@ -52,13 +50,11 @@ public String getConfigKey() { public static final int RELOADER_SLEEP_MILLIS = 1000; - Map acls; - private ReadWriteLock lock; + private volatile Map acls; private ScheduledExecutorService executorService; private long lastReload; KMSACLs(Configuration conf) { - lock = new ReentrantReadWriteLock(); if (conf == null) { conf = loadACLs(); } @@ -70,17 +66,13 @@ public KMSACLs() { } private void setACLs(Configuration conf) { - lock.writeLock().lock(); - try { - acls = new HashMap(); - for (Type aclType : Type.values()) { - String aclStr = conf.get(aclType.getConfigKey(), ACL_DEFAULT); - acls.put(aclType, new AccessControlList(aclStr)); - LOG.info("'{}' ACL '{}'", aclType, aclStr); - } - } finally { - lock.writeLock().unlock(); + Map tempAcls = new HashMap(); + for (Type aclType : Type.values()) { + String aclStr = conf.get(aclType.getConfigKey(), ACL_DEFAULT); + tempAcls.put(aclType, new AccessControlList(aclStr)); + LOG.info("'{}' ACL '{}'", aclType, aclStr); } + acls = tempAcls; } @Override @@ -120,14 +112,7 @@ private Configuration loadACLs() { public boolean hasAccess(Type type, String user) { UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user); - AccessControlList acl = null; - lock.readLock().lock(); - try { - acl = acls.get(type); - } finally { - lock.readLock().unlock(); - } - return acl.isUserAllowed(ugi); + return acls.get(type).isUserAllowed(ugi); } }