Class ClientRegistryBinder

java.lang.Object
org.apache.hadoop.yarn.service.utils.ClientRegistryBinder

public class ClientRegistryBinder extends Object
Generic code to get the URLs for clients via the registry
  • Constructor Details

    • ClientRegistryBinder

      public ClientRegistryBinder(org.apache.hadoop.registry.client.api.RegistryOperations operations)
  • Method Details

    • homePathForUser

      public static String homePathForUser(String username)
      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

      public static String 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

      public static String qualifyUser(String user)
      Qualify a user.
      1. "~" maps to user home path home
      2. "~user" maps to /users/$user
      3. "/" 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 per qualifyUser(String)
      serviceClass - service class
      instance - instance name
      api - API
      Returns:
      the API, or an exception is raised.
      Throws:
      IOException
    • resolveExternalRestAPI

      protected String resolveExternalRestAPI(String api, String path) throws IOException
      Resolve a service record then return an external REST API exported it.
      Parameters:
      api - API to resolve
      path - 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 in RegistryOperations.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 record
      api - URI of api
      external - 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 record
      api - API
      external - flag to indicate this is an external record
      Returns:
      the endpoint or null