Class RegistryTypeUtils

java.lang.Object
org.apache.hadoop.registry.client.binding.RegistryTypeUtils

@Public @Evolving public class RegistryTypeUtils extends Object
Static methods to work with registry types —primarily endpoints and the list representation of addresses.
  • Constructor Details

    • RegistryTypeUtils

      public RegistryTypeUtils()
  • Method Details

    • urlEndpoint

      public static Endpoint urlEndpoint(String api, String protocolType, URI... uris)
      Create a URL endpoint from a list of URIs
      Parameters:
      api - implemented API
      protocolType - protocol type
      uris - URIs
      Returns:
      a new endpoint
    • restEndpoint

      public static Endpoint restEndpoint(String api, URI... uris)
      Create a REST endpoint from a list of URIs
      Parameters:
      api - implemented API
      uris - URIs
      Returns:
      a new endpoint
    • webEndpoint

      public static Endpoint webEndpoint(String api, URI... uris)
      Create a Web UI endpoint from a list of URIs
      Parameters:
      api - implemented API
      uris - URIs
      Returns:
      a new endpoint
    • inetAddrEndpoint

      public static Endpoint inetAddrEndpoint(String api, String protocolType, String hostname, int port)
      Create an internet address endpoint from a list of URIs
      Parameters:
      api - implemented API
      protocolType - protocol type
      hostname - hostname/FQDN
      port - port
      Returns:
      a new endpoint
    • ipcEndpoint

      public static Endpoint ipcEndpoint(String api, InetSocketAddress address)
      Create an IPC endpoint
      Parameters:
      api - API
      address - the address as a tuple of (hostname, port)
      Returns:
      the new endpoint
    • map

      public static Map<String,String> map(String key, String val)
      Create a single entry map
      Parameters:
      key - map entry key
      val - map entry value
      Returns:
      a 1 entry map.
    • uri

      public static Map<String,String> uri(String uri)
      Create a URI
      Parameters:
      uri - value
      Returns:
      a 1 entry map.
    • hostnamePortPair

      public static Map<String,String> hostnamePortPair(String hostname, int port)
      Create a (hostname, port) address pair
      Parameters:
      hostname - hostname
      port - port
      Returns:
      a 1 entry map.
    • hostnamePortPair

      public static Map<String,String> hostnamePortPair(InetSocketAddress address)
      Create a (hostname, port) address pair
      Parameters:
      address - socket address whose hostname and port are used for the generated address.
      Returns:
      a 1 entry map.
    • requireAddressType

      public static void requireAddressType(String required, Endpoint epr) throws InvalidRecordException
      Require a specific address type on an endpoint
      Parameters:
      required - required type
      epr - endpoint
      Throws:
      InvalidRecordException - if the type is wrong
    • retrieveAddressesUriType

      public static List<String> retrieveAddressesUriType(Endpoint epr) throws InvalidRecordException
      Get a single URI endpoint
      Parameters:
      epr - endpoint
      Returns:
      the uri of the first entry in the address list. Null if the endpoint itself is null
      Throws:
      InvalidRecordException - if the type is wrong, there are no addresses or the payload ill-formatted
    • getAddressField

      public static String getAddressField(Map<String,String> address, String field) throws InvalidRecordException
      Get a specific field from an address -raising an exception if the field is not present
      Parameters:
      address - address to query
      field - field to resolve
      Returns:
      the resolved value. Guaranteed to be non-null.
      Throws:
      InvalidRecordException - if the field did not resolve
    • retrieveAddressURLs

      public static List<URL> retrieveAddressURLs(Endpoint epr) throws InvalidRecordException, MalformedURLException
      Get the address URLs. Guranteed to return at least one address.
      Parameters:
      epr - endpoint
      Returns:
      the address as a URL
      Throws:
      InvalidRecordException - if the type is wrong, there are no addresses or the payload ill-formatted
      MalformedURLException - address can't be turned into a URL
    • validateServiceRecord

      public static void validateServiceRecord(String path, ServiceRecord record) throws InvalidRecordException
      Validate the record by checking for null fields and other invalid conditions
      Parameters:
      path - path for exceptions
      record - record to validate. May be null
      Throws:
      InvalidRecordException - on invalid entries
    • validateEndpoint

      public static void validateEndpoint(String path, Endpoint endpoint) throws InvalidRecordException
      Validate the endpoint by checking for null fields and other invalid conditions
      Parameters:
      path - path for exceptions
      endpoint - endpoint to validate. May be null
      Throws:
      InvalidRecordException - on invalid entries