@Public
@Evolving
public class RegistryUtils
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
RegistryUtils.ServiceRecordMarshal |
Static instance of service record marshalling
|
| Constructor | Description |
|---|---|
RegistryUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.lang.String |
componentListPath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName) |
Create a path for listing components under a service
|
static java.lang.String |
componentPath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName,
java.lang.String componentName) |
Create the path to a service record for a component
|
static java.lang.String |
convertUsername(java.lang.String username) |
Convert the username to that which can be used for registry
entries.
|
static java.lang.String |
currentUser() |
Get the current user path formatted for the registry
|
static java.util.Map<java.lang.String,ServiceRecord> |
extractServiceRecords(RegistryOperations operations,
java.lang.String parentpath) |
Extract all service records under a list of stat operations...this
non-atomic action skips entries that are too short or simply not matching.
|
static java.util.Map<java.lang.String,ServiceRecord> |
extractServiceRecords(RegistryOperations operations,
java.lang.String parentpath,
java.util.Collection<RegistryPathStatus> stats) |
Extract all service records under a list of stat operations...this
skips entries that are too short or simply not matching
|
static java.util.Map<java.lang.String,ServiceRecord> |
extractServiceRecords(RegistryOperations operations,
java.lang.String parentpath,
java.util.Map<java.lang.String,RegistryPathStatus> stats) |
Extract all service records under a list of stat operations...this
non-atomic action skips entries that are too short or simply not matching.
|
static java.lang.String |
getCurrentUsernameUnencoded(java.lang.String env_hadoop_username) |
Get the current username, using the value of the parameter
env_hadoop_username if it is set on an insecure cluster. |
static java.lang.String |
homePathForCurrentUser() |
Get the home path of the current user.
|
static java.lang.String |
homePathForUser(java.lang.String username) |
Buld the user path -switches to the system path if the user is "".
|
static java.util.Map<java.lang.String,ServiceRecord> |
listServiceRecords(RegistryOperations registryOperations,
java.lang.String path) |
List service records directly under a path
|
static java.lang.String |
registryUser(java.lang.String shortUserName) |
Convert the given user name formatted for the registry.
|
static java.lang.String |
serviceclassPath(java.lang.String user,
java.lang.String serviceClass) |
Create a service classpath
|
static java.lang.String |
servicePath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName) |
Create a path to a service under a user and service class
|
static java.util.Map<java.lang.String,RegistryPathStatus> |
statChildren(RegistryOperations registryOperations,
java.lang.String path) |
List children of a directory and retrieve their
RegistryPathStatus values. |
public static java.lang.String homePathForUser(java.lang.String username)
username - username or ""public static java.lang.String convertUsername(java.lang.String username)
username - userpublic static java.lang.String serviceclassPath(java.lang.String user,
java.lang.String serviceClass)
user - username or ""serviceClass - service namepublic static java.lang.String servicePath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classpublic static java.lang.String componentListPath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classpublic static java.lang.String componentPath(java.lang.String user,
java.lang.String serviceClass,
java.lang.String serviceName,
java.lang.String componentName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classcomponentName - unique name/ID of the componentpublic static java.util.Map<java.lang.String,ServiceRecord> listServiceRecords(RegistryOperations registryOperations, java.lang.String path) throws java.io.IOException
registryOperations - registry operations instancepath - path to listjava.io.IOExceptionpublic static java.util.Map<java.lang.String,RegistryPathStatus> statChildren(RegistryOperations registryOperations, java.lang.String path) throws org.apache.hadoop.fs.PathNotFoundException, InvalidPathnameException, java.io.IOException
RegistryPathStatus values.
This is not an atomic operation; A child may be deleted
during the iteration through the child entries. If this happens,
the PathNotFoundException is caught and that child
entry ommitted.
path - pathorg.apache.hadoop.fs.PathNotFoundException - path is not in the registry.InvalidPathnameException - the path is invalid.java.io.IOException - Any other IO Exceptionpublic static java.lang.String homePathForCurrentUser()
In an insecure cluster, the environment variable
HADOOP_USER_NAME is queried first.
This means that in a YARN container where the creator set this environment variable to propagate their identity, the defined user name is used in preference to the actual user.
In a secure cluster, the kerberos identity of the current user is used.
java.lang.RuntimeException - if the current user identity cannot be determined
from the OS/kerberos.@VisibleForTesting public static java.lang.String getCurrentUsernameUnencoded(java.lang.String env_hadoop_username)
env_hadoop_username if it is set on an insecure cluster.
This ensures that the username propagates correctly across processes
started by YARN.
This method is primarly made visible for testing.
env_hadoop_username - the environment variablejava.lang.RuntimeException - if there is a problem getting the short user
name of the current user.public static java.lang.String currentUser()
In an insecure cluster, the environment variable
HADOOP_USER_NAME is queried first.
This means that in a YARN container where the creator set this environment variable to propagate their identity, the defined user name is used in preference to the actual user.
In a secure cluster, the kerberos identity of the current user is used.
java.lang.RuntimeException - if the current user identity cannot be determined
from the OS/kerberos.public static java.lang.String registryUser(java.lang.String shortUserName)
shortUserName - public static java.util.Map<java.lang.String,ServiceRecord> extractServiceRecords(RegistryOperations operations, java.lang.String parentpath, java.util.Collection<RegistryPathStatus> stats) throws java.io.IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesstats - Collection of stat resultsjava.io.IOException - for any IO Operation that wasn't ignored.public static java.util.Map<java.lang.String,ServiceRecord> extractServiceRecords(RegistryOperations operations, java.lang.String parentpath, java.util.Map<java.lang.String,RegistryPathStatus> stats) throws java.io.IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesjava.io.IOException - for any IO Operation that wasn't ignored.public static java.util.Map<java.lang.String,ServiceRecord> extractServiceRecords(RegistryOperations operations, java.lang.String parentpath) throws java.io.IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesjava.io.IOException - for any IO Operation that wasn't ignored.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.