Class RegistryPathUtils
java.lang.Object
org.apache.hadoop.registry.client.binding.RegistryPathUtils
Basic operations on paths: manipulating them and creating and validating
path elements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateFullPath(String base, String path) Create a full path from the registry root and the supplied subdirstatic StringencodeForRegistry(String element) Perform any formatting for the registry needed to convert non-simple-DNS elementsstatic StringencodeYarnID(String yarnId) Perform whatever transforms are needed to get a YARN ID into a DNS-compatible namestatic StringgetUsername(String recPath) Return the username found in the ZK path.static StringJoin two paths, guaranteeing that there will not be exactly one separator between the two, and exactly one at the front of the path.static StringlastPathEntry(String path) Get the last entry in a path; for an empty path returns "".static StringGet the parent of a pathsplit a path into elements, stripping empty elementsstatic StringvalidateElementsAsDNS(String path) Validate ZK path as valid for a DNS hostname.static StringvalidateZKPath(String path) Validate ZK path with the path itself included in the exception text
-
Constructor Details
-
RegistryPathUtils
public RegistryPathUtils()
-
-
Method Details
-
validateZKPath
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
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
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
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 pathpath- second path to add- Returns:
- a combined path.
-
split
split a path into elements, stripping empty elements- Parameters:
path- the path- Returns:
- the split path
-
lastPathEntry
Get the last entry in a path; for an empty path returns "". The split logic is that ofsplit(String)- Parameters:
path- path of operation- Returns:
- the last path entry or "" if none.
-
parentOf
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
Perform any formatting for the registry needed to convert non-simple-DNS elements- Parameters:
element- element to encode- Returns:
- an encoded string
-
encodeYarnID
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
Return the username found in the ZK path.- Parameters:
recPath- the ZK recPath.- Returns:
- the user name.
-