Class ZKUtil

java.lang.Object
org.apache.hadoop.util.ZKUtil

@Private public class ZKUtil extends Object
Utilities for working with ZooKeeper.
  • 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 of ZooDefs.Perms
      remove - The permissions to be removed. Should be an OR of a some combination of ZooDefs.Perms
      Returns:
      A permissions flag that is an OR of ZooDefs.Perms present 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

      public static String resolveConfIndirection(String valInConf) throws IOException
      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