@InterfaceAudience.Public @InterfaceStability.Evolving public class RegistryUtils extends Object
| Constructor and Description | 
|---|
| RegistryUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static String | componentListPath(String user,
                 String serviceClass,
                 String serviceName)Create a path for listing components under a service | 
| static String | componentPath(String user,
             String serviceClass,
             String serviceName,
             String componentName)Create the path to a service record for a component | 
| static String | convertUsername(String username)Convert the username to that which can be used for registry
 entries. | 
| static String | currentUser()Get the current user path formatted for the registry | 
| static Map<String,ServiceRecord> | extractServiceRecords(RegistryOperations operations,
                     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 Map<String,ServiceRecord> | extractServiceRecords(RegistryOperations operations,
                     String parentpath,
                     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 Map<String,ServiceRecord> | extractServiceRecords(RegistryOperations operations,
                     String parentpath,
                     Map<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 String | getCurrentUsernameUnencoded(String env_hadoop_username)Get the current username, using the value of the parameter
  env_hadoop_usernameif it is set on an insecure cluster. | 
| static String | homePathForCurrentUser()Get the home path of the current user. | 
| static String | homePathForUser(String username)Buld the user path -switches to the system path if the user is "". | 
| static Map<String,ServiceRecord> | listServiceRecords(RegistryOperations registryOperations,
                  String path)List service records directly under a path | 
| static String | registryUser(String shortUserName)Convert the given user name formatted for the registry. | 
| static String | serviceclassPath(String user,
                String serviceClass)Create a service classpath | 
| static String | servicePath(String user,
           String serviceClass,
           String serviceName)Create a path to a service under a user and service class | 
| static Map<String,RegistryPathStatus> | statChildren(RegistryOperations registryOperations,
            String path)List children of a directory and retrieve their
  RegistryPathStatusvalues. | 
public static String homePathForUser(String username)
username - username or ""public static String convertUsername(String username)
username - userpublic static String serviceclassPath(String user, String serviceClass)
user - username or ""serviceClass - service namepublic static String servicePath(String user, String serviceClass, String serviceName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classpublic static String componentListPath(String user, String serviceClass, String serviceName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classpublic static String componentPath(String user, String serviceClass, String serviceName, String componentName)
user - username or ""serviceClass - service nameserviceName - service name unique for that user and service classcomponentName - unique name/ID of the componentpublic static Map<String,ServiceRecord> listServiceRecords(RegistryOperations registryOperations, String path) throws IOException
registryOperations - registry operations instancepath - path to listIOExceptionpublic static Map<String,RegistryPathStatus> statChildren(RegistryOperations registryOperations, String path) throws org.apache.hadoop.fs.PathNotFoundException, InvalidPathnameException, 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.IOException - Any other IO Exceptionpublic static 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.
RuntimeException - if the current user identity cannot be determined
 from the OS/kerberos.public static String getCurrentUsernameUnencoded(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 variableRuntimeException - if there is a problem getting the short user
 name of the current user.public static 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.
RuntimeException - if the current user identity cannot be determined
 from the OS/kerberos.public static String registryUser(String shortUserName)
shortUserName - public static Map<String,ServiceRecord> extractServiceRecords(RegistryOperations operations, String parentpath, Collection<RegistryPathStatus> stats) throws IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesstats - Collection of stat resultsIOException - for any IO Operation that wasn't ignored.public static Map<String,ServiceRecord> extractServiceRecords(RegistryOperations operations, String parentpath, Map<String,RegistryPathStatus> stats) throws IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesIOException - for any IO Operation that wasn't ignored.public static Map<String,ServiceRecord> extractServiceRecords(RegistryOperations operations, String parentpath) throws IOException
operations - operation support for fetchesparentpath - path of the parent of all the entriesIOException - for any IO Operation that wasn't ignored.Copyright © 2022 Apache Software Foundation. All rights reserved.