Class RegistryTypeUtils
java.lang.Object
org.apache.hadoop.registry.client.binding.RegistryTypeUtils
Static methods to work with registry types —primarily endpoints and the
list representation of addresses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetAddressField(Map<String, String> address, String field) Get a specific field from an address -raising an exception if the field is not presenthostnamePortPair(String hostname, int port) Create a (hostname, port) address pairhostnamePortPair(InetSocketAddress address) Create a (hostname, port) address pairstatic EndpointinetAddrEndpoint(String api, String protocolType, String hostname, int port) Create an internet address endpoint from a list of URIsstatic EndpointipcEndpoint(String api, InetSocketAddress address) Create an IPC endpointCreate a single entry mapstatic voidrequireAddressType(String required, Endpoint epr) Require a specific address type on an endpointstatic EndpointrestEndpoint(String api, URI... uris) Create a REST endpoint from a list of URIsGet a single URI endpointGet the address URLs.Create a URIstatic EndpointurlEndpoint(String api, String protocolType, URI... uris) Create a URL endpoint from a list of URIsstatic voidvalidateEndpoint(String path, Endpoint endpoint) Validate the endpoint by checking for null fields and other invalid conditionsstatic voidvalidateServiceRecord(String path, ServiceRecord record) Validate the record by checking for null fields and other invalid conditionsstatic EndpointwebEndpoint(String api, URI... uris) Create a Web UI endpoint from a list of URIs
-
Constructor Details
-
RegistryTypeUtils
public RegistryTypeUtils()
-
-
Method Details
-
urlEndpoint
Create a URL endpoint from a list of URIs- Parameters:
api- implemented APIprotocolType- protocol typeuris- URIs- Returns:
- a new endpoint
-
restEndpoint
Create a REST endpoint from a list of URIs- Parameters:
api- implemented APIuris- URIs- Returns:
- a new endpoint
-
webEndpoint
Create a Web UI endpoint from a list of URIs- Parameters:
api- implemented APIuris- URIs- Returns:
- a new endpoint
-
inetAddrEndpoint
Create an internet address endpoint from a list of URIs- Parameters:
api- implemented APIprotocolType- protocol typehostname- hostname/FQDNport- port- Returns:
- a new endpoint
-
ipcEndpoint
Create an IPC endpoint- Parameters:
api- APIaddress- the address as a tuple of (hostname, port)- Returns:
- the new endpoint
-
map
Create a single entry map- Parameters:
key- map entry keyval- map entry value- Returns:
- a 1 entry map.
-
uri
Create a URI- Parameters:
uri- value- Returns:
- a 1 entry map.
-
hostnamePortPair
Create a (hostname, port) address pair- Parameters:
hostname- hostnameport- port- Returns:
- a 1 entry map.
-
hostnamePortPair
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
Require a specific address type on an endpoint- Parameters:
required- required typeepr- endpoint- Throws:
InvalidRecordException- if the type is wrong
-
retrieveAddressesUriType
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 InvalidRecordExceptionGet a specific field from an address -raising an exception if the field is not present- Parameters:
address- address to queryfield- 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-formattedMalformedURLException- 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 exceptionsrecord- record to validate. May be null- Throws:
InvalidRecordException- on invalid entries
-
validateEndpoint
Validate the endpoint by checking for null fields and other invalid conditions- Parameters:
path- path for exceptionsendpoint- endpoint to validate. May be null- Throws:
InvalidRecordException- on invalid entries
-