mirror of https://github.com/apache/jclouds.git
Issue 293: refactored code to provide for api versions and coherent properties for authorization
This commit is contained in:
parent
35c83335d2
commit
27f4f69b4c
|
@ -1,56 +0,0 @@
|
|||
#set( $lcaseProviderName = ${providerName.toLowerCase()} )
|
||||
#set( $ucaseProviderName = ${providerName.toUpperCase()} )
|
||||
/**
|
||||
*
|
||||
* 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 ${package}.compute;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import ${package}.${providerName}ContextBuilder;
|
||||
import ${package}.${providerName}PropertiesBuilder;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
|
||||
/**
|
||||
* @author ${author}
|
||||
*/
|
||||
@Test(groups = "unit", testName = "compute.PropertiesTest")
|
||||
public class PropertiesTest {
|
||||
private Properties properties;
|
||||
|
||||
@BeforeTest
|
||||
public void setUp() throws IOException {
|
||||
properties = new Properties();
|
||||
properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties"))
|
||||
.getInput());
|
||||
}
|
||||
|
||||
public void test${providerName}() {
|
||||
assertEquals(properties.getProperty("${lcaseProviderName}.contextbuilder"),
|
||||
${providerName}ContextBuilder.class.getName());
|
||||
assertEquals(properties.getProperty("${lcaseProviderName}.propertiesbuilder"),
|
||||
${providerName}PropertiesBuilder.class.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -47,7 +47,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
|||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.ParamParser;
|
||||
import org.jclouds.rest.annotations.QueryParams;
|
||||
|
@ -68,9 +67,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @see <a href="https://community.emc.com/community/labs/atmos_online" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Endpoint(AtmosStorage.class)
|
||||
@RequestFilters(SignRequest.class)
|
||||
@SkipEncoding( { '/' })
|
||||
@SkipEncoding('/')
|
||||
public interface AtmosStorageAsyncClient {
|
||||
/**
|
||||
* Creates a default implementation of AtmosObject
|
||||
|
|
|
@ -46,13 +46,13 @@ import com.google.inject.Module;
|
|||
public class AtmosStorageContextBuilder extends
|
||||
BlobStoreContextBuilder<AtmosStorageClient, AtmosStorageAsyncClient> {
|
||||
|
||||
public AtmosStorageContextBuilder(String providerName, Properties props) {
|
||||
super(providerName, AtmosStorageClient.class, AtmosStorageAsyncClient.class, props);
|
||||
public AtmosStorageContextBuilder(Properties props) {
|
||||
super(AtmosStorageClient.class, AtmosStorageAsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(String providerName, List<Module> modules) {
|
||||
modules.add(new AtmosBlobStoreContextModule(providerName));
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new AtmosBlobStoreContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link AtmosBlobStoreContext} instances based on the most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see AtmosBlobStoreContext
|
||||
*/
|
||||
public class AtmosStorageContextFactory {
|
||||
public static BlobStoreContext createContext(Properties properties, Module... modules) {
|
||||
return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder(
|
||||
properties).build()).withModules(modules).buildBlobStoreContext();
|
||||
}
|
||||
|
||||
public static BlobStoreContext createContext(String uid, String key, Module... modules) {
|
||||
return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder(uid,
|
||||
key).build()).withModules(modules).buildBlobStoreContext();
|
||||
}
|
||||
|
||||
public static BlobStoreContext createContext(URI endpoint, String uid, String key,
|
||||
Module... modules) {
|
||||
return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder(uid,
|
||||
key).withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext();
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
|
||||
|
||||
/**
|
||||
* Builds properties used in AtmosStorage Connections
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AtmosStoragePropertiesBuilder extends PropertiesBuilder {
|
||||
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_ENDPOINT,
|
||||
"https://accesspoint.atmosonline.com");
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_SESSIONINTERVAL, "60");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public AtmosStoragePropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public AtmosStoragePropertiesBuilder(String uid, String key) {
|
||||
super();
|
||||
withCredentials(uid, key);
|
||||
}
|
||||
|
||||
public AtmosStoragePropertiesBuilder withCredentials(String uid, String key) {
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_UID, checkNotNull(uid, "uid"));
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY, checkNotNull(key, "key"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AtmosStoragePropertiesBuilder withEndpoint(URI endpoint) {
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_ENDPOINT, checkNotNull(
|
||||
endpoint, "endpoint").toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public AtmosStoragePropertiesBuilder withTimeStampExpiration(long seconds) {
|
||||
properties.setProperty(AtmosStorageConstants.PROPERTY_EMCSAAS_SESSIONINTERVAL, seconds + "");
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ import org.jclouds.blobstore.domain.StorageMetadata;
|
|||
import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
||||
import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
|
||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.blobstore.util.BlobUtils;
|
||||
import org.jclouds.concurrent.ConcurrentUtils;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
|
@ -78,7 +78,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||
|
||||
@Inject
|
||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
||||
AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
||||
Location defaultLocation, Set<? extends Location> locations,
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ import org.jclouds.blobstore.domain.StorageMetadata;
|
|||
import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
||||
import org.jclouds.blobstore.internal.BaseBlobStore;
|
||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.blobstore.util.BlobUtils;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
|
@ -64,7 +64,7 @@ public class AtmosBlobStore extends BaseBlobStore {
|
|||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||
|
||||
@Inject
|
||||
AtmosBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, Location defaultLocation,
|
||||
AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Location defaultLocation,
|
||||
Set<? extends Location> locations, AtmosStorageClient sync, ObjectToBlob object2Blob,
|
||||
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
|
||||
BlobStoreListOptionsToListOptions container2ContainerListOptions,
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
|||
import org.jclouds.atmosonline.saas.blobstore.AtmosAsyncBlobStore;
|
||||
import org.jclouds.atmosonline.saas.blobstore.AtmosBlobStore;
|
||||
import org.jclouds.atmosonline.saas.blobstore.strategy.FindMD5InUserMetadata;
|
||||
import org.jclouds.atmosonline.saas.config.AtmosStorageContextModule;
|
||||
import org.jclouds.blobstore.AsyncBlobStore;
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
|
@ -38,8 +37,10 @@ import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
@ -49,16 +50,11 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AtmosBlobStoreContextModule extends AtmosStorageContextModule {
|
||||
private final String providerName;
|
||||
|
||||
public AtmosBlobStoreContextModule(String providerName) {
|
||||
this.providerName = providerName;
|
||||
}
|
||||
public class AtmosBlobStoreContextModule extends AbstractModule {
|
||||
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new BlobStoreMapModule());
|
||||
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
|
||||
bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON);
|
||||
|
@ -72,7 +68,7 @@ public class AtmosBlobStoreContextModule extends AtmosStorageContextModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
Location getLocation() {
|
||||
Location getLocation(@Provider String providerName) {
|
||||
return new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStorage;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.HttpAsyncClient;
|
||||
import org.jclouds.rest.HttpClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
public class AtmosStorageContextModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<AtmosStorageClient, AtmosStorageAsyncClient> provideContext(
|
||||
Closer closer, HttpClient http, HttpAsyncClient asyncHttp,
|
||||
AtmosStorageAsyncClient async, AtmosStorageClient defaultApi,
|
||||
@AtmosStorage URI endPoint,
|
||||
@Named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID) String account) {
|
||||
return new RestContextImpl<AtmosStorageClient, AtmosStorageAsyncClient>(
|
||||
closer, http, asyncHttp, defaultApi, async, endPoint, account);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,16 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.config;
|
||||
|
||||
import static org.jclouds.atmosonline.saas.reference.AtmosStorageConstants.PROPERTY_EMCSAAS_ENDPOINT;
|
||||
import static org.jclouds.atmosonline.saas.reference.AtmosStorageConstants.PROPERTY_EMCSAAS_SESSIONINTERVAL;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStorage;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
||||
import org.jclouds.atmosonline.saas.handlers.AtmosStorageClientErrorRetryHandler;
|
||||
|
@ -41,6 +36,8 @@ import org.jclouds.http.RequiresHttp;
|
|||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.http.functions.config.ParserModule.Iso8601DateAdapter;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
|
@ -63,17 +60,11 @@ public class AtmosStorageRestClientModule extends
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
install(new AtmosObjectModule());
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@AtmosStorage
|
||||
protected URI provideAuthenticationURI(@Named(PROPERTY_EMCSAAS_ENDPOINT) String endpoint) {
|
||||
return URI.create(endpoint);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TimeStamp
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
|
@ -85,7 +76,7 @@ public class AtmosStorageRestClientModule extends
|
|||
*/
|
||||
@Provides
|
||||
@TimeStamp
|
||||
Supplier<String> provideTimeStampCache(@Named(PROPERTY_EMCSAAS_SESSIONINTERVAL) long seconds,
|
||||
Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final DateService dateService) {
|
||||
return new ExpirableSupplier<String>(new Supplier<String>() {
|
||||
public String get() {
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.filters;
|
||||
|
||||
import static org.jclouds.Constants.LOGGER_SIGNATURE;
|
||||
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.util.Patterns.NEWLINE_PATTERN;
|
||||
import static org.jclouds.util.Patterns.TWO_SPACE_PATTERN;
|
||||
|
||||
|
@ -33,8 +36,6 @@ import javax.inject.Provider;
|
|||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
|
@ -67,13 +68,12 @@ public class SignRequest implements HttpRequestFilter {
|
|||
Logger logger = Logger.NULL;
|
||||
|
||||
@Resource
|
||||
@Named(Constants.LOGGER_SIGNATURE)
|
||||
@Named(LOGGER_SIGNATURE)
|
||||
Logger signatureLog = Logger.NULL;
|
||||
|
||||
@Inject
|
||||
public SignRequest(SignatureWire signatureWire,
|
||||
@Named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID) String uid,
|
||||
@Named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY) String encodedKey,
|
||||
public SignRequest(SignatureWire signatureWire, @Named(PROPERTY_IDENTITY) String uid,
|
||||
@Named(PROPERTY_CREDENTIAL) String encodedKey,
|
||||
@TimeStamp Provider<String> timeStampProvider, EncryptionService encryptionService) {
|
||||
this.signatureWire = signatureWire;
|
||||
this.uid = uid;
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas.reference;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in AtmosStorage connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface AtmosStorageConstants {
|
||||
public static final String PROPERTY_EMCSAAS_ENDPOINT = "jclouds.emcsaas.endpoint";
|
||||
public static final String PROPERTY_EMCSAAS_UID = "jclouds.emcsaas.uid";
|
||||
public static final String PROPERTY_EMCSAAS_KEY = "jclouds.emcsaas.key";
|
||||
/**
|
||||
* how long do we wait before obtaining a new timestamp for requests. Clocks must be within 5m of
|
||||
* Atmos.
|
||||
*/
|
||||
public static final String PROPERTY_EMCSAAS_SESSIONINTERVAL = "jclouds.emcsaas.sessioninterval";
|
||||
|
||||
}
|
|
@ -40,16 +40,18 @@ import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
|
|||
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
||||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import com.google.inject.name.Names;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -275,26 +277,34 @@ public class AtmosStorageAsyncClientTest extends RestClientTest<AtmosStorageAsyn
|
|||
|
||||
@BeforeClass
|
||||
@Override
|
||||
protected void setupFactory() {
|
||||
protected void setupFactory() throws IOException {
|
||||
super.setupFactory();
|
||||
blobToObject = injector.getInstance(BlobToObject.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AtmosStorageRestClientModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
Names.bindProperties(binder(), new AtmosStoragePropertiesBuilder(new Properties())
|
||||
.withCredentials("uid", "key").build());
|
||||
install(new NullLoggingModule());
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "2009-11-08T15:54:08.897Z";
|
||||
}
|
||||
};
|
||||
return new TestAtmosStorageRestClientModule();
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestAtmosStorageRestClientModule extends AtmosStorageRestClientModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "Thu, 05 Jun 2008 16:38:19 GMT";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec("atmosonline", "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas;
|
||||
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersInPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Utils.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "atmosonline") : providers;
|
||||
assert Iterables.contains(providers, "synaptic") : providers;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedBlobStoreProviders() {
|
||||
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "atmosonline") : providers;
|
||||
assert Iterables.contains(providers, "synaptic") : providers;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,23 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.blobstore.config;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStoragePropertiesBuilder;
|
||||
import org.jclouds.atmosonline.saas.blobstore.strategy.FindMD5InUserMetadata;
|
||||
import org.jclouds.atmosonline.saas.config.AtmosStorageStubClientModule;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import com.google.inject.name.Names;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestClientTest.MockModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -43,16 +40,10 @@ import com.google.inject.Injector;
|
|||
public class AtmosBlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new AtmosStorageStubClientModule(),
|
||||
new AtmosBlobStoreContextModule("atmos"), new ExecutorServiceModule(sameThreadExecutor(),
|
||||
sameThreadExecutor()), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
Names.bindProperties(binder(), checkNotNull(new AtmosStoragePropertiesBuilder(
|
||||
"user", "key").build(), "properties"));
|
||||
}
|
||||
});
|
||||
return new RestContextFactory().createContextBuilder("atmosonline", "uid", "key", ImmutableSet
|
||||
.<Module> of(new MockModule(), new NullLoggingModule())).buildInjector();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testContextImpl() {
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration", "live" }, testName = "emcsaas.AtmosStorageContainerIntegrationTest")
|
||||
public class AtmosStorageContainerIntegrationTest extends BaseContainerIntegrationTest {
|
||||
@Test(groups = "live", testName = "emcsaas.AtmosStorageContainerIntegrationTest")
|
||||
public class AtmosStorageContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
|
||||
|
||||
@Override
|
||||
public void testListContainerMaxResults() throws InterruptedException,
|
|
@ -27,8 +27,8 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration", "live" }, testName = "emcsaas.AtmosStorageInputStreamMapIntegrationTest")
|
||||
public class AtmosStorageInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest {
|
||||
@Test(groups = "live", testName = "emcsaas.AtmosStorageInputStreamMapIntegrationTest")
|
||||
public class AtmosStorageInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
|
||||
|
||||
@Override
|
||||
@Test(enabled = false)
|
|
@ -27,7 +27,7 @@ import org.testng.annotations.Test;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration", "live" }, testName = "emcsaas.AtmosStorageIntegrationTest")
|
||||
public class AtmosStorageIntegrationTest extends BaseBlobIntegrationTest {
|
||||
public class AtmosStorageIntegrationLiveTest extends BaseBlobIntegrationTest {
|
||||
|
||||
@DataProvider(name = "delete")
|
||||
// no unicode support
|
|
@ -24,7 +24,7 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration", "live" }, testName = "emcsaas.AtmosStorageMapIntegrationTest")
|
||||
public class AtmosStorageMapIntegrationTest extends BaseBlobMapIntegrationTest {
|
||||
@Test(groups = "live", testName = "emcsaas.AtmosStorageMapIntegrationTest")
|
||||
public class AtmosStorageMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration", "live" }, testName = "emcsaas.AtmosStorageServiceIntegrationTest")
|
||||
public class AtmosStorageServiceIntegrationTest extends BaseServiceIntegrationTest {
|
||||
@Test(groups = "live", testName = "emcsaas.AtmosStorageServiceIntegrationTest")
|
||||
public class AtmosStorageServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
|
||||
|
||||
}
|
|
@ -21,11 +21,9 @@ package org.jclouds.atmosonline.saas.blobstore.integration;
|
|||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageContextFactory;
|
||||
import org.jclouds.atmosonline.saas.config.AtmosStorageStubClientModule;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.BlobStoreContextFactory;
|
||||
import org.jclouds.blobstore.integration.internal.BaseTestInitializer;
|
||||
import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -35,7 +33,7 @@ import com.google.inject.Module;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AtmosStorageTestInitializer extends BaseTestInitializer {
|
||||
public class AtmosStorageTestInitializer extends TransientBlobStoreTestInitializer {
|
||||
|
||||
@Override
|
||||
protected BlobStoreContext createLiveContext(Module configurationModule, String url, String app,
|
||||
|
@ -44,10 +42,4 @@ public class AtmosStorageTestInitializer extends BaseTestInitializer {
|
|||
.of(configurationModule, new Log4JLoggingModule()), new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlobStoreContext createStubContext() {
|
||||
return AtmosStorageContextFactory.createContext("user", "pass",
|
||||
new AtmosStorageStubClientModule());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.atmosonline.saas.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStorage;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
||||
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
||||
import org.jclouds.atmosonline.saas.internal.StubAtmosStorageAsyncClient;
|
||||
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
/**
|
||||
* adds a stub alternative to invoking AtmosStorage
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class AtmosStorageStubClientModule extends
|
||||
RestClientModule<AtmosStorageClient, AtmosStorageAsyncClient> {
|
||||
|
||||
public AtmosStorageStubClientModule() {
|
||||
super(AtmosStorageClient.class, AtmosStorageAsyncClient.class);
|
||||
}
|
||||
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new AtmosObjectModule());
|
||||
install(new ParserModule());
|
||||
install(new TransientBlobStoreModule());
|
||||
bind(URI.class).annotatedWith(AtmosStorage.class).toInstance(
|
||||
URI.create("https://localhost/atmosstub"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindAsyncClient() {
|
||||
bind(AtmosStorageAsyncClient.class).to(StubAtmosStorageAsyncClient.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -18,43 +18,40 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.filters;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.atmosonline.saas.AtmosStoragePropertiesBuilder;
|
||||
import org.jclouds.atmosonline.saas.config.AtmosStorageRestClientModule;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.TransformingHttpCommandExecutorService;
|
||||
import org.jclouds.rest.config.RestModule;
|
||||
import com.google.inject.name.Names;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestClientTest.MockModule;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
@Test(groups = "unit", testName = "emcsaas.SignRequestTest")
|
||||
public class SignRequestTest {
|
||||
|
||||
private static final String KEY = "LJLuryj6zs8ste6Y3jTGQp71xq0=";
|
||||
|
||||
private Injector injector;
|
||||
private SignRequest filter;
|
||||
|
||||
@Test
|
||||
|
@ -84,24 +81,31 @@ public class SignRequestTest {
|
|||
|
||||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new RestModule(), new AtmosStorageRestClientModule() {
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "Thu, 05 Jun 2008 16:38:19 GMT";
|
||||
Injector injector = new RestContextFactory().createContextBuilder(
|
||||
"atmosonline",
|
||||
"user",
|
||||
KEY,
|
||||
ImmutableSet.<Module> of(new MockModule(), new TestAtmosStorageRestClientModule(),
|
||||
new NullLoggingModule()), new Properties()).buildInjector();
|
||||
|
||||
}
|
||||
}, new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()),
|
||||
new AbstractModule() {
|
||||
protected void configure() {
|
||||
Names.bindProperties(binder(), checkNotNull(
|
||||
new AtmosStoragePropertiesBuilder("user", KEY)).build());
|
||||
bind(TransformingHttpCommandExecutorService.class).toInstance(
|
||||
createMock(TransformingHttpCommandExecutorService.class));
|
||||
}
|
||||
});
|
||||
filter = injector.getInstance(SignRequest.class);
|
||||
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
private static final class TestAtmosStorageRestClientModule extends AtmosStorageRestClientModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "Thu, 05 Jun 2008 16:38:19 GMT";
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequest newRequest() {
|
||||
HttpRequest request = new HttpRequest("POST", URI.create("http://localhost/rest/objects"));
|
||||
request.getHeaders().put(AtmosStorageHeaders.LISTABLE_META, "part4/part7/part8=quick");
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2;
|
||||
package org.jclouds.aws;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -34,6 +34,6 @@ import javax.inject.Qualifier;
|
|||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface EC2 {
|
||||
public @interface Region {
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.config;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.config.AWSRestClientModule;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the S3 connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class AWSFormSigningRestClientModule<S, A> extends AWSRestClientModule<S, A> {
|
||||
|
||||
public AWSFormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
}
|
||||
|
||||
public AWSFormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TimeStamp
|
||||
protected String provideTimeStamp(final DateService dateService,
|
||||
@Named(Constants.PROPERTY_SESSION_INTERVAL) final int expiration) {
|
||||
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()
|
||||
+ (expiration * 1000)));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RequestSigner provideRequestSigner(FormSigner in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.config;
|
||||
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Configures the S3 connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class AWSRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
public AWSRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
}
|
||||
|
||||
public AWSRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Region
|
||||
protected Map<String, URI> provideRegions(Injector injector) {
|
||||
String regionString = injector.getInstance(Key.get(String.class, Names
|
||||
.named(PROPERTY_REGIONS)));
|
||||
Map<String, URI> regions = Maps.newLinkedHashMap();
|
||||
for (String region : Splitter.on(',').split(regionString)) {
|
||||
regions.put(region, URI.create(injector.getInstance(Key.get(String.class, Names
|
||||
.named(Constants.PROPERTY_ENDPOINT + "." + region)))));
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Region
|
||||
protected Set<String> provideRegions(@Region Map<String, URI> map) {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Region
|
||||
protected String getDefaultRegion(@Provider final URI uri, @Region Map<String, URI> map) {
|
||||
return Iterables.find(map.entrySet(), new Predicate<Entry<String, URI>>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Entry<String, URI> input) {
|
||||
return input.getValue().equals(uri);
|
||||
}
|
||||
|
||||
}).getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
|
||||
AWSRedirectionRetryHandler.class);
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.config;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class DefaultLocationProvider implements javax.inject.Provider<Location> {
|
||||
private final String region;
|
||||
private final Set<? extends Location> set;
|
||||
|
||||
@Inject
|
||||
DefaultLocationProvider(@Region final String region, Set<? extends Location> set) {
|
||||
this.region = region;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Singleton
|
||||
public Location get() {
|
||||
try {
|
||||
Location toReturn = Iterables.find(set, new Predicate<Location>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Location input) {
|
||||
switch (input.getScope()) {
|
||||
case ZONE:
|
||||
return input.getParent().getId().equals(region);
|
||||
case REGION:
|
||||
return input.getId().equals(region);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent();
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new IllegalStateException(String.format("region: %s not found in %s", region, set));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,48 +16,58 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.mezeo.pcs2.config;
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import java.net.URI;
|
||||
import java.io.Closeable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.elb.ELBAsyncClient;
|
||||
import org.jclouds.aws.elb.ELBClient;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.mezeo.pcs2.PCS;
|
||||
import org.jclouds.mezeo.pcs2.PCSAsyncClient;
|
||||
import org.jclouds.mezeo.pcs2.PCSClient;
|
||||
import org.jclouds.mezeo.pcs2.reference.PCSConstants;
|
||||
import org.jclouds.rest.HttpAsyncClient;
|
||||
import org.jclouds.rest.HttpClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the PCS connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class PCSContextModule extends AbstractModule {
|
||||
public PCSContextModule(String providerName) {
|
||||
public class ConfigureELBModule extends AbstractModule {
|
||||
private final Iterable<Module> infra;
|
||||
private final Properties properties;
|
||||
|
||||
ConfigureELBModule(Iterable<Module> infra, Properties properties) {
|
||||
this.infra = infra;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* setup ELB with the same parameters as EC2
|
||||
*/
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<PCSClient, PCSAsyncClient> provideContext(Closer closer,
|
||||
HttpClient http, HttpAsyncClient asyncHttp, PCSAsyncClient async,
|
||||
PCSClient defaultApi, @PCS URI endPoint,
|
||||
@Named(PCSConstants.PROPERTY_PCS2_USER) String account) {
|
||||
return new RestContextImpl<PCSClient, PCSAsyncClient>(closer, http,
|
||||
asyncHttp, defaultApi, async, endPoint, account);
|
||||
}
|
||||
ELBClient provideELBClient(Closer closer) {
|
||||
final RestContext<ELBClient, ELBAsyncClient> context = new RestContextFactory()
|
||||
.createContext("elb", infra, properties);
|
||||
closer.addToClose(new Closeable() {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
|
||||
});
|
||||
return context.getApi();
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ import org.jclouds.aws.ec2.services.AMIAsyncClient;
|
|||
import org.jclouds.aws.ec2.services.AvailabilityZoneAndRegionAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticBlockStoreAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticIPAddressAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.InstanceAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.KeyPairAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
|
||||
|
@ -35,6 +34,8 @@ import org.jclouds.rest.annotations.Delegate;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public interface EC2AsyncClient {
|
||||
public final static String VERSION = "2009-11-30";
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to AMI services.
|
||||
*/
|
||||
|
@ -83,9 +84,4 @@ public interface EC2AsyncClient {
|
|||
@Delegate
|
||||
ElasticBlockStoreAsyncClient getElasticBlockStoreServices();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Elastic Load Balancer services.
|
||||
*/
|
||||
@Delegate
|
||||
ElasticLoadBalancerAsyncClient getElasticLoadBalancerServices();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.jclouds.aws.ec2.services.AMIClient;
|
|||
import org.jclouds.aws.ec2.services.AvailabilityZoneAndRegionClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticBlockStoreClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticIPAddressClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerClient;
|
||||
import org.jclouds.aws.ec2.services.InstanceClient;
|
||||
import org.jclouds.aws.ec2.services.KeyPairClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringClient;
|
||||
|
@ -87,9 +86,4 @@ public interface EC2Client {
|
|||
@Delegate
|
||||
ElasticBlockStoreClient getElasticBlockStoreServices();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Elastic Load Balancer services.
|
||||
*/
|
||||
@Delegate
|
||||
ElasticLoadBalancerClient getElasticLoadBalancerServices();
|
||||
}
|
||||
|
|
|
@ -18,16 +18,26 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static com.google.common.base.Predicates.instanceOf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule;
|
||||
import org.jclouds.aws.ec2.compute.config.EC2ResolveImagesModule;
|
||||
import org.jclouds.aws.ec2.config.EC2RestClientModule;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
||||
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.config.LoggingModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -46,8 +56,8 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public class EC2ContextBuilder extends ComputeServiceContextBuilder<EC2Client, EC2AsyncClient> {
|
||||
|
||||
public EC2ContextBuilder(String providerName, Properties props) {
|
||||
super(providerName, EC2Client.class, EC2AsyncClient.class, props);
|
||||
public EC2ContextBuilder(Properties props) {
|
||||
super(EC2Client.class, EC2AsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,8 +66,8 @@ public class EC2ContextBuilder extends ComputeServiceContextBuilder<EC2Client, E
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(String providerName, List<Module> modules) {
|
||||
modules.add(new EC2ComputeServiceContextModule(providerName));
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new EC2ComputeServiceContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,4 +79,23 @@ public class EC2ContextBuilder extends ComputeServiceContextBuilder<EC2Client, E
|
|||
protected void addImageResolutionModule() {
|
||||
modules.add(new EC2ResolveImagesModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector buildInjector() {
|
||||
try {
|
||||
Iterables.find(modules, Predicates.instanceOf(ConfigureELBModule.class));
|
||||
} catch (NoSuchElementException e) {
|
||||
Iterable<Module> infra = Iterables.filter(modules, new Predicate<Module>() {
|
||||
public boolean apply(Module input) {
|
||||
return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class)
|
||||
|| input.getClass().isAnnotationPresent(
|
||||
ConfiguresHttpCommandExecutorService.class)
|
||||
|| instanceOf(LoggingModule.class).apply(input);
|
||||
}
|
||||
|
||||
});
|
||||
modules.add(new ConfigureELBModule(infra, properties));
|
||||
}
|
||||
return super.buildInjector();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.ec2;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link EC2ComputeServiceContext} instances based on the most commonly requested
|
||||
* arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see EC2ComputeServiceContext
|
||||
*/
|
||||
public class EC2ContextFactory {
|
||||
public static ComputeServiceContext createContext(Properties properties, Module... modules) {
|
||||
return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(properties).build())
|
||||
.withModules(modules).buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(awsAccessKeyId,
|
||||
awsSecretAccessKey).build()).withModules(modules).buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(Properties properties, String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(properties).withCredentials(
|
||||
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules)
|
||||
.buildComputeServiceContext();
|
||||
}
|
||||
|
||||
public static ComputeServiceContext createContext(URI endpoint, String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(awsAccessKeyId,
|
||||
awsSecretAccessKey).withEndpoint(endpoint).build()).withModules(modules)
|
||||
.buildComputeServiceContext();
|
||||
}
|
||||
}
|
|
@ -18,14 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.*;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_ELB_ENDPOINT;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
|
@ -39,17 +36,18 @@ public class EC2PropertiesBuilder extends PropertiesBuilder {
|
|||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_EC2_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_API_VERSION, EC2AsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_ELB_ENDPOINT,
|
||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
||||
// alestic, canonical, and rightscale
|
||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "063491364108,099720109477,411009282317");
|
||||
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
||||
// authorized key executes after ssh has started
|
||||
properties.setProperty("jclouds.ssh.max_retries", "6");
|
||||
properties.setProperty("jclouds.ssh.retryable_messages",
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established");
|
||||
properties
|
||||
.setProperty("jclouds.ssh.retryable_messages",
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -57,25 +55,7 @@ public class EC2PropertiesBuilder extends PropertiesBuilder {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public EC2PropertiesBuilder(String id, String secret) {
|
||||
public EC2PropertiesBuilder() {
|
||||
super();
|
||||
withCredentials(id, secret);
|
||||
}
|
||||
|
||||
public EC2PropertiesBuilder withCredentials(String id, String secret) {
|
||||
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(id, "awsAccessKeyId"));
|
||||
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(secret,
|
||||
"awsSecretAccessKey"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public EC2PropertiesBuilder withEndpoint(URI endpoint) {
|
||||
properties.setProperty(PROPERTY_EC2_ENDPOINT, checkNotNull(endpoint, "endpoint").toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public EC2PropertiesBuilder withRequestExpiration(long seconds) {
|
||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, seconds + "");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.ec2;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Related to a ELB resource.
|
||||
*
|
||||
* @author Lili Nader
|
||||
*
|
||||
*/
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface ELB {
|
||||
|
||||
}
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_ENDPOINT;
|
||||
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_PORT_OPEN;
|
||||
|
||||
import java.util.Properties;
|
||||
|
@ -33,8 +33,8 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
|
|||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_EC2_ENDPOINT,
|
||||
"http://ecc.eucalyptus.com:8773/services/Eucalyptus");
|
||||
properties.setProperty(PROPERTY_ENDPOINT,
|
||||
"http://ecc.eucalyptus.com:8773/services/Eucalyptus");
|
||||
// TODO
|
||||
// properties.setProperty(PROPERTY_ELB_ENDPOINT,
|
||||
// "https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
|
@ -48,7 +48,4 @@ public class EucalyptusPropertiesBuilder extends EC2PropertiesBuilder {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public EucalyptusPropertiesBuilder(String id, String secret) {
|
||||
super(id, secret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.config.DefaultLocationProvider;
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.compute.EC2ComputeService;
|
||||
|
@ -61,7 +62,6 @@ import org.jclouds.aws.ec2.compute.strategy.EC2DestroyLoadBalancerStrategy;
|
|||
import org.jclouds.aws.ec2.compute.strategy.EC2DestroyNodeStrategy;
|
||||
import org.jclouds.aws.ec2.compute.strategy.EC2LoadBalanceNodesStrategy;
|
||||
import org.jclouds.aws.ec2.compute.strategy.EC2RunNodesAndAddToSetStrategy;
|
||||
import org.jclouds.aws.ec2.config.EC2ContextModule;
|
||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||
|
@ -95,6 +95,9 @@ import org.jclouds.domain.LocationScope;
|
|||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -106,58 +109,49 @@ import com.google.common.collect.MapMaker;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Configures the {@link ComputeServiceContext}; requires
|
||||
* {@link EC2ComputeService} bound.
|
||||
* Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||
|
||||
private final String providerName;
|
||||
|
||||
public EC2ComputeServiceContextModule(String providerName) {
|
||||
this.providerName = providerName;
|
||||
}
|
||||
public class EC2ComputeServiceContextModule extends AbstractModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@Named("PRESENT")
|
||||
protected Predicate<RunningInstance> instancePresent(InstancePresent present) {
|
||||
return new RetryablePredicate<RunningInstance>(present, 3000, 200,
|
||||
TimeUnit.MILLISECONDS);
|
||||
return new RetryablePredicate<RunningInstance>(present, 3000, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new ComputeServiceTimeoutsModule());
|
||||
bind(Location.class).toProvider(DefaultLocationProvider.class).in(Scopes.SINGLETON);
|
||||
bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
|
||||
bind(TemplateOptions.class).to(EC2TemplateOptions.class);
|
||||
bind(ComputeService.class).to(EC2ComputeService.class);
|
||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||
})
|
||||
.to(
|
||||
new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(LoadBalanceNodesStrategy.class)
|
||||
.to(EC2LoadBalanceNodesStrategy.class);
|
||||
bind(DestroyLoadBalancerStrategy.class).to(
|
||||
EC2DestroyLoadBalancerStrategy.class);
|
||||
bind(RunNodesAndAddToSetStrategy.class).to(
|
||||
EC2RunNodesAndAddToSetStrategy.class);
|
||||
}).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(new TypeLiteral<RestContext<EC2Client, EC2AsyncClient>>() {
|
||||
}).to(new TypeLiteral<RestContextImpl<EC2Client, EC2AsyncClient>>() {
|
||||
}).in(Scopes.SINGLETON);
|
||||
bind(LoadBalanceNodesStrategy.class).to(EC2LoadBalanceNodesStrategy.class);
|
||||
bind(DestroyLoadBalancerStrategy.class).to(EC2DestroyLoadBalancerStrategy.class);
|
||||
bind(RunNodesAndAddToSetStrategy.class).to(EC2RunNodesAndAddToSetStrategy.class);
|
||||
bind(ListNodesStrategy.class).to(EC2ListNodesStrategy.class);
|
||||
bind(GetNodeMetadataStrategy.class).to(EC2GetNodeMetadataStrategy.class);
|
||||
bind(RebootNodeStrategy.class).to(EC2RebootNodeStrategy.class);
|
||||
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
|
||||
bind(new TypeLiteral<Function<RunningInstance, Map<String, String>>>() {
|
||||
}).annotatedWith(Names.named("volumeMapping")).to(
|
||||
RunningInstanceToStorageMappingUnix.class).in(Scopes.SINGLETON);
|
||||
}).annotatedWith(Names.named("volumeMapping")).to(RunningInstanceToStorageMappingUnix.class)
|
||||
.in(Scopes.SINGLETON);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -176,12 +170,10 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
|
||||
@Provides
|
||||
@Named("DEFAULT")
|
||||
protected TemplateBuilder provideTemplate(@EC2 String region,
|
||||
TemplateBuilder template) {
|
||||
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest()
|
||||
: template.architecture(Architecture.X86_32).osFamily(UBUNTU)
|
||||
.imageNameMatches(".*10\\.?04.*").osDescriptionMatches(
|
||||
"^ubuntu-images.*");
|
||||
protected TemplateBuilder provideTemplate(@Region String region, TemplateBuilder template) {
|
||||
return "Eucalyptus".equals(region) ? template.osFamily(CENTOS).smallest() : template
|
||||
.architecture(Architecture.X86_32).osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*")
|
||||
.osDescriptionMatches("^ubuntu-images.*");
|
||||
}
|
||||
|
||||
// TODO make this more efficient for listNodes(); currently
|
||||
|
@ -199,10 +191,9 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
protected EC2ListNodesStrategy(EC2Client client,
|
||||
@EC2 Map<String, URI> regionMap,
|
||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
protected EC2ListNodesStrategy(EC2Client client, @Region Map<String, URI> regionMap,
|
||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.client = client;
|
||||
this.regionMap = regionMap;
|
||||
this.runningInstanceToNodeMetadata = runningInstanceToNodeMetadata;
|
||||
|
@ -216,44 +207,42 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
|
||||
@Override
|
||||
public Iterable<? extends NodeMetadata> listDetailsOnNodesMatching(
|
||||
Predicate<ComputeMetadata> filter) {
|
||||
Predicate<ComputeMetadata> filter) {
|
||||
final Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||
|
||||
Map<String, ListenableFuture<?>> parallelResponses = Maps.newHashMap();
|
||||
|
||||
for (final String region : regionMap.keySet()) {
|
||||
parallelResponses.put(region, ConcurrentUtils.makeListenable(
|
||||
executor.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
Iterables.addAll(nodes, Iterables.transform(Iterables
|
||||
.concat(client.getInstanceServices()
|
||||
.describeInstancesInRegion(region)),
|
||||
runningInstanceToNodeMetadata));
|
||||
return null;
|
||||
}
|
||||
}), executor));
|
||||
parallelResponses.put(region, ConcurrentUtils.makeListenable(executor
|
||||
.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
Iterables.addAll(nodes, Iterables.transform(Iterables.concat(client
|
||||
.getInstanceServices().describeInstancesInRegion(region)),
|
||||
runningInstanceToNodeMetadata));
|
||||
return null;
|
||||
}
|
||||
}), executor));
|
||||
}
|
||||
Map<String, Exception> exceptions = awaitCompletion(parallelResponses,
|
||||
executor, null, logger, "nodes");
|
||||
Map<String, Exception> exceptions = awaitCompletion(parallelResponses, executor, null,
|
||||
logger, "nodes");
|
||||
|
||||
if (exceptions.size() > 0)
|
||||
throw new RuntimeException(String.format(
|
||||
"error parsing nodes in regions: %s", exceptions));
|
||||
throw new RuntimeException(String.format("error parsing nodes in regions: %s",
|
||||
exceptions));
|
||||
return Iterables.filter(nodes, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class EC2GetNodeMetadataStrategy implements
|
||||
GetNodeMetadataStrategy {
|
||||
public static class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy {
|
||||
|
||||
private final EC2Client client;
|
||||
private final RunningInstanceToNodeMetadata runningInstanceToNodeMetadata;
|
||||
|
||||
@Inject
|
||||
protected EC2GetNodeMetadataStrategy(EC2Client client,
|
||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata) {
|
||||
RunningInstanceToNodeMetadata runningInstanceToNodeMetadata) {
|
||||
this.client = client;
|
||||
this.runningInstanceToNodeMetadata = runningInstanceToNodeMetadata;
|
||||
}
|
||||
|
@ -265,8 +254,8 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
String instanceId = parts[1];
|
||||
try {
|
||||
RunningInstance runningInstance = Iterables
|
||||
.getOnlyElement(getAllRunningInstancesInRegion(client
|
||||
.getInstanceServices(), region, instanceId));
|
||||
.getOnlyElement(getAllRunningInstancesInRegion(client.getInstanceServices(),
|
||||
region, instanceId));
|
||||
return runningInstanceToNodeMetadata.apply(runningInstance);
|
||||
} catch (NoSuchElementException e) {
|
||||
return null;
|
||||
|
@ -281,8 +270,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
private final GetNodeMetadataStrategy getNode;
|
||||
|
||||
@Inject
|
||||
protected EC2RebootNodeStrategy(EC2Client client,
|
||||
GetNodeMetadataStrategy getNode) {
|
||||
protected EC2RebootNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode) {
|
||||
this.client = client.getInstanceServices();
|
||||
this.getNode = getNode;
|
||||
}
|
||||
|
@ -300,8 +288,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected final Map<RegionAndName, KeyPair> credentialsMap(
|
||||
CreateUniqueKeyPair in) {
|
||||
protected final Map<RegionAndName, KeyPair> credentialsMap(CreateUniqueKeyPair in) {
|
||||
// doesn't seem to clear when someone issues remove(key)
|
||||
// return new MapMaker().makeComputingMap(in);
|
||||
return Maps.newLinkedHashMap();
|
||||
|
@ -309,8 +296,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected final Map<RegionAndName, String> securityGroupMap(
|
||||
CreateSecurityGroupIfNeeded in) {
|
||||
protected final Map<RegionAndName, String> securityGroupMap(CreateSecurityGroupIfNeeded in) {
|
||||
// doesn't seem to clear when someone issues remove(key)
|
||||
// return new MapMaker().makeComputingMap(in);
|
||||
return Maps.newLinkedHashMap();
|
||||
|
@ -330,43 +316,26 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
Set<? extends Size> provideSizes() {
|
||||
return ImmutableSet.of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE,
|
||||
EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE,
|
||||
EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE);
|
||||
return ImmutableSet.of(EC2Size.C1_MEDIUM, EC2Size.C1_XLARGE, EC2Size.M1_LARGE,
|
||||
EC2Size.M1_SMALL, EC2Size.M1_XLARGE, EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE,
|
||||
EC2Size.M2_4XLARGE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Set<? extends Location> provideLocations(
|
||||
Map<String, String> availabilityZoneToRegionMap) {
|
||||
Location ec2 = new LocationImpl(LocationScope.PROVIDER, providerName,
|
||||
providerName, null);
|
||||
Set<? extends Location> provideLocations(Map<String, String> availabilityZoneToRegionMap,
|
||||
@Provider String providerName) {
|
||||
Location ec2 = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
Set<Location> locations = Sets.newLinkedHashSet();
|
||||
for (String zone : availabilityZoneToRegionMap.keySet()) {
|
||||
Location region = new LocationImpl(LocationScope.REGION,
|
||||
availabilityZoneToRegionMap.get(zone),
|
||||
availabilityZoneToRegionMap.get(zone), ec2);
|
||||
Location region = new LocationImpl(LocationScope.REGION, availabilityZoneToRegionMap
|
||||
.get(zone), availabilityZoneToRegionMap.get(zone), ec2);
|
||||
locations.add(region);
|
||||
locations
|
||||
.add(new LocationImpl(LocationScope.ZONE, zone, zone, region));
|
||||
locations.add(new LocationImpl(LocationScope.ZONE, zone, zone, region));
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Location getDefaultLocation(@EC2 final String region,
|
||||
Set<? extends Location> set) {
|
||||
return Iterables.find(set, new Predicate<Location>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Location input) {
|
||||
return input.getId().equals(region);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private static class LogHolder {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
|
@ -383,28 +352,26 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
protected Set<? extends Image> provideImages(
|
||||
Map<RegionAndName, ? extends Image> map) {
|
||||
protected Set<? extends Image> provideImages(Map<RegionAndName, ? extends Image> map) {
|
||||
return ImmutableSet.copyOf(map.values());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected ConcurrentMap<RegionAndName, Image> provideImageMap(
|
||||
RegionAndIdToImage regionAndIdToImage) {
|
||||
RegionAndIdToImage regionAndIdToImage) {
|
||||
return new MapMaker().makeComputingMap(regionAndIdToImage);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Map<RegionAndName, ? extends Image> provideImages(
|
||||
final EC2Client sync, @EC2 Map<String, URI> regionMap,
|
||||
final LogHolder holder, Function<ComputeMetadata, String> indexer,
|
||||
@Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners,
|
||||
final ImageParser parser,
|
||||
final ConcurrentMap<RegionAndName, Image> images,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
protected Map<RegionAndName, ? extends Image> provideImages(final EC2Client sync,
|
||||
@Region Map<String, URI> regionMap, final LogHolder holder,
|
||||
Function<ComputeMetadata, String> indexer,
|
||||
@Named(PROPERTY_EC2_AMI_OWNERS) final String[] amiOwners, final ImageParser parser,
|
||||
final ConcurrentMap<RegionAndName, Image> images,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
if (amiOwners.length == 0) {
|
||||
holder.logger.debug(">> no owners specified, skipping image parsing");
|
||||
} else {
|
||||
|
@ -417,31 +384,30 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
|||
else
|
||||
options = ownedBy(amiOwners);
|
||||
for (final String region : regionMap.keySet()) {
|
||||
parallelResponses.put(region, ConcurrentUtils.makeListenable(
|
||||
executor.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
for (final org.jclouds.aws.ec2.domain.Image from : sync
|
||||
.getAMIServices().describeImagesInRegion(region,
|
||||
options)) {
|
||||
Image image = parser.apply(from);
|
||||
if (image != null)
|
||||
images.put(new RegionAndName(region, image
|
||||
.getProviderId()), image);
|
||||
else if (from.getImageType() == ImageType.MACHINE)
|
||||
holder.logger.trace("<< image(%s) didn't parse",
|
||||
from.getId());
|
||||
parallelResponses.put(region, ConcurrentUtils.makeListenable(executor
|
||||
.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
for (final org.jclouds.aws.ec2.domain.Image from : sync.getAMIServices()
|
||||
.describeImagesInRegion(region, options)) {
|
||||
Image image = parser.apply(from);
|
||||
if (image != null)
|
||||
images
|
||||
.put(new RegionAndName(region, image.getProviderId()),
|
||||
image);
|
||||
else if (from.getImageType() == ImageType.MACHINE)
|
||||
holder.logger.trace("<< image(%s) didn't parse", from.getId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}), executor));
|
||||
}), executor));
|
||||
}
|
||||
Map<String, Exception> exceptions = awaitCompletion(parallelResponses,
|
||||
executor, null, holder.logger, "images");
|
||||
Map<String, Exception> exceptions = awaitCompletion(parallelResponses, executor, null,
|
||||
holder.logger, "images");
|
||||
|
||||
if (exceptions.size() > 0)
|
||||
throw new RuntimeException(String.format(
|
||||
"error parsing images in regions: %s", exceptions));
|
||||
throw new RuntimeException(String.format("error parsing images in regions: %s",
|
||||
exceptions));
|
||||
|
||||
holder.logger.debug("<< images(%d)", images.size());
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
package org.jclouds.aws.ec2.compute.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.compute.util.ComputeUtils.parseOsFamilyOrNull;
|
||||
import static org.jclouds.compute.util.ComputeUtils.parseVersionOrReturnEmptyString;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.parseVersionOrReturnEmptyString;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
@ -54,22 +54,21 @@ import com.google.common.collect.Iterables;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ImageParser implements
|
||||
Function<org.jclouds.aws.ec2.domain.Image, Image> {
|
||||
public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, Image> {
|
||||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
public static final Pattern CANONICAL_PATTERN = Pattern
|
||||
.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
|
||||
.compile(".*/([^-]*)-([^-]*)-.*-(.*)(\\.manifest.xml)?");
|
||||
|
||||
// ex rightscale-us-east/CentOS_5.4_x64_v4.4.10.manifest.xml
|
||||
public static final Pattern RIGHTSCALE_PATTERN = Pattern
|
||||
.compile("[^/]*/([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
|
||||
.compile("[^/]*/([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
|
||||
|
||||
// ex 411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha
|
||||
public static final Pattern RIGHTIMAGE_PATTERN = Pattern
|
||||
.compile("[^/]*/RightImage_([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
|
||||
.compile("[^/]*/RightImage_([^_]*)_([^_]*)_[^vV]*[vV](.*)(\\.manifest.xml)?");
|
||||
|
||||
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
||||
private final Set<? extends Location> locations;
|
||||
|
@ -77,11 +76,9 @@ public class ImageParser implements
|
|||
private final Location defaultLocation;
|
||||
|
||||
@Inject
|
||||
ImageParser(
|
||||
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||
Set<? extends Location> locations, Location defaultLocation) {
|
||||
this.credentialProvider = checkNotNull(credentialProvider,
|
||||
"credentialProvider");
|
||||
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||
Set<? extends Location> locations, Location defaultLocation) {
|
||||
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
||||
this.locations = checkNotNull(locations, "locations");
|
||||
this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
|
||||
|
||||
|
@ -99,8 +96,8 @@ public class ImageParser implements
|
|||
}
|
||||
OsFamily os = parseOsFamilyOrNull(from.getImageLocation());
|
||||
String name = parseVersionOrReturnEmptyString(os, from.getImageLocation());
|
||||
String description = from.getDescription() != null ? from
|
||||
.getDescription() : from.getImageLocation();
|
||||
String description = from.getDescription() != null ? from.getDescription() : from
|
||||
.getImageLocation();
|
||||
String osDescription = from.getImageLocation();
|
||||
String version = "";
|
||||
|
||||
|
@ -128,24 +125,24 @@ public class ImageParser implements
|
|||
|
||||
});
|
||||
} catch (NoSuchElementException e) {
|
||||
System.err.printf("unknown region %s for image %s; not in %s", from
|
||||
.getRegion(), from.getId(), locations);
|
||||
location = new LocationImpl(LocationScope.REGION, from.getRegion(),
|
||||
from.getRegion(), defaultLocation.getParent());
|
||||
System.err.printf("unknown region %s for image %s; not in %s", from.getRegion(), from
|
||||
.getId(), locations);
|
||||
location = new LocationImpl(LocationScope.REGION, from.getRegion(), from.getRegion(),
|
||||
defaultLocation.getParent());
|
||||
}
|
||||
return new ImageImpl(
|
||||
from.getId(),
|
||||
name,
|
||||
from.getRegion() + "/" + from.getId(),
|
||||
location,
|
||||
null,
|
||||
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
||||
description,
|
||||
version,
|
||||
os,
|
||||
osDescription,
|
||||
from.getArchitecture() == org.jclouds.aws.ec2.domain.Image.Architecture.I386 ? Architecture.X86_32
|
||||
: Architecture.X86_64, defaultCredentials);
|
||||
from.getId(),
|
||||
name,
|
||||
from.getRegion() + "/" + from.getId(),
|
||||
location,
|
||||
null,
|
||||
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
||||
description,
|
||||
version,
|
||||
os,
|
||||
osDescription,
|
||||
from.getArchitecture() == org.jclouds.aws.ec2.domain.Image.Architecture.I386 ? Architecture.X86_32
|
||||
: Architecture.X86_64, defaultCredentials);
|
||||
|
||||
}
|
||||
|
||||
|
@ -155,8 +152,8 @@ public class ImageParser implements
|
|||
* if no configured matcher matches the manifest.
|
||||
*/
|
||||
private Matcher getMatcherAndFind(String manifest) {
|
||||
for (Pattern pattern : new Pattern[] { CANONICAL_PATTERN,
|
||||
RIGHTIMAGE_PATTERN, RIGHTSCALE_PATTERN }) {
|
||||
for (Pattern pattern : new Pattern[] { CANONICAL_PATTERN, RIGHTIMAGE_PATTERN,
|
||||
RIGHTSCALE_PATTERN }) {
|
||||
Matcher matcher = pattern.matcher(manifest);
|
||||
if (matcher.find())
|
||||
return matcher;
|
||||
|
|
|
@ -28,8 +28,8 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.aws.elb.ELBClient;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -44,11 +44,11 @@ public class EC2DestroyLoadBalancerStrategy implements DestroyLoadBalancerStrate
|
|||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final EC2Client client;
|
||||
private final ELBClient elbClient;
|
||||
|
||||
@Inject
|
||||
protected EC2DestroyLoadBalancerStrategy(EC2Client client) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
protected EC2DestroyLoadBalancerStrategy(ELBClient elbClient) {
|
||||
this.elbClient = checkNotNull(elbClient, "elbClient");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,7 @@ public class EC2DestroyLoadBalancerStrategy implements DestroyLoadBalancerStrate
|
|||
Map<String, String> tuple = EC2Utils.getLoadBalancerNameAndRegionFromDnsName(loadBalancer);
|
||||
// Only one load balancer per DNS name is expected
|
||||
for (String key : tuple.keySet()) {
|
||||
client.getElasticLoadBalancerServices().deleteLoadBalancerInRegion(key, tuple.get(key));
|
||||
elbClient.deleteLoadBalancerInRegion(key, tuple.get(key));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,10 +28,9 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerClient;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils.GetRegionFromLocation;
|
||||
import org.jclouds.aws.elb.ELBClient;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.compute.strategy.LoadBalanceNodesStrategy;
|
||||
import org.jclouds.domain.Location;
|
||||
|
@ -46,13 +45,13 @@ public class EC2LoadBalanceNodesStrategy implements LoadBalanceNodesStrategy {
|
|||
@Resource
|
||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
protected final EC2Client ec2Client;
|
||||
protected final ELBClient elbClient;
|
||||
protected final GetRegionFromLocation getRegionFromLocation;
|
||||
|
||||
@Inject
|
||||
protected EC2LoadBalanceNodesStrategy(EC2Client ec2Client,
|
||||
protected EC2LoadBalanceNodesStrategy(ELBClient elbClient,
|
||||
GetRegionFromLocation getRegionFromLocation) {
|
||||
this.ec2Client = ec2Client;
|
||||
this.elbClient = elbClient;
|
||||
this.getRegionFromLocation = getRegionFromLocation;
|
||||
}
|
||||
|
||||
|
@ -69,8 +68,6 @@ public class EC2LoadBalanceNodesStrategy implements LoadBalanceNodesStrategy {
|
|||
availabilityZone = az;
|
||||
}
|
||||
|
||||
ElasticLoadBalancerClient elbClient = ec2Client.getElasticLoadBalancerServices();
|
||||
|
||||
dnsName = elbClient.createLoadBalancerInRegion(region, name, protocol, loadBalancerPort,
|
||||
instancePort, availabilityZone);
|
||||
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.ec2.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.http.functions.config.ParserModule.CDateAdapter;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.HttpAsyncClient;
|
||||
import org.jclouds.rest.HttpClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the EC2 connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2ContextModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(CDateAdapter.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<EC2Client, EC2AsyncClient> provideContext(Closer closer,
|
||||
HttpClient http, HttpAsyncClient asyncHttp, EC2AsyncClient defaultApi,
|
||||
EC2Client synchApi, @EC2 URI endPoint,
|
||||
@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String account) {
|
||||
return new RestContextImpl<EC2Client, EC2AsyncClient>(closer, http,
|
||||
asyncHttp, synchApi, defaultApi, endPoint, account);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,19 +19,15 @@
|
|||
package org.jclouds.aws.ec2.config;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.config.AWSFormSigningRestClientModule;
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.ELB;
|
||||
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.jclouds.aws.ec2.reference.EC2Constants;
|
||||
import org.jclouds.aws.ec2.services.AMIAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AMIClient;
|
||||
import org.jclouds.aws.ec2.services.AvailabilityZoneAndRegionAsyncClient;
|
||||
|
@ -40,8 +36,6 @@ import org.jclouds.aws.ec2.services.ElasticBlockStoreAsyncClient;
|
|||
import org.jclouds.aws.ec2.services.ElasticBlockStoreClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticIPAddressAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticIPAddressClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.ElasticLoadBalancerClient;
|
||||
import org.jclouds.aws.ec2.services.InstanceAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.InstanceClient;
|
||||
import org.jclouds.aws.ec2.services.KeyPairAsyncClient;
|
||||
|
@ -50,25 +44,12 @@ import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
|
|||
import org.jclouds.aws.ec2.services.MonitoringClient;
|
||||
import org.jclouds.aws.ec2.services.SecurityGroupAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.SecurityGroupClient;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -78,73 +59,28 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class EC2RestClientModule extends
|
||||
RestClientModule<EC2Client, EC2AsyncClient> {
|
||||
public class EC2RestClientModule extends AWSFormSigningRestClientModule<EC2Client, EC2AsyncClient> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap
|
||||
.<Class<?>, Class<?>> builder()//
|
||||
.put(AMIClient.class, AMIAsyncClient.class)//
|
||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||
.put(InstanceClient.class, InstanceAsyncClient.class)//
|
||||
.put(KeyPairClient.class, KeyPairAsyncClient.class)//
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||
.put(MonitoringClient.class, MonitoringAsyncClient.class)//
|
||||
.put(AvailabilityZoneAndRegionClient.class,
|
||||
AvailabilityZoneAndRegionAsyncClient.class)//
|
||||
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
||||
.put(ElasticLoadBalancerClient.class,
|
||||
ElasticLoadBalancerAsyncClient.class)//
|
||||
.build();
|
||||
.<Class<?>, Class<?>> builder()//
|
||||
.put(AMIClient.class, AMIAsyncClient.class)//
|
||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||
.put(InstanceClient.class, InstanceAsyncClient.class)//
|
||||
.put(KeyPairClient.class, KeyPairAsyncClient.class)//
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||
.put(MonitoringClient.class, MonitoringAsyncClient.class)//
|
||||
.put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
|
||||
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
||||
.build();
|
||||
|
||||
public EC2RestClientModule() {
|
||||
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@ELB
|
||||
protected URI provideELBURI(
|
||||
@Named(EC2Constants.PROPERTY_ELB_ENDPOINT) String endpoint) {
|
||||
return URI.create(endpoint);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@ELB
|
||||
Map<String, URI> provideELBRegions() {
|
||||
return ImmutableMap
|
||||
.<String, URI> of(
|
||||
Region.US_EAST_1,
|
||||
URI
|
||||
.create("https://elasticloadbalancing.us-east-1.amazonaws.com"),
|
||||
Region.US_WEST_1,
|
||||
URI
|
||||
.create("https://elasticloadbalancing.us-west-1.amazonaws.com"),
|
||||
Region.EU_WEST_1,
|
||||
URI
|
||||
.create("https://elasticloadbalancing.eu-west-1.amazonaws.com"),
|
||||
Region.AP_SOUTHEAST_1,
|
||||
URI
|
||||
.create("https://elasticloadbalancing.ap-southeast-1.amazonaws.com"));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@EC2
|
||||
String provideCurrentRegion(@EC2 Map<String, URI> regionMap,
|
||||
@EC2 URI currentUri) {
|
||||
ImmutableBiMap<URI, String> map = ImmutableBiMap.<String, URI> builder()
|
||||
.putAll(regionMap).build().inverse();
|
||||
String region = map.get(currentUri);
|
||||
assert region != null : currentUri + " not in " + map;
|
||||
return region;
|
||||
}
|
||||
|
||||
private RuntimeException regionException = null;
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@EC2
|
||||
Map<String, URI> provideRegions(EC2Client client) {
|
||||
@Override
|
||||
protected Map<String, URI> provideRegions(Injector injector) {
|
||||
// http://code.google.com/p/google-guice/issues/detail?id=483
|
||||
// guice doesn't remember when singleton providers throw exceptions.
|
||||
// in this case, if describeRegions fails, it is called again for
|
||||
|
@ -152,6 +88,7 @@ public class EC2RestClientModule extends
|
|||
// we remember the last exception trusting that guice is single-threaded
|
||||
if (regionException != null)
|
||||
throw regionException;
|
||||
EC2Client client = injector.getInstance(EC2Client.class);
|
||||
try {
|
||||
return client.getAvailabilityZoneAndRegionServices().describeRegions();
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -162,56 +99,16 @@ public class EC2RestClientModule extends
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
Map<String, String> provideAvailabilityZoneToRegions(EC2Client client,
|
||||
@EC2 Map<String, URI> regions) {
|
||||
protected Map<String, String> provideAvailabilityZoneToRegions(EC2Client client,
|
||||
@Region Map<String, URI> regions) {
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
for (String region : regions.keySet()) {
|
||||
for (AvailabilityZoneInfo zoneInfo : client
|
||||
.getAvailabilityZoneAndRegionServices()
|
||||
.describeAvailabilityZonesInRegion(region)) {
|
||||
for (AvailabilityZoneInfo zoneInfo : client.getAvailabilityZoneAndRegionServices()
|
||||
.describeAvailabilityZonesInRegion(region)) {
|
||||
map.put(zoneInfo.getZone(), region);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TimeStamp
|
||||
protected String provideTimeStamp(final DateService dateService,
|
||||
@Named(EC2Constants.PROPERTY_AWS_EXPIREINTERVAL) final int expiration) {
|
||||
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()
|
||||
+ (expiration * 1000)));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RequestSigner provideRequestSigner(FormSigner in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@EC2
|
||||
protected URI provideURI(
|
||||
@Named(EC2Constants.PROPERTY_EC2_ENDPOINT) String endpoint) {
|
||||
return URI.create(endpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
|
||||
AWSRedirectionRetryHandler.class);
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class AvailabilityZoneToEndpoint implements Function<Object, URI> {
|
|||
private final Map<String, URI> regionToEndpoint;
|
||||
|
||||
@Inject
|
||||
public AvailabilityZoneToEndpoint(@EC2 Map<String, URI> regionToEndpoint,
|
||||
public AvailabilityZoneToEndpoint(@Region Map<String, URI> regionToEndpoint,
|
||||
Map<String, String> availabilityZoneToRegion) {
|
||||
this.regionToEndpoint = regionToEndpoint;
|
||||
this.availabilityZoneToRegion = availabilityZoneToRegion;
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.ec2.functions;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.ec2.ELB;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ELBRegionToEndpoint implements Function<Object, URI> {
|
||||
private final Map<String, URI> regionToEndpoint;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public ELBRegionToEndpoint(@ELB Map<String, URI> regionToEndpoint, @ELB URI defaultUri) {
|
||||
this.regionToEndpoint = regionToEndpoint;
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
|
||||
public URI apply(Object from) {
|
||||
return from == null ? defaultUri : regionToEndpoint.get(from);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.reference;
|
||||
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
|
||||
/**
|
||||
|
@ -26,8 +25,7 @@ import org.jclouds.compute.ComputeService;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface EC2Constants extends AWSConstants {
|
||||
public static final String PROPERTY_EC2_ENDPOINT = "jclouds.ec2.endpoint";
|
||||
public interface EC2Constants{
|
||||
/**
|
||||
* Listing the universe of amis is extremely expensive. set this to a comma separated value of
|
||||
* the ami owners you wish to use in {@link ComputeService}
|
||||
|
|
|
@ -29,13 +29,13 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindProductCodesToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.Permission;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||
|
@ -46,6 +46,7 @@ import org.jclouds.aws.ec2.xml.ImageIdHandler;
|
|||
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
||||
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -62,7 +63,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface AMIAsyncClient {
|
||||
|
||||
|
|
|
@ -29,15 +29,14 @@ import javax.annotation.Nullable;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.domain.AvailabilityZoneInfo;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
|
||||
import org.jclouds.aws.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.DescribeRegionsResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -53,7 +52,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface AvailabilityZoneAndRegionAsyncClient {
|
||||
|
||||
|
@ -72,7 +71,6 @@ public interface AvailabilityZoneAndRegionAsyncClient {
|
|||
* @see AvailabilityZoneAndRegionClient#describeRegions
|
||||
*/
|
||||
@POST
|
||||
@Endpoint(EC2.class)
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DescribeRegions")
|
||||
@XMLResponseParser(DescribeRegionsResponseHandler.class)
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindVolumeIdsToIndexedFormParams;
|
||||
|
@ -36,7 +37,6 @@ import org.jclouds.aws.ec2.domain.Permission;
|
|||
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||
import org.jclouds.aws.ec2.domain.Volume;
|
||||
import org.jclouds.aws.ec2.functions.AvailabilityZoneToEndpoint;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
|
||||
import org.jclouds.aws.ec2.options.CreateSnapshotOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeSnapshotsOptions;
|
||||
|
@ -48,6 +48,7 @@ import org.jclouds.aws.ec2.xml.DescribeVolumesResponseHandler;
|
|||
import org.jclouds.aws.ec2.xml.PermissionHandler;
|
||||
import org.jclouds.aws.ec2.xml.SnapshotHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
|
@ -65,7 +66,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface ElasticBlockStoreAsyncClient {
|
||||
|
||||
|
@ -193,7 +194,7 @@ public interface ElasticBlockStoreAsyncClient {
|
|||
@FormParam("SnapshotId") String snapshotId);
|
||||
|
||||
/**
|
||||
* @see ElasticBlockStoreClient#removeCreateVolumePermissionsFromSnapshotInRegion
|
||||
* @see ElasticBlockStoreClient#removeCreateVolumePermissionsFromSnapshotInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
|
|
|
@ -28,12 +28,13 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindPublicIpsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -50,7 +51,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface ElasticIPAddressAsyncClient {
|
||||
|
||||
|
@ -72,8 +73,7 @@ public interface ElasticIPAddressAsyncClient {
|
|||
@FormParams(keys = ACTION, values = "AssociateAddress")
|
||||
ListenableFuture<Void> associateAddressInRegion(
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("PublicIp") String publicIp,
|
||||
@FormParam("InstanceId") String instanceId);
|
||||
@FormParam("PublicIp") String publicIp, @FormParam("InstanceId") String instanceId);
|
||||
|
||||
/**
|
||||
* @see BaseEC2Client#disassociateAddressInRegion
|
||||
|
|
|
@ -29,13 +29,16 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindBlockDeviceMappingToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam;
|
||||
import org.jclouds.aws.ec2.domain.*;
|
||||
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
||||
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
||||
import org.jclouds.aws.ec2.domain.Reservation;
|
||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.Volume.InstanceInitiatedShutdownBehavior;
|
||||
import org.jclouds.aws.ec2.functions.ConvertUnencodedBytesToBase64EncodedString;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.options.RunInstancesOptions;
|
||||
import org.jclouds.aws.ec2.xml.BlockDeviceMappingHandler;
|
||||
import org.jclouds.aws.ec2.xml.BooleanValueHandler;
|
||||
|
@ -47,6 +50,7 @@ import org.jclouds.aws.ec2.xml.RunInstancesResponseHandler;
|
|||
import org.jclouds.aws.ec2.xml.StringValueHandler;
|
||||
import org.jclouds.aws.ec2.xml.UnencodeStringValueHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -64,7 +68,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface InstanceAsyncClient {
|
||||
|
||||
|
@ -300,8 +304,7 @@ public interface InstanceAsyncClient {
|
|||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "instanceType" })
|
||||
ListenableFuture<Void> setInstanceTypeForInstanceInRegion(
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("InstanceId") String instanceId,
|
||||
@FormParam("Value") String instanceType);
|
||||
@FormParam("InstanceId") String instanceId, @FormParam("Value") String instanceType);
|
||||
|
||||
/**
|
||||
* @see AMIClient#setInstanceInitiatedShutdownBehaviorForInstanceInRegion
|
||||
|
|
|
@ -28,12 +28,13 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindKeyNameToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.KeyPairResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -50,7 +51,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface KeyPairAsyncClient {
|
||||
|
||||
|
|
|
@ -28,11 +28,12 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindInstanceIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -49,7 +50,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface MonitoringAsyncClient {
|
||||
|
||||
|
|
|
@ -28,15 +28,16 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.binders.BindGroupNameToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams;
|
||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||
import org.jclouds.aws.ec2.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
||||
import org.jclouds.aws.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
|
@ -54,7 +55,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-30")
|
||||
@FormParams(keys = VERSION, values = EC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface SecurityGroupAsyncClient {
|
||||
|
||||
|
@ -91,7 +92,8 @@ public interface SecurityGroupAsyncClient {
|
|||
@BinderParam(BindGroupNameToIndexedFormParams.class) String... securityGroupNames);
|
||||
|
||||
/**
|
||||
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(@Nullable Region, String,UserIdGroupPair)
|
||||
* @see BaseEC2Client#authorizeSecurityGroupIngressInRegion(@Nullable Region,
|
||||
* String,UserIdGroupPair)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
|
@ -115,7 +117,8 @@ public interface SecurityGroupAsyncClient {
|
|||
@FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp);
|
||||
|
||||
/**
|
||||
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(@Nullable Region, String,UserIdGroupPair)
|
||||
* @see BaseEC2Client#revokeSecurityGroupIngressInRegion(@Nullable Region,
|
||||
* String,UserIdGroupPair)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Date;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Attachment;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.date.DateService;
|
||||
|
@ -42,7 +42,7 @@ public class AttachmentHandler extends ParseSax.HandlerWithResult<Attachment> {
|
|||
@Inject
|
||||
protected DateService dateService;
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
private String volumeId;
|
||||
private String instanceId;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.SortedSet;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Attachment;
|
||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||
import org.jclouds.aws.ec2.domain.Reservation;
|
||||
|
@ -53,7 +53,7 @@ public abstract class BaseReservationHandler<T> extends HandlerWithResult<T> {
|
|||
|
||||
@Inject
|
||||
public BaseReservationHandler(DateService dateService,
|
||||
@EC2 String defaultRegion) {
|
||||
@Region String defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Attachment;
|
||||
import org.jclouds.aws.ec2.domain.Volume;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
|
@ -51,7 +51,7 @@ public class CreateVolumeResponseHandler extends ParseSax.HandlerWithResult<Volu
|
|||
@Inject
|
||||
protected DateService dateService;
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
@Inject
|
||||
protected Map<String, String> availabilityZoneToRegion;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.PublicIpInstanceIdPair;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||
|
@ -44,7 +44,7 @@ public class DescribeAddressesResponseHandler extends
|
|||
private String ipAddress;
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
private String instanceId;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
|
@ -51,7 +51,7 @@ import com.google.common.collect.Sets;
|
|||
public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<Set<Image>> {
|
||||
|
||||
@Inject
|
||||
public DescribeImagesResponseHandler(@EC2 String defaultRegion) {
|
||||
public DescribeImagesResponseHandler(@Region String defaultRegion) {
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.SortedSet;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Reservation;
|
||||
import org.jclouds.date.DateService;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class DescribeInstancesResponseHandler extends
|
|||
private SortedSet<Reservation> reservations = Sets.newTreeSet();
|
||||
|
||||
@Inject
|
||||
DescribeInstancesResponseHandler(DateService dateService, @EC2 String defaultRegion) {
|
||||
DescribeInstancesResponseHandler(DateService dateService, @Region String defaultRegion) {
|
||||
super(dateService, defaultRegion);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -38,7 +38,7 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerWithResult<Set<KeyPair>> {
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.SortedSet;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.IpPermission;
|
||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||
import org.jclouds.aws.ec2.domain.SecurityGroup;
|
||||
|
@ -43,7 +43,7 @@ import com.google.common.collect.Sets;
|
|||
public class DescribeSecurityGroupsResponseHandler extends
|
||||
ParseSax.HandlerWithResult<SortedSet<SecurityGroup>> {
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.SortedSet;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||
import org.jclouds.aws.ec2.domain.InstanceStateChange;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
|
@ -49,7 +49,7 @@ import com.google.common.collect.Sets;
|
|||
public class InstanceStateChangeHandler extends HandlerWithResult<SortedSet<InstanceStateChange>> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
|
||||
SortedSet<InstanceStateChange> instances = Sets.newTreeSet();
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.aws.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
@ -34,7 +34,7 @@ import org.jclouds.http.functions.ParseSax;
|
|||
*/
|
||||
public class KeyPairResponseHandler extends ParseSax.HandlerWithResult<KeyPair> {
|
||||
@Inject
|
||||
@EC2
|
||||
@Region
|
||||
String defaultRegion;
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private String keyFingerprint;
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.aws.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Reservation;
|
||||
import org.jclouds.date.DateService;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import org.jclouds.date.DateService;
|
|||
public class RunInstancesResponseHandler extends BaseReservationHandler<Reservation> {
|
||||
|
||||
@Inject
|
||||
RunInstancesResponseHandler(DateService dateService, @EC2 String defaultRegion) {
|
||||
RunInstancesResponseHandler(DateService dateService, @Region String defaultRegion) {
|
||||
super(dateService, defaultRegion);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Date;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.domain.Snapshot;
|
||||
import org.jclouds.aws.ec2.domain.Snapshot.Status;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
|
@ -50,7 +50,7 @@ public class SnapshotHandler extends ParseSax.HandlerWithResult<Snapshot> {
|
|||
private String ownerAlias;
|
||||
|
||||
@Inject
|
||||
public SnapshotHandler(DateService dateService, @EC2 String defaultRegion) {
|
||||
public SnapshotHandler(DateService dateService, @Region String defaultRegion) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
package org.jclouds.aws.elb;
|
||||
|
||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||
|
@ -28,13 +28,13 @@ import javax.ws.rs.FormParam;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.binders.BindELBInstanceIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer;
|
||||
import org.jclouds.aws.ec2.functions.ELBRegionToEndpoint;
|
||||
import org.jclouds.aws.ec2.xml.CreateLoadBalancerResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.DescribeLoadBalancersResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.RegisterInstancesWithLoadBalancerResponseHandler;
|
||||
import org.jclouds.aws.elb.binders.BindELBInstanceIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
||||
import org.jclouds.aws.elb.xml.DescribeLoadBalancersResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
|
@ -51,18 +51,20 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Lili Nader
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-11-25")
|
||||
@FormParams(keys = VERSION, values = ELBAsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface ElasticLoadBalancerAsyncClient {
|
||||
public interface ELBAsyncClient {
|
||||
public static final String VERSION = "2009-11-25";
|
||||
|
||||
/**
|
||||
* @see ElasticLoadBalancerClient#createLoadBalancerInRegion
|
||||
* @see ELBClient#createLoadBalancerInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||
ListenableFuture<String> createLoadBalancerInRegion(
|
||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("LoadBalancerName") String name,
|
||||
@FormParam("Listeners.member.1.Protocol") String protocol,
|
||||
@FormParam("Listeners.member.1.LoadBalancerPort") int loadBalancerPort,
|
||||
|
@ -70,47 +72,47 @@ public interface ElasticLoadBalancerAsyncClient {
|
|||
@FormParam("AvailabilityZones.member.1") String availabilityZone);
|
||||
|
||||
/**
|
||||
* @see ElasticLoadBalancerClient#deleteLoadBalancerInRegion
|
||||
* @see ELBClient#deleteLoadBalancerInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DeleteLoadBalancer")
|
||||
ListenableFuture<Void> deleteLoadBalancerInRegion(
|
||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("LoadBalancerName") String name);
|
||||
|
||||
/**
|
||||
* @see ElasticLoadBalancerClient#registerInstancesWithLoadBalancerInRegion
|
||||
* @see ELBClient#registerInstancesWithLoadBalancerInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(RegisterInstancesWithLoadBalancerResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "RegisterInstancesWithLoadBalancer")
|
||||
ListenableFuture<? extends Set<String>> registerInstancesWithLoadBalancerInRegion(
|
||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("LoadBalancerName") String name,
|
||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||
|
||||
/**
|
||||
* @see ElasticLoadBalancerClient#deregisterInstancesWithLoadBalancerInRegion
|
||||
* @see ELBClient#deregisterInstancesWithLoadBalancerInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DeregisterInstancesFromLoadBalancer")
|
||||
ListenableFuture<Void> deregisterInstancesWithLoadBalancerInRegion(
|
||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("LoadBalancerName") String name,
|
||||
@BinderParam(BindELBInstanceIdsToIndexedFormParams.class) String... instanceIds);
|
||||
|
||||
/**
|
||||
* @see ElasticLoadBalancerClient#describeLoadBalancersInRegion
|
||||
* @see ELBClient#describeLoadBalancersInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeLoadBalancersResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "DescribeLoadBalancers")
|
||||
ListenableFuture<? extends Set<ElasticLoadBalancer>> describeLoadBalancersInRegion(
|
||||
@EndpointParam(parser = ELBRegionToEndpoint.class) @Nullable String region,
|
||||
ListenableFuture<? extends Set<LoadBalancer>> describeLoadBalancersInRegion(
|
||||
@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
|
||||
@FormParam("LoadBalancerName") @Nullable String name);
|
||||
|
||||
}
|
|
@ -16,14 +16,14 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
package org.jclouds.aws.elb;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ import org.jclouds.concurrent.Timeout;
|
|||
* @author Lili Nader
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface ElasticLoadBalancerClient {
|
||||
public interface ELBClient {
|
||||
|
||||
/**
|
||||
* Creates a load balancer
|
||||
|
@ -91,7 +91,6 @@ public interface ElasticLoadBalancerClient {
|
|||
void deregisterInstancesWithLoadBalancerInRegion(@Nullable String region, String name,
|
||||
String... instanceIds);
|
||||
|
||||
Set<ElasticLoadBalancer> describeLoadBalancersInRegion(@Nullable String region,
|
||||
@Nullable String name);
|
||||
Set<LoadBalancer> describeLoadBalancersInRegion(@Nullable String region, @Nullable String name);
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.jclouds.aws.elb;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.elb.config.ELBRestClientModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rest.RestContextBuilder;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link ELBContext} or {@link Injector} instances based on the most commonly requested
|
||||
* arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see ELBContext
|
||||
*/
|
||||
public class ELBContextBuilder extends RestContextBuilder<ELBClient, ELBAsyncClient> {
|
||||
|
||||
public ELBContextBuilder(Properties props) {
|
||||
super(ELBClient.class, ELBAsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new ELBRestClientModule());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.elb;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
/**
|
||||
* Builds properties used in ELB Clients
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ELBPropertiesBuilder extends PropertiesBuilder {
|
||||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_ENDPOINT,
|
||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
|
||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
||||
"https://elasticloadbalancing.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.EU_WEST_1,
|
||||
"https://elasticloadbalancing.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
||||
"https://elasticloadbalancing.ap-southeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public ELBPropertiesBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ELBPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.binders;
|
||||
package org.jclouds.aws.elb.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.elb.config;
|
||||
|
||||
import org.jclouds.aws.config.AWSFormSigningRestClientModule;
|
||||
import org.jclouds.aws.elb.ELBAsyncClient;
|
||||
import org.jclouds.aws.elb.ELBClient;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
/**
|
||||
* Configures the ELB connection.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class ELBRestClientModule extends AWSFormSigningRestClientModule<ELBClient, ELBAsyncClient> {
|
||||
public ELBRestClientModule() {
|
||||
super(ELBClient.class, ELBAsyncClient.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.aws.ec2.domain;
|
||||
package org.jclouds.aws.elb.domain;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -27,7 +27,7 @@ import java.util.Set;
|
|||
*
|
||||
* @author Lili Nader
|
||||
*/
|
||||
public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer> {
|
||||
public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||
|
||||
private String region;
|
||||
private String name;
|
||||
|
@ -38,14 +38,14 @@ public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer> {
|
|||
private LBCookieStickinessPolicy lBCookieStickinessPolicy;
|
||||
private Set<LoadBalancerListener> loadBalancerListeners;
|
||||
|
||||
public ElasticLoadBalancer() {
|
||||
public LoadBalancer() {
|
||||
super();
|
||||
this.instanceIds = new HashSet<String>();
|
||||
this.availabilityZones = new HashSet<String>();
|
||||
this.loadBalancerListeners = new HashSet<LoadBalancerListener>();
|
||||
}
|
||||
|
||||
public ElasticLoadBalancer(String region, String name, Set<String> instanceIds,
|
||||
public LoadBalancer(String region, String name, Set<String> instanceIds,
|
||||
Set<String> availabilityZones, String dnsName) {
|
||||
super();
|
||||
this.region = region;
|
||||
|
@ -121,7 +121,7 @@ public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ElasticLoadBalancer that) {
|
||||
public int compareTo(LoadBalancer that) {
|
||||
return name.compareTo(that.name);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class ElasticLoadBalancer implements Comparable<ElasticLoadBalancer> {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ElasticLoadBalancer other = (ElasticLoadBalancer) obj;
|
||||
LoadBalancer other = (LoadBalancer) obj;
|
||||
if (appCookieStickinessPolicy == null) {
|
||||
if (other.appCookieStickinessPolicy != null)
|
||||
return false;
|
|
@ -16,19 +16,19 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.xml;
|
||||
package org.jclouds.aws.elb.xml;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer;
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer.AppCookieStickinessPolicy;
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer.LBCookieStickinessPolicy;
|
||||
import org.jclouds.aws.ec2.domain.ElasticLoadBalancer.LoadBalancerListener;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer.AppCookieStickinessPolicy;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer.LBCookieStickinessPolicy;
|
||||
import org.jclouds.aws.elb.domain.LoadBalancer.LoadBalancerListener;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -42,9 +42,9 @@ import com.google.common.collect.Sets;
|
|||
* @author Lili Nadar
|
||||
*/
|
||||
public class DescribeLoadBalancersResponseHandler extends
|
||||
ParseSax.HandlerWithResult<Set<ElasticLoadBalancer>> {
|
||||
ParseSax.HandlerWithResult<Set<LoadBalancer>> {
|
||||
@Inject
|
||||
public DescribeLoadBalancersResponseHandler(@EC2 String defaultRegion) {
|
||||
public DescribeLoadBalancersResponseHandler(@Region String defaultRegion) {
|
||||
this.defaultRegion = defaultRegion;
|
||||
this.listenerHandler = new LoadBalancerListenerHandler();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private Set<ElasticLoadBalancer> contents = Sets.newLinkedHashSet();
|
||||
private Set<LoadBalancer> contents = Sets.newLinkedHashSet();
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private final String defaultRegion;
|
||||
private final LoadBalancerListenerHandler listenerHandler;
|
||||
|
@ -68,7 +68,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
|||
// TODO unused?
|
||||
private boolean inLoadBalancerDescriptions = false;
|
||||
|
||||
private ElasticLoadBalancer elb;
|
||||
private LoadBalancer elb;
|
||||
// TODO unused?
|
||||
private AppCookieStickinessPolicy appCookieStickinessPolicy;
|
||||
// TODO unused?
|
||||
|
@ -93,7 +93,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
|||
if (qName.equals("member")) {
|
||||
if (!(inListenerDescriptions || inAppCookieStickinessPolicies || inInstances
|
||||
|| inLBCookieStickinessPolicies || inAvailabilityZones)) {
|
||||
elb = new ElasticLoadBalancer();
|
||||
elb = new LoadBalancer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class DescribeLoadBalancersResponseHandler extends
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ElasticLoadBalancer> getResult() {
|
||||
public Set<LoadBalancer> getResult() {
|
||||
return contents;
|
||||
}
|
||||
|
|
@ -41,7 +41,6 @@ import javax.inject.Singleton;
|
|||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.HttpException;
|
||||
|
@ -83,8 +82,8 @@ public class FormSigner implements HttpRequestFilter, RequestSigner {
|
|||
|
||||
@Inject
|
||||
public FormSigner(SignatureWire signatureWire,
|
||||
@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String accessKey,
|
||||
@Named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY) String secretKey,
|
||||
@Named(Constants.PROPERTY_IDENTITY) String accessKey,
|
||||
@Named(Constants.PROPERTY_CREDENTIAL) String secretKey,
|
||||
@TimeStamp Provider<String> dateService, EncryptionService encryptionService) {
|
||||
this.signatureWire = signatureWire;
|
||||
this.accessKey = accessKey;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.sqs.functions;
|
||||
package org.jclouds.aws.functions;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
@ -24,7 +24,8 @@ import java.util.Map;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.sqs.SQS;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -38,7 +39,7 @@ public class RegionToEndpoint implements Function<Object, URI> {
|
|||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public RegionToEndpoint(@SQS Map<String, URI> regionToEndpoint, @SQS URI defaultUri) {
|
||||
public RegionToEndpoint(@Region Map<String, URI> regionToEndpoint, @Provider URI defaultUri) {
|
||||
this.regionToEndpoint = regionToEndpoint;
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
|
@ -25,7 +25,6 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
import javax.ws.rs.core.UriBuilder;
|
||||
|
||||
import org.jclouds.aws.domain.AWSError;
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpException;
|
||||
|
@ -62,7 +61,7 @@ public class AWSRedirectionRetryHandler extends RedirectionRetryHandler {
|
|||
try {
|
||||
AWSError error = utils.parseAWSErrorFromContent(command, response, new String(
|
||||
content));
|
||||
String host = error.getDetails().get(AWSConstants.ENDPOINT);
|
||||
String host = error.getDetails().get("Endpoint");
|
||||
if (host != null) {
|
||||
if (host.equals(command.getRequest().getEndpoint().getHost())) {
|
||||
// must be an amazon error related to
|
||||
|
|
|
@ -18,20 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.aws.reference;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in AWS connections.
|
||||
* Configuration properties and constants used in amazon connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface AWSConstants extends Constants {
|
||||
public static final String ENDPOINT = "Endpoint";
|
||||
public static final String PROPERTY_AWS_SECRETACCESSKEY = "jclouds.aws.secretaccesskey";
|
||||
public static final String PROPERTY_AWS_ACCESSKEYID = "jclouds.aws.accesskeyid";
|
||||
public interface AWSConstants {
|
||||
public static final String PROPERTY_REGIONS = "jclouds.aws.regions";
|
||||
public static final String PROPERTY_DEFAULT_REGIONS = "jclouds.aws.default_regions";
|
||||
|
||||
/**
|
||||
* how long do we wait before expiring requests.
|
||||
*/
|
||||
public static final String PROPERTY_AWS_EXPIREINTERVAL = "jclouds.aws.expireinterval";
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.jclouds.aws.s3;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_AUTH_TAG;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_HEADER_TAG;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SERVICE_EXPR;
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||
|
||||
|
@ -22,19 +22,17 @@ public class GoogleStoragePropertiesBuilder extends S3PropertiesBuilder {
|
|||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-goog-meta-");
|
||||
properties.setProperty(PROPERTY_S3_AUTH_TAG, "GOOG1");
|
||||
properties.setProperty(PROPERTY_S3_HEADER_TAG, "goog");
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_EXPR,
|
||||
"\\.commondatastorage\\.googleapis\\.com");
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_EXPR, "\\.commondatastorage\\.googleapis\\.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties addEndpoints(Properties properties) {
|
||||
properties.setProperty(PROPERTY_S3_REGIONS, "GoogleStorage");
|
||||
properties.setProperty(PROPERTY_S3_DEFAULT_REGIONS, "GoogleStorage");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT,
|
||||
"https://commondatastorage.googleapis.com");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + ".GoogleStorage",
|
||||
"https://commondatastorage.googleapis.com");
|
||||
properties.setProperty(PROPERTY_REGIONS, "GoogleStorage");
|
||||
properties.setProperty(PROPERTY_DEFAULT_REGIONS, "GoogleStorage");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://commondatastorage.googleapis.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + ".GoogleStorage",
|
||||
"https://commondatastorage.googleapis.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -42,7 +40,4 @@ public class GoogleStoragePropertiesBuilder extends S3PropertiesBuilder {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public GoogleStoragePropertiesBuilder(String id, String secret) {
|
||||
super(id, secret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
|||
import org.jclouds.http.functions.ParseETagHeader;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.Headers;
|
||||
import org.jclouds.rest.annotations.HostPrefixParam;
|
||||
|
@ -102,9 +101,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@VirtualHost
|
||||
@SkipEncoding('/')
|
||||
@RequestFilters(RequestAuthorizeSignature.class)
|
||||
@Endpoint(S3.class)
|
||||
@BlobScope(CONTAINER)
|
||||
public interface S3AsyncClient {
|
||||
public static final String VERSION = "2006-03-01";
|
||||
|
||||
/**
|
||||
* Creates a default implementation of S3Object
|
||||
|
|
|
@ -45,13 +45,13 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public class S3ContextBuilder extends BlobStoreContextBuilder<S3Client, S3AsyncClient> {
|
||||
|
||||
public S3ContextBuilder(String providerName, Properties props) {
|
||||
super(providerName, S3Client.class, S3AsyncClient.class, props);
|
||||
public S3ContextBuilder(Properties props) {
|
||||
super(S3Client.class, S3AsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(String providerName, List<Module> modules) {
|
||||
modules.add(new S3BlobStoreContextModule(providerName));
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new S3BlobStoreContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.s3;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link S3Context} instances based on the most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see S3AsyncClient
|
||||
*/
|
||||
public class S3ContextFactory {
|
||||
|
||||
public static BlobStoreContext createContext(Properties properties, Module... modules) {
|
||||
return new S3ContextBuilder("s3", new S3PropertiesBuilder(properties).build()).withModules(
|
||||
modules).buildBlobStoreContext();
|
||||
}
|
||||
|
||||
public static BlobStoreContext createContext(Properties properties, String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new S3ContextBuilder("s3", new S3PropertiesBuilder(properties).withCredentials(
|
||||
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules)
|
||||
.buildBlobStoreContext();
|
||||
}
|
||||
|
||||
public static BlobStoreContext createContext(String awsAccessKeyId, String awsSecretAccessKey,
|
||||
Module... modules) {
|
||||
return new S3ContextBuilder("s3", new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
|
||||
.build()).withModules(modules).buildBlobStoreContext();
|
||||
}
|
||||
|
||||
public static BlobStoreContext createContext(URI endpoint, String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new S3ContextBuilder("s3", new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey)
|
||||
.withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext();
|
||||
}
|
||||
}
|
|
@ -18,27 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_AUTH_TAG;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_HEADER_TAG;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SERVICE_EXPR;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERVAL;
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER;
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX;
|
||||
import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.s3.reference.S3Constants;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
|
@ -51,38 +46,32 @@ public class S3PropertiesBuilder extends PropertiesBuilder {
|
|||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-amz-meta-");
|
||||
properties.setProperty(PROPERTY_S3_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_S3_HEADER_TAG, "aws");
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_EXPR,
|
||||
"\\.s3[^.]*\\.amazonaws\\.com");
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_EXPR, "\\.s3[^.]*\\.amazonaws\\.com");
|
||||
properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
|
||||
addEndpoints(properties);
|
||||
properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, "60");
|
||||
properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX,
|
||||
DIRECTORY_SUFFIX_FOLDER);
|
||||
|
||||
properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER);
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected Properties addEndpoints(Properties properties) {
|
||||
properties.setProperty(PROPERTY_S3_REGIONS, Joiner.on(',').join(
|
||||
Region.US_STANDARD, Region.US_EAST_1, Region.US_WEST_1, "EU",
|
||||
Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_S3_DEFAULT_REGIONS, Joiner.on(',').join(
|
||||
Region.US_STANDARD, Region.US_EAST_1));
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + "." + Region.US_STANDARD,
|
||||
"https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + "." + Region.US_EAST_1,
|
||||
"https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + "." + Region.US_WEST_1,
|
||||
"https://s3-us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + "." + "EU",
|
||||
"https://s3-eu-west-1.amazonaws.com");
|
||||
properties.setProperty(
|
||||
PROPERTY_S3_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
||||
"https://s3-ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_STANDARD,
|
||||
Region.US_EAST_1, Region.US_WEST_1, "EU", Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_DEFAULT_REGIONS, Joiner.on(',').join(Region.US_STANDARD,
|
||||
Region.US_EAST_1));
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_STANDARD,
|
||||
"https://s3.amazonaws.com");
|
||||
properties
|
||||
.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
||||
"https://s3-us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + "EU", "https://s3-eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
||||
"https://s3-ap-southeast-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -90,29 +79,8 @@ public class S3PropertiesBuilder extends PropertiesBuilder {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public S3PropertiesBuilder(String id, String secret) {
|
||||
public S3PropertiesBuilder() {
|
||||
super();
|
||||
withCredentials(id, secret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public S3PropertiesBuilder withCredentials(String id, String secret) {
|
||||
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(id,
|
||||
"awsAccessKeyId"));
|
||||
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(secret,
|
||||
"awsSecretAccessKey"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public S3PropertiesBuilder withEndpoint(URI endpoint) {
|
||||
properties.setProperty(S3Constants.PROPERTY_S3_ENDPOINT, checkNotNull(
|
||||
endpoint, "endpoint").toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public S3PropertiesBuilder withTimeStampExpiration(long seconds) {
|
||||
properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, seconds + "");
|
||||
return this;
|
||||
}
|
||||
|
||||
protected S3PropertiesBuilder withMetaPrefix(String prefix) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.jclouds.aws.s3;
|
||||
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_ENDPOINT;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_REGIONS;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -14,12 +14,11 @@ import java.util.Properties;
|
|||
public class WalrusPropertiesBuilder extends S3PropertiesBuilder {
|
||||
@Override
|
||||
protected Properties addEndpoints(Properties properties) {
|
||||
properties.setProperty(PROPERTY_S3_REGIONS, "Walrus");
|
||||
properties.setProperty(PROPERTY_S3_DEFAULT_REGIONS, "Walrus");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT,
|
||||
"http://ecc.eucalyptus.com:8773/services/Walrus");
|
||||
properties.setProperty(PROPERTY_S3_ENDPOINT + ".Walrus",
|
||||
"http://ecc.eucalyptus.com:8773/services/Walrus");
|
||||
properties.setProperty(PROPERTY_REGIONS, "Walrus");
|
||||
properties.setProperty(PROPERTY_DEFAULT_REGIONS, "Walrus");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "http://ecc.eucalyptus.com:8773/services/Walrus");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + ".Walrus",
|
||||
"http://ecc.eucalyptus.com:8773/services/Walrus");
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -27,7 +26,4 @@ public class WalrusPropertiesBuilder extends S3PropertiesBuilder {
|
|||
super(properties);
|
||||
}
|
||||
|
||||
public WalrusPropertiesBuilder(String id, String secret) {
|
||||
super(id, secret);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
|||
import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.blobstore.util.BlobUtils;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore {
|
|||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||
|
||||
@Inject
|
||||
S3AsyncBlobStore(BlobStoreContext context, BlobStoreUtils blobUtils,
|
||||
S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
||||
Location defaultLocation, Set<? extends Location> locations, S3AsyncClient async,
|
||||
S3Client sync, BucketToResourceMetadata bucket2ResourceMd,
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
|
|||
import org.jclouds.blobstore.internal.BaseBlobStore;
|
||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||
import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.blobstore.util.BlobUtils;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.util.Utils;
|
||||
|
@ -74,7 +74,7 @@ public class S3BlobStore extends BaseBlobStore {
|
|||
private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
|
||||
|
||||
@Inject
|
||||
S3BlobStore(BlobStoreContext context, BlobStoreUtils blobUtils, Location defaultLocation,
|
||||
S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Location defaultLocation,
|
||||
Set<? extends Location> locations, S3Client sync,
|
||||
BucketToResourceMetadata bucket2ResourceMd,
|
||||
ContainerToBucketListOptions container2BucketListOptions,
|
||||
|
|
|
@ -22,12 +22,12 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.s3.S3;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.config.DefaultLocationProvider;
|
||||
import org.jclouds.aws.s3.S3AsyncClient;
|
||||
import org.jclouds.aws.s3.S3Client;
|
||||
import org.jclouds.aws.s3.blobstore.S3AsyncBlobStore;
|
||||
import org.jclouds.aws.s3.blobstore.S3BlobStore;
|
||||
import org.jclouds.aws.s3.config.S3ContextModule;
|
||||
import org.jclouds.blobstore.AsyncBlobStore;
|
||||
import org.jclouds.blobstore.BlobStore;
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
|
@ -37,10 +37,10 @@ import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.rest.annotations.Provider;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
@ -50,17 +50,12 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class S3BlobStoreContextModule extends S3ContextModule {
|
||||
private final String providerName;
|
||||
|
||||
public S3BlobStoreContextModule(String providerName) {
|
||||
this.providerName = providerName;
|
||||
}
|
||||
public class S3BlobStoreContextModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new BlobStoreMapModule());
|
||||
bind(Location.class).toProvider(DefaultLocationProvider.class).in(Scopes.SINGLETON);
|
||||
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
|
||||
bind(AsyncBlobStore.class).to(S3AsyncBlobStore.class).in(Scopes.SINGLETON);
|
||||
bind(BlobStore.class).to(S3BlobStore.class).in(Scopes.SINGLETON);
|
||||
|
@ -71,20 +66,8 @@ public class S3BlobStoreContextModule extends S3ContextModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
Location getDefaultLocation(@S3 final String region, Set<? extends Location> locations) {
|
||||
return Iterables.find(locations, new Predicate<Location>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Location input) {
|
||||
return input.getId().equals(region);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Set<? extends Location> provideLocations(@S3 Set<String> regions) {
|
||||
Set<? extends Location> provideLocations(@Region Set<String> regions,
|
||||
@Provider String providerName) {
|
||||
Set<Location> locations = Sets.newHashSet();
|
||||
Location s3 = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
for (String zone : regions) {
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.s3.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.aws.s3.S3;
|
||||
import org.jclouds.aws.s3.S3AsyncClient;
|
||||
import org.jclouds.aws.s3.S3Client;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.HttpAsyncClient;
|
||||
import org.jclouds.rest.HttpClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the {@link S3ContextModule}; requires {@link S3AsyncClient} bound.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class S3ContextModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<S3Client, S3AsyncClient> provideContext(Closer closer,
|
||||
HttpClient http, HttpAsyncClient asyncHttp, S3AsyncClient defaultApi,
|
||||
S3Client syncApi, @S3 URI endPoint,
|
||||
@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String account) {
|
||||
return new RestContextImpl<S3Client, S3AsyncClient>(closer, http,
|
||||
asyncHttp, syncApi, defaultApi, endPoint, account);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,46 +18,28 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.config;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.aws.s3.S3;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.aws.config.AWSRestClientModule;
|
||||
import org.jclouds.aws.s3.S3AsyncClient;
|
||||
import org.jclouds.aws.s3.S3Client;
|
||||
import org.jclouds.aws.s3.filters.RequestAuthorizeSignature;
|
||||
import org.jclouds.aws.s3.reference.S3Constants;
|
||||
import org.jclouds.concurrent.ExpirableSupplier;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.http.functions.config.ParserModule.Iso8601DateAdapter;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Configures the S3 connection, including logging and http transport.
|
||||
|
@ -66,8 +48,7 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
@RequiresHttp
|
||||
public class S3RestClientModule extends
|
||||
RestClientModule<S3Client, S3AsyncClient> {
|
||||
public class S3RestClientModule extends AWSRestClientModule<S3Client, S3AsyncClient> {
|
||||
public S3RestClientModule() {
|
||||
super(S3Client.class, S3AsyncClient.class);
|
||||
}
|
||||
|
@ -75,6 +56,7 @@ public class S3RestClientModule extends
|
|||
@Override
|
||||
protected void configure() {
|
||||
install(new S3ObjectModule());
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
bind(RequestAuthorizeSignature.class).in(Scopes.SINGLETON);
|
||||
super.configure();
|
||||
}
|
||||
|
@ -96,76 +78,13 @@ public class S3RestClientModule extends
|
|||
*/
|
||||
@Provides
|
||||
@TimeStamp
|
||||
Supplier<String> provideTimeStampCache(
|
||||
@Named(S3Constants.PROPERTY_S3_SESSIONINTERVAL) long seconds,
|
||||
final DateService dateService) {
|
||||
@Singleton
|
||||
Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final DateService dateService) {
|
||||
return new ExpirableSupplier<String>(new Supplier<String>() {
|
||||
public String get() {
|
||||
return dateService.rfc822DateFormat();
|
||||
}
|
||||
}, seconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@S3
|
||||
Map<String, URI> provideRegions(
|
||||
@Named(S3Constants.PROPERTY_S3_REGIONS) String regionString,
|
||||
Injector injector) {
|
||||
Map<String, URI> regions = Maps.newLinkedHashMap();
|
||||
for (String region : Splitter.on(',').split(regionString)) {
|
||||
regions.put(region, URI.create(injector.getInstance(Key.get(
|
||||
String.class, Names.named(S3Constants.PROPERTY_S3_ENDPOINT + "."
|
||||
+ region)))));
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@S3
|
||||
Set<String> provideRegions(@S3 Map<String, URI> map) {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@S3
|
||||
protected URI provideS3URI(
|
||||
@Named(S3Constants.PROPERTY_S3_ENDPOINT) String endpoint) {
|
||||
return URI.create(endpoint);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@S3
|
||||
String getDefaultRegion(@S3 final URI uri, @S3 Map<String, URI> map) {
|
||||
return Iterables.find(map.entrySet(),
|
||||
new Predicate<Entry<String, URI>>() {
|
||||
|
||||
@Override
|
||||
public boolean apply(Entry<String, URI> input) {
|
||||
return input.getValue().equals(uri);
|
||||
}
|
||||
|
||||
}).getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
|
||||
AWSRedirectionRetryHandler.class);
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
}
|
|
@ -45,19 +45,19 @@ public enum CannedAccessPolicy {
|
|||
*/
|
||||
PRIVATE("private"),
|
||||
/**
|
||||
* Owner gets FULL_CONTROL and the anonymous principal is granted READ
|
||||
* Owner gets FULL_CONTROL and the anonymous identity is granted READ
|
||||
* access. If this policy is used on an object, it can be read from a
|
||||
* browser with no authentication.
|
||||
*/
|
||||
PUBLIC_READ("public-read"),
|
||||
/**
|
||||
* Owner gets FULL_CONTROL, the anonymous principal is granted READ and
|
||||
* Owner gets FULL_CONTROL, the anonymous identity is granted READ and
|
||||
* WRITE access. This can be a useful policy to apply to a bucket, but is
|
||||
* generally not recommended.
|
||||
*/
|
||||
PUBLIC_READ_WRITE("public-read-write"),
|
||||
/**
|
||||
* Owner gets FULL_CONTROL, and any principal authenticated as a registered
|
||||
* Owner gets FULL_CONTROL, and any identity authenticated as a registered
|
||||
* Amazon S3 user is granted READ access.
|
||||
*/
|
||||
AUTHENTICATED_READ("authenticated-read");
|
||||
|
|
|
@ -52,20 +52,17 @@ import com.google.common.collect.ImmutableSet;
|
|||
/**
|
||||
* Signs the S3 request.
|
||||
*
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AmazonS3/latest/RESTAuthentication.html"
|
||||
* />
|
||||
* @see <a href= "http://docs.amazonwebservices.com/AmazonS3/latest/RESTAuthentication.html" />
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class RequestAuthorizeSignature implements HttpRequestFilter,
|
||||
RequestSigner {
|
||||
public class RequestAuthorizeSignature implements HttpRequestFilter, RequestSigner {
|
||||
private final String[] firstHeadersToSign = new String[] { "Content-MD5",
|
||||
HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE };
|
||||
HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE };
|
||||
|
||||
public static Set<String> SPECIAL_QUERIES = ImmutableSet.of("acl",
|
||||
"torrent", "logging", "location", "requestPayment");
|
||||
public static Set<String> SPECIAL_QUERIES = ImmutableSet.of("acl", "torrent", "logging",
|
||||
"location", "requestPayment");
|
||||
private final SignatureWire signatureWire;
|
||||
private final String accessKey;
|
||||
private final String secretKey;
|
||||
|
@ -82,13 +79,12 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
|
||||
@Inject
|
||||
public RequestAuthorizeSignature(SignatureWire signatureWire,
|
||||
@Named(S3Constants.PROPERTY_S3_AUTH_TAG) String authTag,
|
||||
@Named(S3Constants.PROPERTY_S3_SERVICE_EXPR) String srvExpr,
|
||||
@Named(S3Constants.PROPERTY_S3_HEADER_TAG) String headerTag,
|
||||
@Named(S3Constants.PROPERTY_AWS_ACCESSKEYID) String accessKey,
|
||||
@Named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY) String secretKey,
|
||||
@TimeStamp Provider<String> timeStampProvider,
|
||||
EncryptionService encryptionService) {
|
||||
@Named(S3Constants.PROPERTY_S3_AUTH_TAG) String authTag,
|
||||
@Named(S3Constants.PROPERTY_S3_SERVICE_EXPR) String srvExpr,
|
||||
@Named(S3Constants.PROPERTY_S3_HEADER_TAG) String headerTag,
|
||||
@Named(Constants.PROPERTY_IDENTITY) String accessKey,
|
||||
@Named(Constants.PROPERTY_CREDENTIAL) String secretKey,
|
||||
@TimeStamp Provider<String> timeStampProvider, EncryptionService encryptionService) {
|
||||
this.srvExpr = srvExpr;
|
||||
this.headerTag = headerTag;
|
||||
this.authTag = authTag;
|
||||
|
@ -121,21 +117,18 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
}
|
||||
|
||||
private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign)
|
||||
throws HttpException {
|
||||
throws HttpException {
|
||||
String signature = sign(toSign);
|
||||
if (signatureWire.enabled())
|
||||
signatureWire.input(Utils.toInputStream(signature));
|
||||
request.getHeaders().replaceValues(
|
||||
HttpHeaders.AUTHORIZATION,
|
||||
Collections.singletonList(authTag + " " + accessKey + ":"
|
||||
+ signature));
|
||||
request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION,
|
||||
Collections.singletonList(authTag + " " + accessKey + ":" + signature));
|
||||
}
|
||||
|
||||
public String sign(String toSign) {
|
||||
String signature;
|
||||
try {
|
||||
signature = encryptionService.hmacSha1Base64(toSign, secretKey
|
||||
.getBytes());
|
||||
signature = encryptionService.hmacSha1Base64(toSign, secretKey.getBytes());
|
||||
} catch (Exception e) {
|
||||
throw new HttpException("error signing request", e);
|
||||
}
|
||||
|
@ -148,7 +141,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
|
||||
private void replaceDateHeader(HttpRequest request) {
|
||||
request.getHeaders().replaceValues(HttpHeaders.DATE,
|
||||
Collections.singletonList(timeStampProvider.get()));
|
||||
Collections.singletonList(timeStampProvider.get()));
|
||||
}
|
||||
|
||||
private void appendAmzHeaders(HttpRequest request, StringBuilder toSign) {
|
||||
|
@ -157,8 +150,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
if (header.startsWith("x-" + headerTag + "-")) {
|
||||
toSign.append(header.toLowerCase()).append(":");
|
||||
for (String value : request.getHeaders().get(header)) {
|
||||
toSign.append(Utils.replaceAll(value, NEWLINE_PATTERN, ""))
|
||||
.append(",");
|
||||
toSign.append(Utils.replaceAll(value, NEWLINE_PATTERN, "")).append(",");
|
||||
}
|
||||
toSign.deleteCharAt(toSign.lastIndexOf(","));
|
||||
toSign.append("\n");
|
||||
|
@ -168,8 +160,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
|
||||
private void appendHttpHeaders(HttpRequest request, StringBuilder toSign) {
|
||||
for (String header : firstHeadersToSign)
|
||||
toSign.append(valueOrEmpty(request.getHeaders().get(header))).append(
|
||||
"\n");
|
||||
toSign.append(valueOrEmpty(request.getHeaders().get(header))).append("\n");
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -177,7 +168,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
String hostHeader = request.getFirstHeaderOrNull(HttpHeaders.HOST);
|
||||
if (hostHeader == null)
|
||||
hostHeader = checkNotNull(request.getEndpoint().getHost(),
|
||||
"request.getEndPoint().getHost()");
|
||||
"request.getEndPoint().getHost()");
|
||||
if (hostHeader.matches(".*" + srvExpr))
|
||||
toSign.append("/").append(hostHeader.replaceAll(srvExpr, ""));
|
||||
}
|
||||
|
@ -208,7 +199,6 @@ public class RequestAuthorizeSignature implements HttpRequestFilter,
|
|||
}
|
||||
|
||||
private String valueOrEmpty(Collection<String> collection) {
|
||||
return (collection != null && collection.size() >= 1) ? collection
|
||||
.iterator().next() : "";
|
||||
return (collection != null && collection.size() >= 1) ? collection.iterator().next() : "";
|
||||
}
|
||||
}
|
|
@ -20,8 +20,8 @@
|
|||
package org.jclouds.aws.s3.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_REGIONS;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_DEFAULT_REGIONS;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
@ -35,8 +35,8 @@ import com.google.common.collect.Iterables;
|
|||
|
||||
/**
|
||||
*
|
||||
* Depending on your latency and legal requirements, you can specify a location
|
||||
* constraint that will affect where your data physically resides.
|
||||
* Depending on your latency and legal requirements, you can specify a location constraint that will
|
||||
* affect where your data physically resides.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
|
@ -48,9 +48,8 @@ public class BindRegionToXmlPayload extends BindToStringPayload {
|
|||
private final Iterable<String> regions;
|
||||
|
||||
@Inject
|
||||
BindRegionToXmlPayload(
|
||||
@Named(PROPERTY_S3_DEFAULT_REGIONS) String defaultRegions,
|
||||
@Named(PROPERTY_S3_REGIONS) String regions) {
|
||||
BindRegionToXmlPayload(@Named(PROPERTY_DEFAULT_REGIONS) String defaultRegions,
|
||||
@Named(PROPERTY_REGIONS) String regions) {
|
||||
this.defaultRegions = Splitter.on(',').split(defaultRegions);
|
||||
this.regions = Splitter.on(',').split(regions);
|
||||
}
|
||||
|
@ -58,8 +57,7 @@ public class BindRegionToXmlPayload extends BindToStringPayload {
|
|||
@Override
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
input = input == null ? Iterables.get(defaultRegions, 0) : input;
|
||||
checkArgument(input instanceof String,
|
||||
"this binder is only valid for Region!");
|
||||
checkArgument(input instanceof String, "this binder is only valid for Region!");
|
||||
String constraint = (String) input;
|
||||
String value = null;
|
||||
if (Iterables.contains(defaultRegions, constraint)) {
|
||||
|
@ -71,9 +69,9 @@ public class BindRegionToXmlPayload extends BindToStringPayload {
|
|||
throw new IllegalStateException("unimplemented location: " + constraint);
|
||||
}
|
||||
String payload = String
|
||||
.format(
|
||||
"<CreateBucketConfiguration><LocationConstraint>%s</LocationConstraint></CreateBucketConfiguration>",
|
||||
value);
|
||||
.format(
|
||||
"<CreateBucketConfiguration><LocationConstraint>%s</LocationConstraint></CreateBucketConfiguration>",
|
||||
value);
|
||||
super.bindToRequest(request, payload);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.reference;
|
||||
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in S3 connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface S3Constants extends AWSConstants, S3Headers {
|
||||
public interface S3Constants {
|
||||
|
||||
/**
|
||||
* S3 service's XML Namespace, as used in XML request and response documents.
|
||||
|
@ -35,15 +33,9 @@ public interface S3Constants extends AWSConstants, S3Headers {
|
|||
public static final String MARKER = "marker";
|
||||
public static final String MAX_KEYS = "max-keys";
|
||||
public static final String DELIMITER = "delimiter";
|
||||
public static final String PROPERTY_S3_ENDPOINT = "jclouds.s3.endpoint";
|
||||
public static final String PROPERTY_S3_REGIONS = "jclouds.s3.regions";
|
||||
public static final String PROPERTY_S3_DEFAULT_REGIONS = "jclouds.s3.default-regions";
|
||||
|
||||
public static final String PROPERTY_S3_SERVICE_EXPR = "jclouds.service.expr";
|
||||
/**
|
||||
* how long do we wait before obtaining a new timestamp for requests.
|
||||
*/
|
||||
public static final String PROPERTY_S3_SESSIONINTERVAL = "jclouds.s3.sessioninterval";
|
||||
|
||||
public static final String PROPERTY_S3_AUTH_TAG = "jclouds.s3.auth.tag";
|
||||
public static final String PROPERTY_S3_HEADER_TAG = "jclouds.s3.header.tag";
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@ import javax.ws.rs.POST;
|
|||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.sqs.domain.Queue;
|
||||
import org.jclouds.aws.sqs.functions.QueueLocation;
|
||||
import org.jclouds.aws.sqs.functions.RegionToEndpoint;
|
||||
import org.jclouds.aws.sqs.options.CreateQueueOptions;
|
||||
import org.jclouds.aws.sqs.options.ListQueuesOptions;
|
||||
import org.jclouds.aws.sqs.xml.RegexListQueuesResponseHandler;
|
||||
|
@ -52,9 +52,10 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = "2009-02-01")
|
||||
@FormParams(keys = VERSION, values = SQSAsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
public interface SQSAsyncClient {
|
||||
public static final String VERSION = "2009-02-01";
|
||||
|
||||
/**
|
||||
* @see SQSClient#listQueuesInRegion
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.aws.sqs;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.sqs.config.SQSContextModule;
|
||||
import org.jclouds.aws.sqs.config.SQSRestClientModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
@ -45,23 +44,12 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public class SQSContextBuilder extends RestContextBuilder<SQSClient, SQSAsyncClient> {
|
||||
|
||||
public SQSContextBuilder(String providerName, Properties props) {
|
||||
super(providerName, SQSClient.class, SQSAsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addContextModule(String providerName, List<Module> modules) {
|
||||
modules.add(new SQSContextModule(providerName));
|
||||
public SQSContextBuilder(Properties props) {
|
||||
super(SQSClient.class, SQSAsyncClient.class, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addClientModule(List<Module> modules) {
|
||||
modules.add(new SQSRestClientModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQSContextBuilder withModules(Module... modules) {
|
||||
return (SQSContextBuilder) super.withModules(modules);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.sqs;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link SQSContext} instances based on the most commonly requested arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see SQSAsyncClient
|
||||
*/
|
||||
public class SQSContextFactory {
|
||||
|
||||
public static RestContext<SQSClient, SQSAsyncClient> createContext(Properties properties,
|
||||
Module... modules) {
|
||||
return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(properties).build())
|
||||
.withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<SQSClient, SQSAsyncClient> createContext(Properties properties,
|
||||
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
|
||||
return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(properties).withCredentials(
|
||||
awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<SQSClient, SQSAsyncClient> createContext(String awsAccessKeyId,
|
||||
String awsSecretAccessKey, Module... modules) {
|
||||
return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(awsAccessKeyId,
|
||||
awsSecretAccessKey).build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<SQSClient, SQSAsyncClient> createContext(URI endpoint,
|
||||
String awsAccessKeyId, String awsSecretAccessKey, Module... modules) {
|
||||
return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(awsAccessKeyId,
|
||||
awsSecretAccessKey).withEndpoint(endpoint).build()).withModules(modules)
|
||||
.buildContext();
|
||||
}
|
||||
}
|
|
@ -18,20 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.aws.sqs;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_EXPIREINTERVAL;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
|
||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT;
|
||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1;
|
||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1;
|
||||
import static org.jclouds.aws.sqs.reference.SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.aws.domain.Region;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
/**
|
||||
* Builds properties used in SQS Clients
|
||||
|
@ -42,42 +38,27 @@ public class SQSPropertiesBuilder extends PropertiesBuilder {
|
|||
@Override
|
||||
protected Properties defaultProperties() {
|
||||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_SQS_ENDPOINT, "https://sqs.us-east-1.amazonaws.com");
|
||||
properties
|
||||
.setProperty(PROPERTY_SQS_ENDPOINT_US_EAST_1, "https://sqs.us-east-1.amazonaws.com");
|
||||
properties
|
||||
.setProperty(PROPERTY_SQS_ENDPOINT_US_WEST_1, "https://sqs.us-west-1.amazonaws.com");
|
||||
properties
|
||||
.setProperty(PROPERTY_SQS_ENDPOINT_EU_WEST_1, "https://sqs.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1,
|
||||
properties.setProperty(PROPERTY_API_VERSION, SQSAsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
|
||||
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://sqs.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
|
||||
"https://sqs.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
|
||||
"https://sqs.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.EU_WEST_1,
|
||||
"https://sqs.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
|
||||
"https://sqs.ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder(String id, String secret) {
|
||||
super();
|
||||
withCredentials(id, secret);
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder withCredentials(String id, String secret) {
|
||||
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(id, "awsAccessKeyId"));
|
||||
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(secret,
|
||||
"awsSecretAccessKey"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder withEndpoint(URI endpoint) {
|
||||
properties.setProperty(PROPERTY_SQS_ENDPOINT, checkNotNull(endpoint, "endpoint").toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SQSPropertiesBuilder withRequestExpiration(long seconds) {
|
||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, seconds + "");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.sqs.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.aws.sqs.SQS;
|
||||
import org.jclouds.aws.sqs.SQSAsyncClient;
|
||||
import org.jclouds.aws.sqs.SQSClient;
|
||||
import org.jclouds.http.functions.config.ParserModule.CDateAdapter;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.HttpAsyncClient;
|
||||
import org.jclouds.rest.HttpClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the SQS connection, including logging and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SQSContextModule extends AbstractModule {
|
||||
public SQSContextModule(String providerName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(CDateAdapter.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<SQSClient, SQSAsyncClient> provideContext(Closer closer,
|
||||
HttpClient http, HttpAsyncClient asyncHttp, SQSAsyncClient defaultApi,
|
||||
SQSClient synchApi, @SQS URI endPoint,
|
||||
@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String account) {
|
||||
return new RestContextImpl<SQSClient, SQSAsyncClient>(closer, http,
|
||||
asyncHttp, synchApi, defaultApi, endPoint, account);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,37 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.aws.sqs.config;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.aws.sqs.SQS;
|
||||
import org.jclouds.aws.config.AWSFormSigningRestClientModule;
|
||||
import org.jclouds.aws.sqs.SQSAsyncClient;
|
||||
import org.jclouds.aws.sqs.SQSClient;
|
||||
import org.jclouds.aws.sqs.reference.SQSConstants;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Configures the SQS connection.
|
||||
|
@ -57,68 +31,10 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
public class SQSRestClientModule extends RestClientModule<SQSClient, SQSAsyncClient> {
|
||||
public class SQSRestClientModule extends AWSFormSigningRestClientModule<SQSClient, SQSAsyncClient> {
|
||||
|
||||
public SQSRestClientModule() {
|
||||
super(SQSClient.class, SQSAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TimeStamp
|
||||
protected String provideTimeStamp(final DateService dateService,
|
||||
@Named(SQSConstants.PROPERTY_AWS_EXPIREINTERVAL) final int expiration) {
|
||||
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()
|
||||
+ (expiration * 1000)));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SQS
|
||||
Map<String, URI> provideRegions(
|
||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_EAST_1) String useast,
|
||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_US_WEST_1) String uswest,
|
||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_EU_WEST_1) String euwest,
|
||||
@Named(SQSConstants.PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1) String apsoutheast) {
|
||||
return ImmutableMap.<String, URI> of(Region.US_EAST_1, URI.create(useast), Region.US_WEST_1,
|
||||
URI.create(uswest), Region.EU_WEST_1, URI.create(euwest), Region.AP_SOUTHEAST_1, URI
|
||||
.create(apsoutheast));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SQS
|
||||
protected URI provideURI(@Named(SQSConstants.PROPERTY_SQS_ENDPOINT) String endpoint) {
|
||||
return URI.create(endpoint);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SQS
|
||||
String getDefaultRegion(@SQS URI uri, @SQS Map<String, URI> map) {
|
||||
return ImmutableBiMap.<String, URI> builder().putAll(map).build().inverse().get(uri);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RequestSigner provideRequestSigner(FormSigner in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
ParseAWSErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
|
||||
AWSRedirectionRetryHandler.class);
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.aws.sqs.reference;
|
||||
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
|
||||
/**
|
||||
* Configuration properties and constants used in SQS connections.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface SQSConstants extends AWSConstants {
|
||||
public static final String PROPERTY_SQS_ENDPOINT = "jclouds.sqs.endpoint";
|
||||
|
||||
public static final String PROPERTY_SQS_ENDPOINT_EU_WEST_1 = "jclouds.sqs.endpoint.eu_west_1";
|
||||
public static final String PROPERTY_SQS_ENDPOINT_US_EAST_1 = "jclouds.sqs.endpoint.us_east_1";
|
||||
public static final String PROPERTY_SQS_ENDPOINT_US_WEST_1 = "jclouds.sqs.endpoint.us_west_1";
|
||||
public static final String PROPERTY_SQS_ENDPOINT_AP_SOUTHEAST_1 = "jclouds.sqs.endpoint.ap_southeast_1";
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import javax.inject.Inject;
|
|||
import javax.inject.Provider;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
|
||||
import org.jclouds.aws.sqs.SQS;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.sqs.domain.Queue;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class QueueHandler extends ParseSax.HandlerWithResult<Queue> {
|
|||
private final Provider<UriBuilder> uriBuilderProvider;
|
||||
|
||||
@Inject
|
||||
QueueHandler(Provider<UriBuilder> uriBuilderProvider, @SQS Map<String, URI> regionMap) {
|
||||
QueueHandler(Provider<UriBuilder> uriBuilderProvider, @Region Map<String, URI> regionMap) {
|
||||
this.uriBuilderProvider = uriBuilderProvider;
|
||||
this.regionBiMap = ImmutableBiMap.<String, URI> builder().putAll(regionMap).build();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Set;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.sqs.SQS;
|
||||
import org.jclouds.aws.Region;
|
||||
import org.jclouds.aws.sqs.domain.Queue;
|
||||
import org.jclouds.aws.sqs.xml.internal.BaseRegexQueueHandler;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -45,7 +45,7 @@ import com.google.common.base.Throwables;
|
|||
public class RegexListQueuesResponseHandler extends BaseRegexQueueHandler implements
|
||||
Function<HttpResponse, Set<Queue>> {
|
||||
@Inject
|
||||
RegexListQueuesResponseHandler(@SQS Map<String, URI> regionMap) {
|
||||
RegexListQueuesResponseHandler(@Region Map<String, URI> regionMap) {
|
||||
super(regionMap);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue