Class RegistryPathUtils

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

@Private @Evolving public class RegistryPathUtils extends Object
Basic operations on paths: manipulating them and creating and validating path elements.
  • Constructor Details

    • RegistryPathUtils

      public RegistryPathUtils()
  • Method Details

    • 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.