| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.aws.domain; |
| 20 | |
| 21 | import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; |
| 22 | import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES; |
| 23 | import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION; |
| 24 | import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; |
| 25 | |
| 26 | import java.util.Properties; |
| 27 | import java.util.Set; |
| 28 | |
| 29 | import com.google.common.base.Joiner; |
| 30 | import com.google.common.collect.ImmutableSet; |
| 31 | |
| 32 | /** |
| 33 | * |
| 34 | * Regions used for all aws commands. |
| 35 | * |
| 36 | * @author Adrian Cole |
| 37 | * @see <a |
| 38 | * href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?LocationSelection.html" |
| 39 | * /> |
| 40 | * |
| 41 | */ |
| 42 | public class Region { |
| 43 | /** |
| 44 | * EU (Ireland) |
| 45 | * <p/> |
| 46 | * <h3>S3</h3> |
| 47 | * <p/> |
| 48 | * In Amazon S3, the EU (Ireland) Region provides read-after-write consistency for PUTS of new |
| 49 | * objects in your Amazon S3 bucket and eventual consistency for overwrite PUTS and DELETES. |
| 50 | */ |
| 51 | public static final String EU = "EU"; |
| 52 | |
| 53 | public static final String EU_WEST_1 = "eu-west-1"; |
| 54 | |
| 55 | /** |
| 56 | * |
| 57 | * US Standard |
| 58 | * <p/> |
| 59 | * <h3>S3</h3> |
| 60 | * <p/> |
| 61 | * This is the default Region. All requests sent to s3.amazonaws.com go to this Region unless you |
| 62 | * specify a LocationConstraint on a bucket. The US Standard Region automatically places your |
| 63 | * data in either Amazon's east or west coast data centers depending on what will provide you |
| 64 | * with the lowest latency. To use this region, do not set the LocationConstraint bucket |
| 65 | * parameter. The US Standard Region provides eventual consistency for all requests. |
| 66 | */ |
| 67 | public static final String US_STANDARD = "us-standard"; |
| 68 | |
| 69 | /** |
| 70 | * |
| 71 | */ |
| 72 | public static final String US_EAST_1 = "us-east-1"; |
| 73 | |
| 74 | /** |
| 75 | * US-West (Northern California) <h3>S3</h3> Uses Amazon S3 servers in Northern California |
| 76 | * <p/> |
| 77 | * Optionally, use the endpoint s3-us-west-1.amazonaws.com on all requests to this bucket to |
| 78 | * reduce the latency you might experience after the first hour of creating a bucket in this |
| 79 | * Region. |
| 80 | * <p/> |
| 81 | * In Amazon S3, the US-West (Northern California) Region provides read-after-write consistency |
| 82 | * for PUTS of new objects in your Amazon S3 bucket and eventual consistency for overwrite PUTS |
| 83 | * and DELETES. |
| 84 | */ |
| 85 | public static final String US_WEST_1 = "us-west-1"; |
| 86 | |
| 87 | /** |
| 88 | * Region in Singapore, launched April 28, 2010. This region improves latency for Asia-based |
| 89 | * users |
| 90 | */ |
| 91 | public static final String AP_SOUTHEAST_1 = "ap-southeast-1"; |
| 92 | |
| 93 | /** |
| 94 | * Region in Tokyo, launched March 2, 2011. This region improves latency for Asia-based users |
| 95 | */ |
| 96 | public static final String AP_NORTHEAST_1 = "ap-northeast-1"; |
| 97 | |
| 98 | public static Set<String> DEFAULT_S3 = ImmutableSet.of(EU, US_STANDARD, US_WEST_1, AP_SOUTHEAST_1, AP_NORTHEAST_1); |
| 99 | |
| 100 | public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(US_EAST_1, US_WEST_1, EU_WEST_1, AP_SOUTHEAST_1, |
| 101 | AP_NORTHEAST_1); |
| 102 | |
| 103 | public static Properties regionPropertiesS3() { |
| 104 | |
| 105 | Properties properties = regionProperties(); |
| 106 | properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_S3)); |
| 107 | // note that due to US_STANDARD the codes include US instead of US-VA |
| 108 | properties.setProperty(PROPERTY_ISO3166_CODES, "US,US-CA,IE,SG,JP-13"); |
| 109 | properties.setProperty(PROPERTY_REGION + "." + US_STANDARD + "." + ISO3166_CODES, "US"); |
| 110 | properties.setProperty(PROPERTY_REGION + "." + EU + "." + ISO3166_CODES, "IE"); |
| 111 | return properties; |
| 112 | } |
| 113 | |
| 114 | public static Properties regionProperties() { |
| 115 | Properties properties = new Properties(); |
| 116 | properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS)); |
| 117 | properties.setProperty(PROPERTY_ISO3166_CODES, "US-VA,US-CA,IE,SG,JP-13"); |
| 118 | properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + "." + ISO3166_CODES, "US-VA"); |
| 119 | properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + "." + ISO3166_CODES, "US-CA"); |
| 120 | properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + "." + ISO3166_CODES, "IE"); |
| 121 | properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + "." + ISO3166_CODES, "SG"); |
| 122 | properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + "." + ISO3166_CODES, "JP-13"); |
| 123 | return properties; |
| 124 | } |
| 125 | } |