Class ClientRegistryBinder
java.lang.Object
org.apache.hadoop.yarn.service.utils.ClientRegistryBinder
Generic code to get the URLs for clients via the registry
-
Constructor Summary
ConstructorsConstructorDescriptionClientRegistryBinder(org.apache.hadoop.registry.client.api.RegistryOperations operations) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet the current username, before any encoding has been applied.static org.apache.hadoop.registry.client.types.EndpointgetEndpoint(org.apache.hadoop.registry.client.types.ServiceRecord record, String api, boolean external) Get an endpont by APIstatic StringhomePathForUser(String username) Buld the user path -switches to the system path if the user is "".lookupExternalRestAPI(String user, String serviceClass, String instance, String api) Look up an external REST APIstatic StringlookupRestAPI(org.apache.hadoop.registry.client.types.ServiceRecord record, String api, boolean external) Look up an external REST API endpointstatic StringqualifyUser(String user) Qualify a user.protected StringresolveExternalRestAPI(String api, String path) Resolve a service record then return an external REST API exported it.
-
Constructor Details
-
ClientRegistryBinder
public ClientRegistryBinder(org.apache.hadoop.registry.client.api.RegistryOperations operations)
-
-
Method Details
-
homePathForUser
Buld the user path -switches to the system path if the user is "". It also cross-converts the username to ascii via punycode- Parameters:
username- username or ""- Returns:
- the path to the user
-
currentUsernameUnencoded
Get the current username, before any encoding has been applied.- Returns:
- the current user from the kerberos identity, falling back to the user and/or env variables.
-
qualifyUser
Qualify a user.-
"~"maps to user home path home -
"~user"maps to/users/$user -
"/"maps to/services/
- Parameters:
user- the username- Returns:
- the base path
-
-
lookupExternalRestAPI
public String lookupExternalRestAPI(String user, String serviceClass, String instance, String api) throws IOException Look up an external REST API- Parameters:
user- user which will be qualified as perqualifyUser(String)serviceClass- service classinstance- instance nameapi- API- Returns:
- the API, or an exception is raised.
- Throws:
IOException
-
resolveExternalRestAPI
Resolve a service record then return an external REST API exported it.- Parameters:
api- API to resolvepath- path of the service record- Returns:
- null if the record exists but the API is absent or it has no REST endpoints.
- Throws:
IOException- resolution problems, as covered inRegistryOperations.resolve(String)
-
lookupRestAPI
public static String lookupRestAPI(org.apache.hadoop.registry.client.types.ServiceRecord record, String api, boolean external) throws org.apache.hadoop.registry.client.exceptions.InvalidRecordException Look up an external REST API endpoint- Parameters:
record- service recordapi- URI of apiexternal- flag to indicate this is an external record- Returns:
- the first endpoint of the implementation, or null if there is no entry for the API, implementation or it's the wrong type.
- Throws:
org.apache.hadoop.registry.client.exceptions.InvalidRecordException
-
getEndpoint
public static org.apache.hadoop.registry.client.types.Endpoint getEndpoint(org.apache.hadoop.registry.client.types.ServiceRecord record, String api, boolean external) Get an endpont by API- Parameters:
record- service recordapi- APIexternal- flag to indicate this is an external record- Returns:
- the endpoint or null
-