>        @Provides
>        @Singleton
>        @Storage
> -      protected Supplier<URI> 
> provideStorageUrl(RegionIdToURISupplier.Factory factory, @ApiVersion String 
> apiVersion) {
> -         return 
> getLastValueInMap(factory.createForApiTypeAndVersion(ServiceType.OBJECT_STORE,
>  apiVersion));
> +      protected Supplier<URI> 
> provideStorageUrl(RegionIdToURISupplier.Factory factory, 
> +            @ApiVersion String apiVersion,
> +            @Named(LocationConstants.PROPERTY_REGION) String region) {
> +         
> +         //Get the URI's keyed by their region name
> +         Supplier<Map<String, Supplier<URI>>> endpointsSupplier = 
> factory.createForApiTypeAndVersion(ServiceType.OBJECT_STORE, apiVersion);
> +         
> +         //Pick the matching region name (if any) otherwise just return an 
> arbitrary URL if no region name is set
> +         if (!Strings.isNullOrEmpty(region)) {
> +            return getSpecificValueInMap(endpointsSupplier, region);
> +         } else {
> +            return getLastValueInMap(endpointsSupplier);

The current behaviour is just getLastValueInMap() which is inherently non 
deterministic due to the undefined nature of Map ordering. I didn't want to 
change the behavior of the default case. Any suggestions on making it more 
deterministic? I could always take the first region alphabetically.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/31/files#r4858756

Reply via email to