org.apache.hadoop.registry.client.binding

## Class RegistryPathUtils

- java.lang.Object
- - org.apache.hadoop.registry.client.binding.RegistryPathUtils

-     @InterfaceAudience.Private
       @InterfaceStability.Evolving
      public class RegistryPathUtils
      extends Object

  Basic operations on paths: manipulating them and creating and validating path elements.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegistryPathUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `createFullPath(String base, String path)` Create a full path from the registry root and the supplied subdir
    `static String` | `encodeForRegistry(String element)` Perform any formatting for the registry needed to convert non-simple-DNS elements
    `static String` | `encodeYarnID(String yarnId)` Perform whatever transforms are needed to get a YARN ID into a DNS-compatible name
    `static String` | `getUsername(String recPath)` Return the username found in the ZK path.
    `static String` | `join(String base, String path)` Join two paths, guaranteeing that there will not be exactly one separator between the two, and exactly one at the front of the path.
    `static String` | `lastPathEntry(String path)` Get the last entry in a path; for an empty path returns "".
    `static String` | `parentOf(String path)` Get the parent of a path
    `static List<String>` | `split(String path)` split a path into elements, stripping empty elements
    `static String` | `validateElementsAsDNS(String path)` Validate ZK path as valid for a DNS hostname.
    `static String` | `validateZKPath(String path)` Validate ZK path with the path itself included in the exception text

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

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

- - ### Constructor Detail

    - #### RegistryPathUtils

          public RegistryPathUtils()

  - ### Method Detail

    - #### validateZKPath

          public static String validateZKPath(String path)
                                       throws InvalidPathnameException

      Validate ZK path with the path itself included in the exception text
      Parameters:
        `path` - path to validate
      Returns:
        the path parameter
      Throws:
        `InvalidPathnameException` - if the pathname is invalid.

    - #### validateElementsAsDNS

          public static String validateElementsAsDNS(String path)
                                              throws InvalidPathnameException

      Validate ZK path as valid for a DNS hostname.
      Parameters:
        `path` - path to validate
      Returns:
        the path parameter
      Throws:
        `InvalidPathnameException` - if the pathname is invalid.

    - #### createFullPath

          public static String createFullPath(String base,
                                              String path)
                                       throws InvalidPathnameException

      Create a full path from the registry root and the supplied subdir
      Parameters:
        `path` - path of operation
      Returns:
        an absolute path
      Throws:
        `InvalidPathnameException` - if the path is invalid

    - #### join

          public static String join(String base,
                                    String path)

      Join two paths, guaranteeing that there will not be exactly one separator between the two, and exactly one at the front of the path. There will be no trailing "/" except for the special case that this is the root path
      Parameters:
        `base` - base path
        `path` - second path to add
      Returns:
        a combined path.

    - #### split

          public static List<String> split(String path)

      split a path into elements, stripping empty elements
      Parameters:
        `path` - the path
      Returns:
        the split path

    - #### lastPathEntry

          public static String lastPathEntry(String path)

      Get the last entry in a path; for an empty path returns "". The split logic is that of `split(String)`
      Parameters:
        `path` - path of operation
      Returns:
        the last path entry or "" if none.

    - #### parentOf

          public static String parentOf(String path)
                                 throws org.apache.hadoop.fs.PathNotFoundException

      Get the parent of a path
      Parameters:
        `path` - path to look at
      Returns:
        the parent path
      Throws:
        `org.apache.hadoop.fs.PathNotFoundException` - if the path was at root.

    - #### encodeForRegistry

          public static String encodeForRegistry(String element)

      Perform any formatting for the registry needed to convert non-simple-DNS elements
      Parameters:
        `element` - element to encode
      Returns:
        an encoded string

    - #### encodeYarnID

          public static String encodeYarnID(String yarnId)

      Perform whatever transforms are needed to get a YARN ID into a DNS-compatible name
      Parameters:
        `yarnId` - ID as string of YARN application, instance or container
      Returns:
        a string suitable for use in registry paths.

    - #### getUsername

          public static String getUsername(String recPath)

      Return the username found in the ZK path.
      Parameters:
        `recPath` - the ZK recPath.
      Returns:
        the user name.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.