Package org.apache.hadoop.util
Class ZKUtil
java.lang.Object
org.apache.hadoop.util.ZKUtil
Utilities for working with ZooKeeper.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classAn authentication token passed to ZooKeeper.addAuthInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.apache.zookeeper.data.ACL>Parse comma separated list of ACL entries to secure generated nodes, e.g.static List<ZKUtil.ZKAuthInfo>Parse a comma-separated list of authentication mechanisms.static intremoveSpecificPerms(int perms, int remove) Helper method to remove a subset of permissions (remove) from a given set (perms).static StringresolveConfIndirection(String valInConf) Because ZK ACLs and authentication information may be secret, allow the configuration values to be indirected through a file by specifying the configuration as "@/path/to/file".
-
Constructor Details
-
ZKUtil
public ZKUtil()
-
-
Method Details
-
removeSpecificPerms
public static int removeSpecificPerms(int perms, int remove) Helper method to remove a subset of permissions (remove) from a given set (perms).- Parameters:
perms- The permissions flag to remove from. Should be an OR of a some combination ofZooDefs.Permsremove- The permissions to be removed. Should be an OR of a some combination ofZooDefs.Perms- Returns:
- A permissions flag that is an OR of
ZooDefs.Permspresent in perms and not present in remove
-
parseACLs
public static List<org.apache.zookeeper.data.ACL> parseACLs(String aclString) throws ZKUtil.BadAclFormatException Parse comma separated list of ACL entries to secure generated nodes, e.g.sasl:hdfs/host1@MY.DOMAIN:cdrwa,sasl:hdfs/host2@MY.DOMAIN:cdrwa- Parameters:
aclString- aclString.- Returns:
- ACL list
- Throws:
ZKUtil.BadAclFormatException- if an ACL is invalid
-
parseAuth
public static List<ZKUtil.ZKAuthInfo> parseAuth(String authString) throws ZKUtil.BadAuthFormatException Parse a comma-separated list of authentication mechanisms. Each such mechanism should be of the form 'scheme:auth' -- the same syntax used for the 'addAuth' command in the ZK CLI.- Parameters:
authString- the comma-separated auth mechanisms- Returns:
- a list of parsed authentications
- Throws:
ZKUtil.BadAuthFormatException- if the auth format is invalid
-
resolveConfIndirection
Because ZK ACLs and authentication information may be secret, allow the configuration values to be indirected through a file by specifying the configuration as "@/path/to/file". If this syntax is used, this function will return the contents of the file as a String.- Parameters:
valInConf- the value from the Configuration- Returns:
- either the same value, or the contents of the referenced file if the configured value starts with "@"
- Throws:
IOException- if the file cannot be read
-