ZKUtil (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: ZKUtil

Package org.apache.hadoop.util

# Class ZKUtil

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

@Private public class ZKUtil extends Object
Utilities for working with ZooKeeper.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `ZKUtil.BadAclFormatException`
  `static class`
  `ZKUtil.BadAuthFormatException`
  `static class`
  `ZKUtil.ZKAuthInfo`
  An authentication token passed to ZooKeeper.addAuthInfo

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ZKUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static List<org.apache.zookeeper.data.ACL>`
  `parseACLs(String aclString)`
  Parse comma separated list of ACL entries to secure generated nodes, e.g.
  `static List<ZKUtil.ZKAuthInfo>`
  `parseAuth(String authString)`
  Parse a comma-separated list of authentication mechanisms.
  `static int`
  `removeSpecificPerms(int perms, int remove)`
  Helper method to remove a subset of permissions (remove) from a given set (perms).
  `static String`
  `resolveConfIndirection(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".

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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