git-svn-id: http://jclouds.googlecode.com/svn/trunk@865 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
suprememoocow 2009-05-28 22:14:38 +00:00
parent 0f346ca1c2
commit 5b1f294068
7 changed files with 287 additions and 160 deletions

View File

@ -24,18 +24,20 @@
package org.jclouds.aws.s3; package org.jclouds.aws.s3;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_AWS_ACCESSKEYID; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_ACCESSKEYID;
import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_AWS_SECRETACCESSKEY; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AWS_SECRETACCESSKEY;
import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_IO_WORKER_THREADS; import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_IO_WORKER_THREADS;
import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTIONS; import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTIONS;
import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTION_REUSE; import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_CONNECTION_REUSE;
import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_SESSION_FAILURES; import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_MAX_SESSION_FAILURES;
import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_REQUEST_INVOKER_THREADS; import static org.jclouds.command.pool.PoolConstants.PROPERTY_POOL_REQUEST_INVOKER_THREADS;
import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_ADDRESS; import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_ADDRESS;
import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_MAX_RETRIES;
import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_PORT; import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_PORT;
import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_SECURE; import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_SECURE;
import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_MAX_RETRIES;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -51,7 +53,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -68,114 +69,189 @@ import com.google.inject.name.Names;
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and * If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
* {@link JavaUrlHttpFutureCommandClientModule http transports} will be installed. * {@link JavaUrlHttpFutureCommandClientModule http transports} will be installed.
* *
* @author Adrian Cole * @author Adrian Cole, Andrew Newdigate
* @see S3Context * @see S3Context
*/ */
public class S3ContextFactory { public class S3ContextFactory {
public static final Properties DEFAULT_PROPERTIES; private static final String DEFAULT_SECURE_HTTP_PORT = "443";
private static final String DEFAULT_NON_SECURE_HTTP_PORT = "80";
static { private final Properties properties;
DEFAULT_PROPERTIES = new Properties(); private final List<Module> modules = new ArrayList<Module>(3);
DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_ADDRESS, "s3.amazonaws.com");
DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_PORT, "443"); private S3ContextFactory(Properties properties) {
DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_SECURE, "true"); this.properties = properties;
DEFAULT_PROPERTIES.setProperty(PROPERTY_HTTP_MAX_RETRIES, "5"); }
DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_MAX_CONNECTION_REUSE, "75");
DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_MAX_SESSION_FAILURES, "2"); public static S3ContextFactory createContext(String awsAccessKeyId, String awsSecretAccessKey) {
DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_REQUEST_INVOKER_THREADS, "1"); Properties properties = new Properties();
DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_IO_WORKER_THREADS, "2");
DEFAULT_PROPERTIES.setProperty(PROPERTY_POOL_MAX_CONNECTIONS, "12"); properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(awsAccessKeyId, "awsAccessKeyId"));
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(awsSecretAccessKey,"awsSecretAccessKey"));
properties.setProperty(PROPERTY_HTTP_ADDRESS, "s3.amazonaws.com");
properties.setProperty(PROPERTY_HTTP_SECURE, "true");
properties.setProperty(PROPERTY_HTTP_MAX_RETRIES, "5");
properties.setProperty(PROPERTY_POOL_MAX_CONNECTION_REUSE, "75");
properties.setProperty(PROPERTY_POOL_MAX_SESSION_FAILURES, "2");
properties.setProperty(PROPERTY_POOL_REQUEST_INVOKER_THREADS, "1");
properties.setProperty(PROPERTY_POOL_IO_WORKER_THREADS, "2");
properties.setProperty(PROPERTY_POOL_MAX_CONNECTIONS, "12");
return new S3ContextFactory(properties);
}
public S3Context build() {
return createInjector().getInstance(S3Context.class);
} }
public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey, public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey,
Module... modules) { Module... modules) {
Properties properties = new Properties(DEFAULT_PROPERTIES); return createContext(awsAccessKeyId, awsSecretAccessKey)
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId); .withModules(modules)
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey); .createInjector();
return createInjector(properties, modules);
} }
public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey, public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey,
Module... modules) { Module... modules) {
return createInjector(awsAccessKeyId, awsSecretAccessKey, modules).getInstance( return createContext(awsAccessKeyId, awsSecretAccessKey)
S3Context.class); .withModules(modules)
.build();
} }
public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey, public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, Module... modules) { boolean isSecure, Module... modules) {
Properties properties = new Properties(DEFAULT_PROPERTIES); return createContext(awsAccessKeyId, awsSecretAccessKey)
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId); .withModules(modules)
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey); .withHttpSecure(isSecure)
properties.setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure)); .createInjector();
if (!isSecure)
properties.setProperty(PROPERTY_HTTP_PORT, "80");
return createInjector(properties, modules);
} }
public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey, public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, Module... modules) { boolean isSecure, Module... modules) {
return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure, modules).getInstance(
S3Context.class); return createContext(awsAccessKeyId, awsSecretAccessKey)
.withModules(modules)
.withHttpSecure(isSecure)
.build();
} }
public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey, public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, String server, Module... modules) { boolean isSecure, String server, Module... modules) {
Properties properties = new Properties(DEFAULT_PROPERTIES); return createContext(awsAccessKeyId, awsSecretAccessKey)
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId); .withModules(modules)
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey); .withHttpSecure(isSecure)
properties.setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure)); .withHttpAddress(server)
properties.setProperty(PROPERTY_HTTP_ADDRESS, server); .createInjector();
if (!isSecure)
properties.setProperty(PROPERTY_HTTP_PORT, "80");
return createInjector(properties, modules);
} }
public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey, public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, String server, Module... modules) { boolean isSecure, String server, Module... modules) {
return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure, server, modules) return createContext(awsAccessKeyId, awsSecretAccessKey)
.getInstance(S3Context.class); .withModules(modules)
.withHttpSecure(isSecure)
.withHttpAddress(server)
.build();
} }
public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey, public static S3Context createS3Context(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, String server, int port, Module... modules) { boolean isSecure, String server, int port, Module... modules) {
return createInjector(awsAccessKeyId, awsSecretAccessKey, isSecure, server, port, modules) return createContext(awsAccessKeyId, awsSecretAccessKey)
.getInstance(S3Context.class); .withModules(modules)
.withHttpSecure(isSecure)
.withHttpAddress(server)
.withHttpPort(port)
.build();
} }
public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey, public static Injector createInjector(String awsAccessKeyId, String awsSecretAccessKey,
boolean isSecure, String server, int port, Module... modules) { boolean isSecure, String server, int port, Module... modules) {
Properties properties = new Properties(DEFAULT_PROPERTIES); return createContext(awsAccessKeyId, awsSecretAccessKey)
properties.setProperty(PROPERTY_AWS_ACCESSKEYID, awsAccessKeyId); .withModules(modules)
properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, awsSecretAccessKey); .withHttpSecure(isSecure)
properties.setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(isSecure)); .withHttpAddress(server)
properties.setProperty(PROPERTY_HTTP_ADDRESS, server); .withHttpPort(port)
properties.setProperty(PROPERTY_HTTP_PORT, port + ""); .createInjector();
return createInjector(properties, modules);
} }
public static S3Context createS3Context(Properties properties, Module... modules) { public S3ContextFactory withHttpAddress(String httpAddress) {
return createInjector(properties, modules).getInstance(S3Context.class); properties.setProperty(PROPERTY_HTTP_ADDRESS, httpAddress);
return this;
} }
/** public S3ContextFactory withHttpMaxRetries(int httpMaxRetries) {
* Bind the given properties and install the list of modules. If no modules are specified, properties.setProperty(PROPERTY_HTTP_MAX_RETRIES, Integer.toString(httpMaxRetries));
* install the default {@link JDKLoggingModule} {@link JavaUrlHttpFutureCommandClientModule} return this;
* }
* @param properties
* - contains constants used by jclouds {@link #DEFAULT_PROPERTIES} public S3ContextFactory withHttpPort(int httpPort) {
* @param configModules properties.setProperty(PROPERTY_HTTP_PORT, Integer.toString(httpPort));
* - alternative configuration modules return this;
*/ }
public static Injector createInjector(final Properties properties, Module... configModules) {
final List<Module> modules = Lists.newArrayList(configModules); public S3ContextFactory withHttpSecure(boolean httpSecure) {
properties.setProperty(PROPERTY_HTTP_SECURE, Boolean.toString(httpSecure));
return this;
}
public S3ContextFactory withPoolMaxConnectionReuse(int poolMaxConnectionReuse) {
properties.setProperty(PROPERTY_POOL_MAX_CONNECTION_REUSE, Integer.toString(poolMaxConnectionReuse));
return this;
}
public S3ContextFactory withPoolMaxSessionFailures(int poolMaxSessionFailures) {
properties.setProperty(PROPERTY_POOL_MAX_SESSION_FAILURES, Integer.toString(poolMaxSessionFailures));
return this;
}
public S3ContextFactory withPoolRequestInvokerThreads(int poolRequestInvokerThreads) {
properties.setProperty(PROPERTY_POOL_REQUEST_INVOKER_THREADS, Integer.toString(poolRequestInvokerThreads));
return this;
}
public S3ContextFactory withPoolIoWorkerThreads(int poolIoWorkerThreads) {
properties.setProperty(PROPERTY_POOL_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads));
return this;
}
public S3ContextFactory withPoolMaxConnections(int poolMaxConnections) {
properties.setProperty(PROPERTY_POOL_MAX_CONNECTIONS, Integer.toString(poolMaxConnections));
return this;
}
public S3ContextFactory withModule(Module module) {
modules.add(module);
return this;
}
public S3ContextFactory withModules(Module... modules) {
this.modules.addAll(Arrays.asList(modules));
return this;
}
private Injector createInjector() {
/* Use 80 or 443 as the default port if one hasn't been set? */
if(!properties.containsKey(PROPERTY_HTTP_PORT)) {
if(Boolean.parseBoolean(properties.getProperty(PROPERTY_HTTP_SECURE))) {
properties.setProperty(PROPERTY_HTTP_PORT, DEFAULT_SECURE_HTTP_PORT);
} else {
properties.setProperty(PROPERTY_HTTP_PORT, DEFAULT_NON_SECURE_HTTP_PORT);
}
}
addLoggingModuleIfNotPresent(modules); addLoggingModuleIfNotPresent(modules);
addHttpModuleIfNeededAndNotPresent(modules);
addS3ConnectionModuleIfNotPresent(modules); addS3ConnectionModuleIfNotPresent(modules);
addHttpModuleIfNeededAndNotPresent(modules);
return Guice.createInjector(new AbstractModule() { return Guice.createInjector(new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
@ -186,6 +262,7 @@ public class S3ContextFactory {
}, new S3ContextModule()); }, new S3ContextModule());
} }
@VisibleForTesting @VisibleForTesting
static void addHttpModuleIfNeededAndNotPresent(final List<Module> modules) { static void addHttpModuleIfNeededAndNotPresent(final List<Module> modules) {
if (Iterables.any(modules, new Predicate<Module>() { if (Iterables.any(modules, new Predicate<Module>() {
@ -219,4 +296,9 @@ public class S3ContextFactory {
if (!Iterables.any(modules, Predicates.instanceOf(LoggingModule.class))) if (!Iterables.any(modules, Predicates.instanceOf(LoggingModule.class)))
modules.add(new JDKLoggingModule()); modules.add(new JDKLoggingModule());
} }
@VisibleForTesting
Properties getProperties() {
return properties;
}
} }

View File

@ -36,6 +36,7 @@ import org.testng.annotations.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties;
/** /**
* Tests behavior of modules configured in S3ContextFactory * Tests behavior of modules configured in S3ContextFactory
@ -108,4 +109,46 @@ public class S3ContextFactoryTest {
assert modules.remove(0) instanceof JavaUrlHttpFutureCommandClientModule; assert modules.remove(0) instanceof JavaUrlHttpFutureCommandClientModule;
assert modules.remove(0) instanceof JDKLoggingModule; assert modules.remove(0) instanceof JDKLoggingModule;
} }
public void testBuilder() {
String awsAccessKeyId = "awsAccessKeyId";
String awsSecretAccessKey = "awsSecretAccessKey";
String httpAddress = "httpAddress";
int httpMaxRetries = 9875;
int httpPort = 3827;
boolean httpSecure = false;
int poolIoWorkerThreads= 2727;
int poolMaxConnectionReuse = 3932;
int poolMaxConnections = 3382;
int poolMaxSessionFailures = 857;
int poolRequestInvokerThreads = 8362;
AbstractModule module1 = new AbstractModule() {
@Override
protected void configure() {
}
};
AbstractModule module2 = new AbstractModule() {
@Override
protected void configure() {
}
};
S3ContextFactory factory = S3ContextFactory.createContext(awsAccessKeyId, awsSecretAccessKey);
factory.withHttpAddress(httpAddress);
factory.withHttpMaxRetries(httpMaxRetries);
factory.withHttpPort(httpPort);
factory.withHttpSecure(httpSecure);
factory.withModule(module1);
factory.withModules(module2);
factory.withPoolIoWorkerThreads(poolIoWorkerThreads);
factory.withPoolMaxConnectionReuse(poolMaxConnectionReuse);
factory.withPoolMaxConnections(poolMaxConnections);
factory.withPoolMaxSessionFailures(poolMaxSessionFailures);
factory.withPoolRequestInvokerThreads(poolRequestInvokerThreads);
Properties properties = factory.getProperties();
}
} }

View File

@ -166,15 +166,16 @@ public class S3IntegrationTest {
} }
protected void createStubS3Context() { protected void createStubS3Context() {
Properties props = new Properties(); context = S3ContextFactory.createContext("stub", "stub")
props.setProperty(S3Constants.PROPERTY_HTTP_ADDRESS, "stub"); .withHttpAddress("stub")
context = S3ContextFactory.createS3Context(props, new StubS3ConnectionModule()); .withModule(new StubS3ConnectionModule())
.build();
} }
protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) { protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) {
context = S3ContextFactory.createS3Context(buildS3Properties(checkNotNull(AWSAccessKeyId, context = buildS3ContextFactory(AWSAccessKeyId, AWSSecretAccessKey)
"AWSAccessKeyId"), checkNotNull(AWSSecretAccessKey, "AWSSecretAccessKey")), .withModule(createHttpModule())
createHttpModule()); .build();
} }
@BeforeMethod(dependsOnMethods = "deleteBucket", groups = { "integration", "live" }) @BeforeMethod(dependsOnMethods = "deleteBucket", groups = { "integration", "live" })
@ -195,15 +196,10 @@ public class S3IntegrationTest {
return false; return false;
} }
protected Properties buildS3Properties(String AWSAccessKeyId, String AWSSecretAccessKey) { protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId, String AWSSecretAccessKey) {
Properties properties = new Properties(S3ContextFactory.DEFAULT_PROPERTIES); return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey)
properties.setProperty(S3Constants.PROPERTY_AWS_ACCESSKEYID, checkNotNull(AWSAccessKeyId, .withHttpSecure(false)
"AWSAccessKeyId")); .withHttpPort(80);
properties.setProperty(S3Constants.PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(
AWSSecretAccessKey, "AWSSecretAccessKey"));
properties.setProperty(HttpConstants.PROPERTY_HTTP_SECURE, "false");
properties.setProperty(HttpConstants.PROPERTY_HTTP_PORT, "80");
return properties;
} }
protected Module createHttpModule() { protected Module createHttpModule() {

View File

@ -25,8 +25,6 @@ package org.jclouds.aws.s3;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.Properties;
/** /**
* This performs the same test as {@link S3ConnectionIntegrationTest}, except using SSL. * This performs the same test as {@link S3ConnectionIntegrationTest}, except using SSL.
* *
@ -35,13 +33,11 @@ import java.util.Properties;
@Test(groups = {"live"}, testName = "s3.SecureS3ConnectionIntegrationTest") @Test(groups = {"live"}, testName = "s3.SecureS3ConnectionIntegrationTest")
public class SecureS3ConnectionIntegrationTest extends S3ConnectionIntegrationTest { public class SecureS3ConnectionIntegrationTest extends S3ConnectionIntegrationTest {
@Override @Override
protected Properties buildS3Properties(String AWSAccessKeyId, protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId,
String AWSSecretAccessKey) { String AWSSecretAccessKey) {
Properties properties = super.buildS3Properties(AWSAccessKeyId, return S3ContextFactory.createContext(AWSAccessKeyId, AWSSecretAccessKey)
AWSSecretAccessKey); .withHttpSecure(true)
properties.setProperty("jclouds.http.secure", Boolean.toString(true)); .withHttpPort(443);
properties.setProperty("jclouds.http.port", "443");
return properties;
} }
} }

View File

@ -103,6 +103,8 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
throws S3ServiceException, InterruptedException, ExecutionException throws S3ServiceException, InterruptedException, ExecutionException
{ {
String bucketName = bucketPrefix + ".testCreateBucketImplStringStringAccessControlList"; String bucketName = bucketPrefix + ".testCreateBucketImplStringStringAccessControlList";
bucketName = bucketName.toLowerCase();
S3Bucket bucket = service.createBucket(new S3Bucket(bucketName)); S3Bucket bucket = service.createBucket(new S3Bucket(bucketName));
assertEquals(bucket.getName(), bucketName); assertEquals(bucket.getName(), bucketName);
assertTrue(client.bucketExists(bucketName).get()); assertTrue(client.bucketExists(bucketName).get());
@ -114,6 +116,9 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
public void testDeleteBucketImplString() throws S3ServiceException, public void testDeleteBucketImplString() throws S3ServiceException,
InterruptedException, ExecutionException, TimeoutException { InterruptedException, ExecutionException, TimeoutException {
String bucketName = bucketPrefix + ".testDeleteBucketImplString"; String bucketName = bucketPrefix + ".testDeleteBucketImplString";
bucketName = bucketName.toLowerCase();
service.deleteBucket(bucketName); service.deleteBucket(bucketName);
assert !client.bucketExists(bucketName).get(10, TimeUnit.SECONDS); assert !client.bucketExists(bucketName).get(10, TimeUnit.SECONDS);
} }
@ -130,6 +135,8 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
String objectKey = "key"; String objectKey = "key";
String objectValue = "test"; String objectValue = "test";
bucketName = bucketName.toLowerCase();
addNewObject(bucketName, objectKey, objectValue); addNewObject(bucketName, objectKey, objectValue);
service.deleteObject(bucketName, objectKey); service.deleteObject(bucketName, objectKey);
@ -187,6 +194,8 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
String objectKey = "key"; String objectKey = "key";
String objectValue = "test"; String objectValue = "test";
bucketName = bucketName.toLowerCase();
addNewObject(bucketName, objectKey, objectValue); addNewObject(bucketName, objectKey, objectValue);
S3Object objectDetails = service.getObjectDetails(new S3Bucket(bucketName), objectKey); S3Object objectDetails = service.getObjectDetails(new S3Bucket(bucketName), objectKey);
@ -208,6 +217,8 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
String objectKey = "key"; String objectKey = "key";
String objectValue = "test"; String objectValue = "test";
bucketName = bucketName.toLowerCase();
addNewObject(bucketName, objectKey, objectValue); addNewObject(bucketName, objectKey, objectValue);
S3Object object = service.getObject(new S3Bucket(bucketName), objectKey); S3Object object = service.getObject(new S3Bucket(bucketName), objectKey);
@ -239,6 +250,8 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
ExecutionException, TimeoutException, S3ServiceException { ExecutionException, TimeoutException, S3ServiceException {
// Ensure there is at least 1 bucket in S3 account to list and compare. // Ensure there is at least 1 bucket in S3 account to list and compare.
String bucketName = bucketPrefix + ".testListAllBucketsImplString"; String bucketName = bucketPrefix + ".testListAllBucketsImplString";
bucketName = bucketName.toLowerCase();
createBucket(bucketName); createBucket(bucketName);
S3Bucket[] jsBuckets = service.listAllBuckets(); S3Bucket[] jsBuckets = service.listAllBuckets();

View File

@ -23,8 +23,6 @@
*/ */
package org.jclouds.aws.s3; package org.jclouds.aws.s3;
import java.util.Properties;
import org.jclouds.http.httpnio.config.HttpNioConnectionPoolClientModule; import org.jclouds.http.httpnio.config.HttpNioConnectionPoolClientModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -34,15 +32,14 @@ import com.google.inject.Module;
public class JCloudsNioPerformanceLiveTest extends BaseJCloudsPerformance { public class JCloudsNioPerformanceLiveTest extends BaseJCloudsPerformance {
@Override @Override
protected Properties buildS3Properties(String AWSAccessKeyId, protected S3ContextFactory buildS3ContextFactory(String AWSAccessKeyId,
String AWSSecretAccessKey) { String AWSSecretAccessKey) {
Properties properties = super.buildS3Properties(AWSAccessKeyId, AWSSecretAccessKey); return super.buildS3ContextFactory(AWSAccessKeyId, AWSSecretAccessKey)
properties.setProperty("jclouds.http.pool.max_connection_reuse", "75"); .withPoolMaxConnectionReuse(75)
properties.setProperty("jclouds.http.pool.max_session_failures", "2"); .withPoolMaxSessionFailures(2)
properties.setProperty("jclouds.http.pool.request_invoker_threads", "1"); .withPoolRequestInvokerThreads(1)
properties.setProperty("jclouds.http.pool.io_worker_threads", "2"); .withPoolIoWorkerThreads(2)
properties.setProperty("jclouds.pool.max_connections", "12"); .withPoolMaxConnections(12);
return properties;
} }
@Override @Override