List of usage examples for org.apache.hadoop.registry.client.binding RegistryTypeUtils retrieveAddressesUriType
public static List<String> retrieveAddressesUriType(Endpoint epr) throws InvalidRecordException
From source file:org.apache.slider.client.ClientRegistryBinder.java
License:Apache License
/** * Look up an external REST API endpoint * @param record service record// www . j av a 2s . c o m * @param api URI of api * @param external flag to indicate this is an external record * @return the first endpoint of the implementation, or null if there * is no entry for the API, implementation or it's the wrong type. */ public static String lookupRestAPI(ServiceRecord record, String api, boolean external) throws InvalidRecordException { try { String url = null; Endpoint endpoint = getEndpoint(record, api, external); List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(endpoint); if (addresses != null && !addresses.isEmpty()) { url = addresses.get(0); } return url; } catch (InvalidRecordException e) { log.debug("looking for API {}", api, e); return null; } }
From source file:org.apache.slider.core.registry.retrieve.RegistryRetriever.java
License:Apache License
/** * Retrieve from a service by locating the * exported {@link CustomRegistryConstants#PUBLISHER_CONFIGURATIONS_API} * and working off it.//w w w. j av a 2 s .com * @param record service record * @throws RegistryIOException the address type of the endpoint does * not match that expected (i.e. not a list of URLs), missing endpoint... */ public RegistryRetriever(ServiceRecord record) throws RegistryIOException { Endpoint internal = record.getInternalEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API); String url = null; if (internal != null) { List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(internal); if (addresses != null && !addresses.isEmpty()) { url = addresses.get(0); } } internalConfigurationURL = url; Endpoint external = record.getExternalEndpoint(CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API); url = null; if (external != null) { List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(external); if (addresses != null && !addresses.isEmpty()) { url = addresses.get(0); } } externalConfigurationURL = url; internal = record.getInternalEndpoint(CustomRegistryConstants.PUBLISHER_EXPORTS_API); url = null; if (internal != null) { List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(internal); if (addresses != null && !addresses.isEmpty()) { url = addresses.get(0); } } internalExportsURL = url; external = record.getExternalEndpoint(CustomRegistryConstants.PUBLISHER_EXPORTS_API); url = null; if (external != null) { List<String> addresses = RegistryTypeUtils.retrieveAddressesUriType(external); if (addresses != null && !addresses.isEmpty()) { url = addresses.get(0); } } externalExportsURL = url; }