mirror of https://github.com/apache/jclouds.git
added new aws-simpledb provider
This commit is contained in:
parent
49cbf7a0a4
commit
2759da648d
|
@ -39,5 +39,10 @@
|
||||||
<artifactId>jclouds-allblobstore</artifactId>
|
<artifactId>jclouds-allblobstore</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds.provider</groupId>
|
||||||
|
<artifactId>aws-simpledb</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -21,29 +21,19 @@ package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
|
||||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
|
||||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
|
||||||
import static org.jclouds.aws.domain.Region.US_WEST_1;
|
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in SimpleDB Clients
|
* Builds properties used in SimpleDB Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
|
public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
|
||||||
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
|
@ -51,12 +41,7 @@ public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, SimpleDBAsyncClient.VERSION);
|
properties.setProperty(PROPERTY_API_VERSION, SimpleDBAsyncClient.VERSION);
|
||||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + US_EAST_1, "https://sdb.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + US_WEST_1, "https://sdb.us-west-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + EU_WEST_1, "https://sdb.eu-west-1.amazonaws.com");
|
|
||||||
properties.setProperty(PROPERTY_ENDPOINT + "." + AP_SOUTHEAST_1, "https://sdb.ap-southeast-1.amazonaws.com");
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static org.jclouds.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -96,15 +95,6 @@ public class SimpleDBAsyncClientTest extends RestClientTest<SimpleDBAsyncClient>
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO fix this test as it has the wrong arg count
|
|
||||||
@Test(enabled = false)
|
|
||||||
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class);
|
|
||||||
for (String region : DEFAULT_REGIONS) {
|
|
||||||
processor.createRequest(method, region, "domainName");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO fix this test as it has the wrong arg type
|
// TODO fix this test as it has the wrong arg type
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testPutAttributes() throws SecurityException, NoSuchMethodException, IOException {
|
public void testPutAttributes() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.jclouds.simpledb;
|
package org.jclouds.simpledb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -28,7 +27,6 @@ import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
@ -38,7 +36,6 @@ import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
@ -50,11 +47,11 @@ import com.google.inject.Module;
|
||||||
@Test(groups = "live", sequential = true)
|
@Test(groups = "live", sequential = true)
|
||||||
public class SimpleDBClientLiveTest {
|
public class SimpleDBClientLiveTest {
|
||||||
|
|
||||||
private SimpleDBClient client;
|
protected SimpleDBClient client;
|
||||||
|
|
||||||
private RestContext<SimpleDBClient, SimpleDBAsyncClient> context;
|
private RestContext<SimpleDBClient, SimpleDBAsyncClient> context;
|
||||||
|
|
||||||
private Set<String> domains = Sets.newHashSet();
|
protected Set<String> domains = Sets.newHashSet();
|
||||||
protected String provider = "simpledb";
|
protected String provider = "simpledb";
|
||||||
protected String identity;
|
protected String identity;
|
||||||
protected String credential;
|
protected String credential;
|
||||||
|
@ -93,9 +90,11 @@ public class SimpleDBClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testListDomainsInRegion() throws InterruptedException {
|
protected void testListDomains() throws InterruptedException {
|
||||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
listDomainInRegion(null);
|
||||||
Region.AP_SOUTHEAST_1)) {
|
}
|
||||||
|
|
||||||
|
protected void listDomainInRegion(String region) throws InterruptedException {
|
||||||
SortedSet<String> allResults = Sets.newTreeSet(client.listDomainsInRegion(region));
|
SortedSet<String> allResults = Sets.newTreeSet(client.listDomainsInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
@ -103,15 +102,10 @@ public class SimpleDBClientLiveTest {
|
||||||
assertDomainInList(region, domain);
|
assertDomainInList(region, domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-simpledb";
|
public static final String PREFIX = System.getProperty("user.name") + "-simpledb";
|
||||||
|
|
||||||
@Test
|
protected String createDomainInRegion(String region, String domainName) throws InterruptedException {
|
||||||
void testCreateDomain() throws InterruptedException {
|
|
||||||
String domainName = PREFIX + "1";
|
|
||||||
|
|
||||||
for (String region : DEFAULT_REGIONS) {
|
|
||||||
try {
|
try {
|
||||||
SortedSet<String> result = Sets.newTreeSet(client.listDomainsInRegion(region));
|
SortedSet<String> result = Sets.newTreeSet(client.listDomainsInRegion(region));
|
||||||
if (result.size() >= 1) {
|
if (result.size() >= 1) {
|
||||||
|
@ -130,10 +124,15 @@ public class SimpleDBClientLiveTest {
|
||||||
// assertEquals(domain.getName(), domainName);
|
// assertEquals(domain.getName(), domainName);
|
||||||
assertDomainInList(region, domainName);
|
assertDomainInList(region, domainName);
|
||||||
domains.add(domainName);
|
domains.add(domainName);
|
||||||
}
|
return domainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertDomainInList(final String region, final String domain) throws InterruptedException {
|
@Test
|
||||||
|
protected void testCreateDomain() throws InterruptedException {
|
||||||
|
createDomainInRegion(null, PREFIX + "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void assertDomainInList(final String region, final String domain) throws InterruptedException {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
ListDomainsResponse domains = client.listDomainsInRegion(region);
|
ListDomainsResponse domains = client.listDomainsInRegion(region);
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.simpledb.config;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
|
||||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
|
||||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
|
||||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
|
||||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
|
||||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
|
||||||
import org.jclouds.logging.config.NullLoggingModule;
|
|
||||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "unit")
|
|
||||||
public class SimpleDBRestClientModuleTest {
|
|
||||||
|
|
||||||
Injector createInjector() {
|
|
||||||
return new RestContextFactory().createContextBuilder("simpledb", "uid", "key",
|
|
||||||
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testServerErrorHandler() {
|
|
||||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
|
||||||
assertEquals(handler.getServerErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testRegions() {
|
|
||||||
Map<String, URI> regionMap = createInjector().getInstance(
|
|
||||||
new Key<Map<String, URI>>(org.jclouds.location.Region.class) {
|
|
||||||
});
|
|
||||||
assertEquals(regionMap, ImmutableMap.<String, URI> of(Region.US_EAST_1, URI
|
|
||||||
.create("https://sdb.amazonaws.com"), Region.US_WEST_1, URI
|
|
||||||
.create("https://sdb.us-west-1.amazonaws.com"), Region.EU_WEST_1, URI
|
|
||||||
.create("https://sdb.eu-west-1.amazonaws.com"), Region.AP_SOUTHEAST_1, URI
|
|
||||||
.create("https://sdb.ap-southeast-1.amazonaws.com")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testClientErrorHandler() {
|
|
||||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
|
||||||
assertEquals(handler.getClientErrorHandler().getClass(), ParseAWSErrorFromXmlContent.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testClientRetryHandler() {
|
|
||||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
|
||||||
assertEquals(handler.getClientErrorRetryHandler().getClass(),
|
|
||||||
AWSClientErrorRetryHandler.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testRedirectionRetryHandler() {
|
|
||||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
|
||||||
assertEquals(handler.getRedirectionRetryHandler().getClass(),
|
|
||||||
AWSRedirectionRetryHandler.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,38 +19,50 @@
|
||||||
|
|
||||||
package org.jclouds.location.functions;
|
package org.jclouds.location.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.location.Region;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* If a mapping of regions to endpoints exists, return a corresponding
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class RegionToEndpointOrProviderIfNull implements Function<Object, URI> {
|
public class RegionToEndpointOrProviderIfNull implements Function<Object, URI> {
|
||||||
private final URI defaultUri;
|
private final URI defaultUri;
|
||||||
private final Map<String, URI> regionToEndpoint;
|
private final String defaultProvider;
|
||||||
|
|
||||||
|
@Inject(optional = true)
|
||||||
|
@Region
|
||||||
|
Map<String, URI> regionToEndpoint;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RegionToEndpointOrProviderIfNull(@Provider URI defaultUri, @Region Map<String, URI> regionToEndpoint) {
|
public RegionToEndpointOrProviderIfNull(@Provider URI defaultUri, @Provider String defaultProvider) {
|
||||||
this.defaultUri = checkNotNull(defaultUri, "defaultUri");
|
this.defaultUri = checkNotNull(defaultUri, "defaultUri");
|
||||||
this.regionToEndpoint = checkNotNull(regionToEndpoint, "regionToEndpoint");
|
this.defaultProvider = checkNotNull(defaultProvider, "defaultProvider");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI apply(@Nullable Object from) {
|
public URI apply(@Nullable Object from) {
|
||||||
return from == null ? defaultUri : regionToEndpoint.get(from);
|
checkState(from == null || from.equals(defaultProvider) || regionToEndpoint != null, "requested location " + from
|
||||||
|
+ ", but only the default location " + defaultProvider + " is configured");
|
||||||
|
checkArgument(from == null || from.equals(defaultProvider) || regionToEndpoint.containsKey(from),
|
||||||
|
"requested location " + from + ", which is not in the configured locations: " + regionToEndpoint.keySet());
|
||||||
|
|
||||||
|
return from == null || from.equals(defaultProvider) ? defaultUri : regionToEndpoint.get(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -38,6 +38,9 @@ sqs.propertiesbuilder=org.jclouds.aws.sqs.SQSPropertiesBuilder
|
||||||
simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
|
simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
|
||||||
simpledb.propertiesbuilder=org.jclouds.simpledb.SimpleDBPropertiesBuilder
|
simpledb.propertiesbuilder=org.jclouds.simpledb.SimpleDBPropertiesBuilder
|
||||||
|
|
||||||
|
aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder
|
||||||
|
aws-simpledb..propertiesbuilder=org.jclouds.aws.simpledb.SimpleDBPropertiesBuilder
|
||||||
|
|
||||||
elb.contextbuilder=org.jclouds.aws.elb.ELBContextBuilder
|
elb.contextbuilder=org.jclouds.aws.elb.ELBContextBuilder
|
||||||
elb.propertiesbuilder=org.jclouds.aws.elb.ELBPropertiesBuilder
|
elb.propertiesbuilder=org.jclouds.aws.elb.ELBPropertiesBuilder
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SyncProxyTest {
|
||||||
|
|
||||||
String take100MillisecondsAndTimeout();
|
String take100MillisecondsAndTimeout();
|
||||||
|
|
||||||
@Timeout(duration = 150, timeUnit = TimeUnit.MILLISECONDS)
|
@Timeout(duration = 300, timeUnit = TimeUnit.MILLISECONDS)
|
||||||
String take100MillisecondsAndOverride();
|
String take100MillisecondsAndOverride();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,5 +36,6 @@
|
||||||
<module>gogrid</module>
|
<module>gogrid</module>
|
||||||
<module>slicehost</module>
|
<module>slicehost</module>
|
||||||
<module>cloudsigma</module>
|
<module>cloudsigma</module>
|
||||||
|
<module>aws-simpledb</module>
|
||||||
</modules>
|
</modules>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue