Author: bikas Date: Thu Nov 14 17:53:25 2013 New Revision: 1541995 URL: http://svn.apache.org/r1541995 Log: YARN-1222. Make improvements in ZKRMStateStore for fencing (Karthik Kambatla via bikas)
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ZKUtil.java hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestZKUtil.java Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ZKUtil.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ZKUtil.java?rev=1541995&r1=1541994&r2=1541995&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ZKUtil.java (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ZKUtil.java Thu Nov 14 17:53:25 2013 @@ -72,6 +72,20 @@ public class ZKUtil { } /** + * Helper method to remove a subset of permissions (remove) from a + * given set (perms). + * @param perms The permissions flag to remove from. Should be an OR of a + * some combination of {@link ZooDefs.Perms} + * @param remove The permissions to be removed. Should be an OR of a + * some combination of {@link ZooDefs.Perms} + * @return A permissions flag that is an OR of {@link ZooDefs.Perms} + * present in perms and not present in remove + */ + public static int removeSpecificPerms(int perms, int remove) { + return perms ^ remove; + } + + /** * Parse comma separated list of ACL entries to secure generated nodes, e.g. * <code>sasl:hdfs/host1@MY.DOMAIN:cdrwa,sasl:hdfs/host2@MY.DOMAIN:cdrwa</code> * Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestZKUtil.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestZKUtil.java?rev=1541995&r1=1541994&r2=1541995&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestZKUtil.java (original) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestZKUtil.java Thu Nov 14 17:53:25 2013 @@ -24,7 +24,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; -import org.apache.hadoop.util.ZKUtil; import org.apache.hadoop.util.ZKUtil.BadAclFormatException; import org.apache.hadoop.util.ZKUtil.ZKAuthInfo; import org.apache.zookeeper.ZooDefs.Perms; @@ -76,6 +75,14 @@ public class TestZKUtil { } @Test + public void testRemoveSpecificPerms() { + int perms = Perms.ALL; + int remove = Perms.CREATE; + int newPerms = ZKUtil.removeSpecificPerms(perms, remove); + assertEquals("Removal failed", 0, newPerms & Perms.CREATE); + } + + @Test public void testGoodACLs() { List<ACL> result = ZKUtil.parseACLs( "sasl:hdfs/host1@MY.DOMAIN:cdrwa, sasl:hdfs/host2@MY.DOMAIN:ca");