private static void updateRegion(Region region, String service, String host, boolean http, boolean https) { final Map<String, String> serviceEndpoints = region.getServiceEndpoints(); final Map<String, Boolean> httpSupport = region.getHttpSupport(); final Map<String, Boolean> httpsSupport = region.getHttpsSupport(); serviceEndpoints.put(service, host); httpSupport.put(service, http); httpsSupport.put(service, https); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }
private static void addRegionEndpoint( final Region region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if (endpointVerification && !verifyLegacyEndpoint(hostname)) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.getServiceEndpoints().put(serviceName, hostname); region.getHttpSupport().put(serviceName, "true".equals(http)); region.getHttpsSupport().put(serviceName, "true".equals(https)); }
@BeforeClass public static void setUp() { List<Region> regions = new LinkedList<Region>(); Region region = new Region("us-east-1", null); region.getServiceEndpoints().put("s3", "s3.amazonaws.com"); regions.add(region); region = new Region("us-west-1", null); region.getServiceEndpoints().put("s3", "s3-us-west-1.amazonaws.com"); regions.add(region); regions.add(new Region("cn-north-1", "amazonaws.com.cn")); metadata = new RegionMetadata(regions); }
private static void updateRegion(Region region, String service, String host, boolean http, boolean https) { final Map<String, String> serviceEndpoints = region.getServiceEndpoints(); final Map<String, Boolean> httpSupport = region.getHttpSupport(); final Map<String, Boolean> httpsSupport = region.getHttpsSupport(); serviceEndpoints.put(service, host); httpSupport.put(service, http); httpsSupport.put(service, https); }
private static void updateRegion(Region region, String service, String host, boolean http, boolean https) { final Map<String, String> serviceEndpoints = region.getServiceEndpoints(); final Map<String, Boolean> httpSupport = region.getHttpSupport(); final Map<String, Boolean> httpsSupport = region.getHttpsSupport(); serviceEndpoints.put(service, host); httpSupport.put(service, http); httpsSupport.put(service, https); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws IllegalArgumentException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }
/** * Searches through all known regions to find one with any service at the * specified endpoint. If no region is found with a service at that * endpoint, an exception is thrown. * * @param endpoint The endpoint for any service residing in the desired * region. * @return The region containing any service running at the specified * endpoint, otherwise an exception is thrown if no region is found * with a service at the specified endpoint. * @throws MalformedURLException If the given URL is malformed, or if the * one of the service URLs on record is malformed. */ public static Region getRegionByEndpoint(String endpoint) { URI targetEndpointUri = getUriByEndpoint(endpoint); String targetHost = targetEndpointUri.getHost(); for (Region region : getRegions()) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { URI serviceEndpointUrl = getUriByEndpoint(serviceEndpoint); if (serviceEndpointUrl.getHost().equals(targetHost)) return region; } } throw new IllegalArgumentException("No region found with any service for endpoint " + endpoint); }
private static void addRegionEndpoint( final Region region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if (endpointVerification && !verifyLegacyEndpoint(hostname)) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.getServiceEndpoints().put(serviceName, hostname); region.getHttpSupport().put(serviceName, "true".equals(http)); region.getHttpsSupport().put(serviceName, "true".equals(https)); }
private static void addRegionEndpoint( final Region region, final Element endpointElement, final boolean endpointVerification) { String serviceName = getChildElementValue(SERVICE_TAG, endpointElement); String hostname = getChildElementValue(HOSTNAME_TAG, endpointElement); String http = getChildElementValue(HTTP_TAG, endpointElement); String https = getChildElementValue(HTTPS_TAG, endpointElement); if (endpointVerification && !verifyLegacyEndpoint(hostname)) { throw new IllegalStateException("Invalid service endpoint (" + hostname + ") is detected."); } region.getServiceEndpoints().put(serviceName, hostname); region.getHttpSupport().put(serviceName, "true".equals(http)); region.getHttpsSupport().put(serviceName, "true".equals(https)); }