diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java index 553bdd9750..82c152168a 100644 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/AtmosAsyncBlobStore.java @@ -19,8 +19,8 @@ package org.jclouds.atmosonline.saas.blobstore; import static com.google.common.util.concurrent.Futures.compose; -import static com.google.common.util.concurrent.Futures.makeListenable; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.net.URI; import java.util.concurrent.Callable; @@ -98,7 +98,7 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob return null; } - })); + }), service); } /** @@ -140,7 +140,7 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob return null; } - })); + }), service); } public ListenableFuture containerExists(String container) { diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3Client.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3Client.java index 40f252b473..b7b001c40c 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3Client.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3Client.java @@ -182,6 +182,7 @@ public interface S3Client { * /> * */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) boolean putBucketInRegion(Region region, String bucketName, PutBucketOptions... options); /** diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java index 0bd7fc1111..2a6d01e36c 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextBuilder.java @@ -18,8 +18,15 @@ */ package org.jclouds.aws.s3; +import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_METADATA_PREFIX; +import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_RETRY; +import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_TIMEOUT; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_RETRY; +import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; + import java.util.List; import java.util.Properties; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import org.jclouds.aws.s3.config.S3ContextModule; @@ -28,6 +35,7 @@ import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.rest.RestContextBuilder; +import com.google.common.collect.ImmutableMap; import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -50,7 +58,17 @@ public class S3ContextBuilder extends RestContextBuilder() { }, new TypeLiteral() { - }, props); + }, convert(props)); + } + + private static Properties convert(Properties props) { + for (Entry entry : ImmutableMap.of(PROPERTY_S3_METADATA_PREFIX, + PROPERTY_USER_METADATA_PREFIX, PROPERTY_S3_RETRY, PROPERTY_BLOBSTORE_RETRY, + PROPERTY_S3_TIMEOUT, PROPERTY_USER_METADATA_PREFIX).entrySet()) { + if (props.containsKey(entry.getKey())) + props.setProperty(entry.getValue(), props.getProperty(entry.getKey())); + } + return props; } @Override diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java index 9c1e00d4af..463572be4a 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/S3AsyncBlobStore.java @@ -19,8 +19,8 @@ package org.jclouds.aws.s3.blobstore; import static com.google.common.util.concurrent.Futures.compose; -import static com.google.common.util.concurrent.Futures.makeListenable; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.util.SortedSet; import java.util.concurrent.Callable; @@ -87,7 +87,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore * This implementation uses the S3 HEAD Object command to return the result */ public ListenableFuture blobMetadata(String container, String key) { - return compose(makeListenable(async.headObject(container, key)), + return compose(makeListenable(async.headObject(container, key), service), new Function() { @Override @@ -106,7 +106,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore return null; } - })); + }), service); } public ListenableFuture deleteContainer(final String container) { @@ -118,7 +118,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore return null; } - })); + }), service); } public ListenableFuture createContainerInLocation(String location, String container) { @@ -137,7 +137,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore return null; } - })); + }), service); } public ListenableFuture directoryExists(final String container, final String directory) { @@ -152,7 +152,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore } } - })); + }), service); } public ListenableFuture getBlob(String container, String key, diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java b/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java index 6beb5bc5fb..f0f5936bd3 100755 --- a/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/internal/StubS3AsyncClient.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.SortedSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutorService; import javax.inject.Inject; @@ -63,13 +64,13 @@ import org.jclouds.blobstore.domain.MutableBlobMetadata; import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions; import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.concurrent.internal.ConcurrentUtils; import org.jclouds.date.DateService; import org.jclouds.http.options.GetOptions; import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; /** @@ -90,6 +91,7 @@ public class StubS3AsyncClient implements S3AsyncClient { private final BlobToObjectMetadata blob2ObjectMetadata; private final BucketToContainerListOptions bucket2ContainerListOptions; private final ResourceToBucketList resource2BucketList; + private final ExecutorService executorService; @Inject private StubS3AsyncClient(StubAsyncBlobStore blobStore, @@ -98,7 +100,7 @@ public class StubS3AsyncClient implements S3AsyncClient { HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob, BlobToObject blob2Object, BlobToObjectMetadata blob2ObjectMetadata, BucketToContainerListOptions bucket2ContainerListOptions, - ResourceToBucketList resource2BucketList) { + ResourceToBucketList resource2BucketList, ExecutorService executorService) { this.blobStore = blobStore; this.objectProvider = objectProvider; this.blobProvider = blobProvider; @@ -110,6 +112,7 @@ public class StubS3AsyncClient implements S3AsyncClient { this.bucket2ContainerListOptions = checkNotNull(bucket2ContainerListOptions, "bucket2ContainerListOptions"); this.resource2BucketList = checkNotNull(resource2BucketList, "resource2BucketList"); + this.executorService = checkNotNull(executorService, "executorService"); } public static final String TEST_ACL_ID = "1a405254c932b52e5b5caaa88186bc431a1bacb9ece631f835daddaf0c47677c"; @@ -268,13 +271,13 @@ public class StubS3AsyncClient implements S3AsyncClient { } public ListenableFuture headObject(String bucketName, String key) { - return compose(Futures.makeListenable(blobStore.blobMetadata(bucketName, key)), - new Function() { - @Override - public ObjectMetadata apply(BlobMetadata from) { - return blob2ObjectMetadata.apply(from); - } - }); + return compose(ConcurrentUtils.makeListenable(blobStore.blobMetadata(bucketName, key), + executorService), new Function() { + @Override + public ObjectMetadata apply(BlobMetadata from) { + return blob2ObjectMetadata.apply(from); + } + }); } public ListenableFuture> listOwnedBuckets() { diff --git a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java index a0f08068d4..99c9db8f7c 100755 --- a/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java +++ b/aws/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToContainerResult.java @@ -26,8 +26,8 @@ import javax.inject.Singleton; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.ContainerNotFoundException; -import org.jclouds.blobstore.domain.ResourceMetadata; -import org.jclouds.blobstore.domain.ResourceType; +import org.jclouds.blobstore.domain.StorageMetadata; +import org.jclouds.blobstore.domain.StorageType; import org.jclouds.logging.Logger; import org.jclouds.samples.googleappengine.domain.ContainerResult; @@ -38,7 +38,7 @@ import com.google.common.collect.Sets; @Singleton public class BlobStoreContextToContainerResult implements Function { - private final class BuildContainerResult implements Function { + private final class BuildContainerResult implements Function { private final String host; private final BlobStoreContext context; private final String contextName; @@ -49,7 +49,7 @@ public class BlobStoreContextToContainerResult implements Function context = contexts.get(contextName); final String host = context.getEndPoint().getHost(); try { - ResourceMetadata md = Iterables.getLast(Sets.newTreeSet(Iterables.filter(context - .getBlobStore().list(), new Predicate() { + StorageMetadata md = Iterables.getLast(Sets.newTreeSet(Iterables.filter(context + .getBlobStore().list(), new Predicate() { - public boolean apply(ResourceMetadata input) { - return input.getType() == ResourceType.CONTAINER; + public boolean apply(StorageMetadata input) { + return input.getType() == StorageType.CONTAINER; } }))); diff --git a/aws/perftest/pom.xml b/aws/perftest/pom.xml index 2ac8c980c9..205d72cd15 100644 --- a/aws/perftest/pom.xml +++ b/aws/perftest/pom.xml @@ -80,13 +80,13 @@ com.google.appengine appengine-api-stubs - 1.2.5 + 1.3.0 test com.google.appengine appengine-local-runtime - 1.2.5 + 1.3.0 test diff --git a/aws/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java b/aws/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java index fd371ebd24..54bff7ee51 100755 --- a/aws/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java +++ b/aws/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.s3; -import static org.jclouds.aws.s3.options.PutBucketOptions.Builder.createIn; - import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; @@ -35,7 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.inject.Provider; -import org.jclouds.aws.s3.domain.BucketMetadata.LocationConstraint; +import org.jclouds.aws.domain.Region; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -89,7 +87,7 @@ public abstract class BasePerformanceLiveTest extends protected String createScratchContainerInEU() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getScratchContainerName(); - context.getApi().putBucketIfNotExists(containerName, createIn(LocationConstraint.EU)); + context.getApi().putBucketInRegion(Region.EU_WEST_1, containerName); return containerName; } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java index 1b6da3a571..20b2497522 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/AzureAsyncBlobStore.java @@ -19,8 +19,8 @@ package org.jclouds.azure.storage.blob.blobstore; import static com.google.common.util.concurrent.Futures.compose; -import static com.google.common.util.concurrent.Futures.makeListenable; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.util.SortedSet; import java.util.concurrent.Callable; @@ -106,7 +106,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob return null; } - })); + }), service); } /** @@ -167,7 +167,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob return null; } - })); + }), service); } public ListenableFuture directoryExists(final String container, final String directory) { @@ -182,7 +182,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob } } - })); + }), service); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java index 9a86b405bc..ff5ba29a3c 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/StubAsyncBlobStore.java @@ -21,7 +21,7 @@ package org.jclouds.blobstore.integration.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Futures.immediateFailedFuture; import static com.google.common.util.concurrent.Futures.immediateFuture; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -593,7 +593,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { return null; } - })); + }), service); } public ListenableFuture directoryExists(final String container, final String directory) { @@ -607,7 +607,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore { } } - })); + }), service); } public Blob newBlob(String name) { diff --git a/core/src/main/java/org/jclouds/concurrent/internal/ConcurrentUtils.java b/core/src/main/java/org/jclouds/concurrent/internal/ConcurrentUtils.java new file mode 100644 index 0000000000..d4c0ba2d50 --- /dev/null +++ b/core/src/main/java/org/jclouds/concurrent/internal/ConcurrentUtils.java @@ -0,0 +1,111 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * 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.concurrent.internal; + +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicBoolean; + +import javax.inject.Singleton; + +import com.google.common.util.concurrent.ExecutionList; +import com.google.common.util.concurrent.ForwardingFuture; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Adapt things missing from Guava. + * + * @author Adrian Cole + */ +@Singleton +public class ConcurrentUtils { + + /** + * Just like {@code Futures#makeListenable} except that we pass in an executorService. + *

+ * Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed. + */ + public static ListenableFuture makeListenable(Future future, ExecutorService executorService) { + if (future instanceof ListenableFuture) { + return (ListenableFuture) future; + } + return new ListenableFutureAdapter(executorService, future); + } + + /** + * Just like {@code Futures#ListenableFutureAdapter} except that we pass in an executorService. + *

+ * Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed. + */ + private static class ListenableFutureAdapter extends ForwardingFuture implements + ListenableFuture { + + private final Executor adapterExecutor; + + // The execution list to hold our listeners. + private final ExecutionList executionList = new ExecutionList(); + + // This allows us to only start up a thread waiting on the delegate future + // when the first listener is added. + private final AtomicBoolean hasListeners = new AtomicBoolean(false); + + // The delegate future. + private final Future delegate; + + ListenableFutureAdapter(ExecutorService executorService, final Future delegate) { + this.adapterExecutor = executorService; + this.delegate = delegate; + } + + @Override + protected Future delegate() { + return delegate; + } + + /* @Override */ + public void addListener(Runnable listener, Executor exec) { + + // When a listener is first added, we run a task that will wait for + // the delegate to finish, and when it is done will run the listeners. + if (!hasListeners.get() && hasListeners.compareAndSet(false, true)) { + adapterExecutor.execute(new Runnable() { + /* @Override */ + public void run() { + try { + delegate.get(); + } catch (CancellationException e) { + // The task was cancelled, so it is done, run the listeners. + } catch (InterruptedException e) { + // This thread was interrupted. This should never happen, so we + // throw an IllegalStateException. + throw new IllegalStateException("Adapter thread interrupted!", e); + } catch (ExecutionException e) { + // The task caused an exception, so it is done, run the listeners. + } + executionList.run(); + } + }); + } + executionList.add(listener, exec); + } + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java index 973741e956..ea8b41af5b 100644 --- a/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java @@ -18,7 +18,7 @@ */ package org.jclouds.http.internal; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.io.IOException; import java.util.concurrent.Callable; @@ -64,7 +64,8 @@ public abstract class BaseHttpCommandExecutorService implements HttpCommandEx } public ListenableFuture submit(HttpCommand command) { - return makeListenable(executorService.submit(new HttpResponseCallable(command))); + return makeListenable(executorService.submit(new HttpResponseCallable(command)), + executorService); } public class HttpResponseCallable implements Callable { diff --git a/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java b/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java index f63454363d..f384d4a29f 100755 --- a/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java +++ b/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.concurrent; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import static org.testng.Assert.assertEquals; import java.util.concurrent.Callable; @@ -76,7 +76,7 @@ public class FutureExceptionParserTest { throw exception; } - })); + }), executorService); future = new FutureExceptionParser(future, new Function() { diff --git a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java index 1f98c1a312..437416fe99 100644 --- a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java +++ b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.concurrent.internal; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import static org.testng.Assert.assertEquals; import java.io.FileNotFoundException; @@ -79,7 +79,7 @@ public class SyncProxyTest { return "foo"; } - })); + }), executorService); } public ListenableFuture getRuntimeException() { @@ -89,7 +89,7 @@ public class SyncProxyTest { throw new RuntimeException(); } - })); + }), executorService); } public ListenableFuture getTypedException() throws FileNotFoundException { @@ -99,7 +99,7 @@ public class SyncProxyTest { throw new FileNotFoundException(); } - })); + }), executorService); } public String newString() { @@ -118,7 +118,7 @@ public class SyncProxyTest { return "foo"; } - })); + }), executorService); } public ListenableFuture take100MillisecondsAndTimeout() { @@ -133,7 +133,7 @@ public class SyncProxyTest { return "foo"; } - })); + }), executorService); } public ListenableFuture take100MillisecondsAndOverride() { diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index e31ec2f10d..e6d9063d96 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -53,7 +53,7 @@ public class AddTweetsControllerTest { for (String name : new String[] { "1", "2" }) { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getAsyncBlobStore().createContainer(container).get(); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 74940c10bf..b76b027a5a 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -60,7 +60,7 @@ public class StoreTweetsControllerTest { .> of("test1", new StubBlobStoreContextBuilder() .buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext()); for (BlobStoreContext blobstore : contexts.values()) { - blobstore.getAsyncBlobStore().createContainer("favo").get(); + blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 01346f4dfc..b40a2fa701 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -44,7 +44,7 @@ public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getBlobStore().createContainer("test1"); + context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 18b05a0ade..06ae089ddf 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -50,7 +50,7 @@ public class ServiceToStoredTweetStatusesTest { for (String name : new String[] { "1", "2" }) { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getAsyncBlobStore().createContainer(container).get(); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 862b92e9a3..b482f86305 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -42,8 +42,6 @@ import org.jclouds.aws.s3.S3PropertiesBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; -import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder; -import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextFactory; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; @@ -58,146 +56,146 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * Starts up the Google App Engine for Java Development environment and deploys - * an application which tests accesses twitter and blobstores. + * Starts up the Google App Engine for Java Development environment and deploys an application which + * tests accesses twitter and blobstores. * * @author Adrian Cole */ @Test(groups = "live", sequential = true, testName = "functionalTests") public class TweetStoreLiveTest { - GoogleDevServer server; - private URL url; - private ImmutableSet> contexts; - private String container; + GoogleDevServer server; + private URL url; + private ImmutableSet> contexts; + private String container; - @BeforeTest - @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) - public void startDevAppServer(final String warfile, final String address, - final String port) throws Exception { - url = new URL(String.format("http://%s:%s", address, port)); - Properties props = new Properties(); - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, - checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); - props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, - // WATCH THIS.. when adding a new context, you must update the string - String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), - CloudFilesBlobStoreContextBuilder.class.getName(), - AzureBlobStoreContextBuilder.class.getName())); + @BeforeTest + @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) + public void startDevAppServer(final String warfile, final String address, final String port) + throws Exception { + url = new URL(String.format("http://%s:%s", address, port)); + Properties props = new Properties(); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System + .getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); + props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, + // WATCH THIS.. when adding a new context, you must update the string + // String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), + // CloudFilesBlobStoreContextBuilder.class.getName(), + // AzureBlobStoreContextBuilder.class.getName())); + String.format("%s,%s", S3BlobStoreContextBuilder.class.getName(), + CloudFilesBlobStoreContextBuilder.class.getName())); + props = new TwitterPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), + System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build(); - props = new TwitterPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), - System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)) - .build(); + props = new S3PropertiesBuilder(props) + .withCredentials( + checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), + PROPERTY_AWS_ACCESSKEYID), + System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, + PROPERTY_AWS_SECRETACCESSKEY)).build(); - props = new S3PropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), - System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)) - .build(); + props = new CloudFilesPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build(); - props = new CloudFilesPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)) - .build(); + props = new AzureBlobPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), + PROPERTY_AZURESTORAGE_ACCOUNT), + System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build(); - props = new AzureBlobPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)) - .build(); + server = new GoogleDevServer(); + server.writePropertiesAndStartServer(address, port, warfile, props); + } - server = new GoogleDevServer(); - server.writePropertiesAndStartServer(address, port, warfile, props); - } + @BeforeClass + void clearAndCreateContainers() throws InterruptedException, ExecutionException, + TimeoutException { + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); + BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext(checkNotNull( + System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System + .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); - @BeforeClass - void clearAndCreateContainers() throws InterruptedException, - ExecutionException, TimeoutException { - container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), - System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); + BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); - BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); + // BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext(checkNotNull( + // System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), + // System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); + // + // this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); + this.contexts = ImmutableSet.of(s3Context, cfContext); + boolean deleted = false; + for (BlobStoreContext context : contexts) { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } + if (deleted) { + System.err.println("sleeping 30 seconds to allow containers to clear"); + Thread.sleep(30000); + } + for (BlobStoreContext context : contexts) { + System.err.printf("creating container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().createContainerInLocation(null, container); + } + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(30000); + } + } - BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); + @Test + public void shouldPass() throws InterruptedException, IOException { + InputStream i = url.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Welcome") >= 0 : string; + } - this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); - boolean deleted = false; - for (BlobStoreContext context : contexts) { - if (context.getBlobStore().containerExists(container)) { - System.err.printf("deleting container %s at %s%n", container, - context.getEndPoint()); - context.getBlobStore().deleteContainer(container); - deleted = true; - } - } - if (deleted) { - System.err.println("sleeping 30 seconds to allow containers to clear"); - Thread.sleep(30000); - } - for (BlobStoreContext context : contexts) { - System.err.printf("creating container %s at %s%n", container, - context.getEndPoint()); - context.getBlobStore().createContainer(container); - } - if (deleted) { - System.err.println("sleeping 5 seconds to allow containers to create"); - Thread.sleep(30000); - } - } + @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) + public void shouldFail() throws InterruptedException, IOException { + new URL(url, "/store/do").openStream(); + } - @Test - public void shouldPass() throws InterruptedException, IOException { - InputStream i = url.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Welcome") >= 0 : string; - } + @Test(dependsOnMethods = "shouldFail") + public void testPrimeContainers() throws IOException, InterruptedException { + URL gurl = new URL(url, "/store/do"); - @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) - public void shouldFail() throws InterruptedException, IOException { - new URL(url, "/store/do").openStream(); - } + for (String context : new String[] { "S3", "CloudFiles" }) { + // for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { + System.out.println("storing at context: " + context); + HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); + connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); + connection.addRequestProperty("context", context); + InputStream i = connection.getInputStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Done!") >= 0 : string; + connection.disconnect(); + } - @Test(dependsOnMethods = "shouldFail") - public void testPrimeContainers() throws IOException, InterruptedException { - URL gurl = new URL(url, "/store/do"); + System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); + Thread.sleep(10000); + for (BlobStoreContext context : contexts) { + assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); + } + } - for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { - System.out.println("storing at context: " + context); - HttpURLConnection connection = (HttpURLConnection) gurl - .openConnection(); - connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); - connection.addRequestProperty("context", context); - InputStream i = connection.getInputStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Done!") >= 0 : string; - connection.disconnect(); - } + @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") + public void testSerial() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } - System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); - Thread.sleep(10000); - for (BlobStoreContext context : contexts) { - assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); - } - } - - @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") - public void testSerial() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } - - @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) - public void testParallel() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } + @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) + public void testParallel() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } } \ No newline at end of file diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index e31ec2f10d..e6d9063d96 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -53,7 +53,7 @@ public class AddTweetsControllerTest { for (String name : new String[] { "1", "2" }) { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getAsyncBlobStore().createContainer(container).get(); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java index 74940c10bf..b76b027a5a 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -60,7 +60,7 @@ public class StoreTweetsControllerTest { .> of("test1", new StubBlobStoreContextBuilder() .buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext()); for (BlobStoreContext blobstore : contexts.values()) { - blobstore.getAsyncBlobStore().createContainer("favo").get(); + blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); } return contexts; } diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 01346f4dfc..b40a2fa701 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -44,7 +44,7 @@ public class KeyToStoredTweetStatusTest { BlobMap createMap() throws InterruptedException, ExecutionException { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getBlobStore().createContainer("test1"); + context.getBlobStore().createContainerInLocation(null, "test1"); return context.createBlobMap("test1"); } diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index 18b05a0ade..06ae089ddf 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -50,7 +50,7 @@ public class ServiceToStoredTweetStatusesTest { for (String name : new String[] { "1", "2" }) { BlobStoreContext context = new StubBlobStoreContextBuilder() .buildContext(); - context.getAsyncBlobStore().createContainer(container).get(); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); Blob blob = context.getAsyncBlobStore().newBlob("1"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index 862b92e9a3..4a3825398e 100755 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -42,8 +42,6 @@ import org.jclouds.aws.s3.S3PropertiesBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; -import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder; -import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextFactory; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; @@ -58,146 +56,150 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * Starts up the Google App Engine for Java Development environment and deploys - * an application which tests accesses twitter and blobstores. + * Starts up the Google App Engine for Java Development environment and deploys an application which + * tests accesses twitter and blobstores. * * @author Adrian Cole */ @Test(groups = "live", sequential = true, testName = "functionalTests") public class TweetStoreLiveTest { - GoogleDevServer server; - private URL url; - private ImmutableSet> contexts; - private String container; + GoogleDevServer server; + private URL url; + private ImmutableSet> contexts; + private String container; - @BeforeTest - @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) - public void startDevAppServer(final String warfile, final String address, - final String port) throws Exception { - url = new URL(String.format("http://%s:%s", address, port)); - Properties props = new Properties(); - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, - checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); - props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, - // WATCH THIS.. when adding a new context, you must update the string - String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), - CloudFilesBlobStoreContextBuilder.class.getName(), - AzureBlobStoreContextBuilder.class.getName())); + @BeforeTest + @Parameters( { "warfile", "devappserver.address", "devappserver.port" }) + public void startDevAppServer(final String warfile, final String address, final String port) + throws Exception { + url = new URL(String.format("http://%s:%s", address, port)); + Properties props = new Properties(); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System + .getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); + props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, + // WATCH THIS.. when adding a new context, you must update the string + // String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), + // CloudFilesBlobStoreContextBuilder.class.getName(), + // AzureBlobStoreContextBuilder.class.getName())); + String.format("%s,%s", S3BlobStoreContextBuilder.class.getName(), + CloudFilesBlobStoreContextBuilder.class.getName())); + props = new TwitterPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), + System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build(); - props = new TwitterPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), - System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)) - .build(); + props = new TwitterPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), + System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build(); - props = new S3PropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), - System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)) - .build(); + props = new S3PropertiesBuilder(props) + .withCredentials( + checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), + PROPERTY_AWS_ACCESSKEYID), + System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, + PROPERTY_AWS_SECRETACCESSKEY)).build(); - props = new CloudFilesPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)) - .build(); + props = new CloudFilesPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build(); - props = new AzureBlobPropertiesBuilder(props).withCredentials( - checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)) - .build(); + props = new AzureBlobPropertiesBuilder(props).withCredentials( + checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), + PROPERTY_AZURESTORAGE_ACCOUNT), + System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build(); - server = new GoogleDevServer(); - server.writePropertiesAndStartServer(address, port, warfile, props); - } + server = new GoogleDevServer(); + server.writePropertiesAndStartServer(address, port, warfile, props); + } - @BeforeClass - void clearAndCreateContainers() throws InterruptedException, - ExecutionException, TimeoutException { - container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), - System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); + @BeforeClass + void clearAndCreateContainers() throws InterruptedException, ExecutionException, + TimeoutException { + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); + BlobStoreContext s3Context = S3BlobStoreContextFactory.createContext(checkNotNull( + System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System + .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); - BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), - System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); + BlobStoreContext cfContext = CloudFilesBlobStoreContextFactory.createContext( + checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), + System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); - BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext( - checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), - System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); +// BlobStoreContext azContext = AzureBlobStoreContextFactory.createContext(checkNotNull( +// System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), +// System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); +// +// this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); + this.contexts = ImmutableSet.of(s3Context, cfContext); + boolean deleted = false; + for (BlobStoreContext context : contexts) { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } + if (deleted) { + System.err.println("sleeping 30 seconds to allow containers to clear"); + Thread.sleep(30000); + } + for (BlobStoreContext context : contexts) { + System.err.printf("creating container %s at %s%n", container, context.getEndPoint()); + context.getBlobStore().createContainerInLocation(null, container); + } + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(30000); + } + } - this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); - boolean deleted = false; - for (BlobStoreContext context : contexts) { - if (context.getBlobStore().containerExists(container)) { - System.err.printf("deleting container %s at %s%n", container, - context.getEndPoint()); - context.getBlobStore().deleteContainer(container); - deleted = true; - } - } - if (deleted) { - System.err.println("sleeping 30 seconds to allow containers to clear"); - Thread.sleep(30000); - } - for (BlobStoreContext context : contexts) { - System.err.printf("creating container %s at %s%n", container, - context.getEndPoint()); - context.getBlobStore().createContainer(container); - } - if (deleted) { - System.err.println("sleeping 5 seconds to allow containers to create"); - Thread.sleep(30000); - } - } + @Test + public void shouldPass() throws InterruptedException, IOException { + InputStream i = url.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Welcome") >= 0 : string; + } - @Test - public void shouldPass() throws InterruptedException, IOException { - InputStream i = url.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Welcome") >= 0 : string; - } + @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) + public void shouldFail() throws InterruptedException, IOException { + new URL(url, "/store/do").openStream(); + } - @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) - public void shouldFail() throws InterruptedException, IOException { - new URL(url, "/store/do").openStream(); - } + @Test(dependsOnMethods = "shouldFail") + public void testPrimeContainers() throws IOException, InterruptedException { + URL gurl = new URL(url, "/store/do"); - @Test(dependsOnMethods = "shouldFail") - public void testPrimeContainers() throws IOException, InterruptedException { - URL gurl = new URL(url, "/store/do"); + for (String context : new String[] { "S3", "CloudFiles" }) { + // for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { + System.out.println("storing at context: " + context); + HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); + connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); + connection.addRequestProperty("context", context); + InputStream i = connection.getInputStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Done!") >= 0 : string; + connection.disconnect(); + } - for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { - System.out.println("storing at context: " + context); - HttpURLConnection connection = (HttpURLConnection) gurl - .openConnection(); - connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); - connection.addRequestProperty("context", context); - InputStream i = connection.getInputStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Done!") >= 0 : string; - connection.disconnect(); - } + System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); + Thread.sleep(10000); + for (BlobStoreContext context : contexts) { + assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); + } + } - System.err.println("sleeping 10 seconds to allow for eventual consistency delay"); - Thread.sleep(10000); - for (BlobStoreContext context : contexts) { - assert context.createInputStreamMap(container).size() > 0 : context.getEndPoint(); - } - } + @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") + public void testSerial() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } - @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") - public void testSerial() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } - - @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) - public void testParallel() throws InterruptedException, IOException { - URL gurl = new URL(url, "/tweets/get"); - InputStream i = gurl.openStream(); - String string = Utils.toStringAndClose(i); - assert string.indexOf("Tweets in Clouds") >= 0 : string; - } + @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) + public void testParallel() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Utils.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } } \ No newline at end of file diff --git a/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java b/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java index a25019de62..990be28f36 100755 --- a/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java +++ b/extensions/httpnio/src/main/java/org/jclouds/http/pool/ConnectionPoolTransformingHttpCommandExecutorService.java @@ -19,7 +19,7 @@ package org.jclouds.http.pool; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import java.net.URI; import java.util.concurrent.BlockingQueue; @@ -148,10 +148,10 @@ public class ConnectionPoolTransformingHttpCommandExecutorService extends Bas transformerLogger.debug("Processed intermediate result for: %s", o); return result; } - })); + }), executorService); HttpCommandRendezvous rendezvous = new HttpCommandRendezvous(command, channel, - makeListenable(future)); + makeListenable(future, executorService)); commandQueue.add(rendezvous); return rendezvous.getListenableFuture(); } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java index e97cdbdf29..1063d61000 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java @@ -19,7 +19,7 @@ package org.jclouds.rackspace.cloudfiles.blobstore; import static com.google.common.util.concurrent.Futures.compose; -import static com.google.common.util.concurrent.Futures.makeListenable; +import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable; import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive; import java.util.SortedSet; @@ -108,7 +108,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements return null; } - })); + }), service); } /** @@ -128,7 +128,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements return null; } - })); + }), service); } public ListenableFuture containerExists(String container) { @@ -179,7 +179,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements return null; } - })); + }), service); } public ListenableFuture directoryExists(final String container, final String directory) { @@ -193,7 +193,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements } } - })); + }), service); } } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 7fa4bf50f4..ce81ea0edd 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -129,7 +129,7 @@ public class VCloudClientLiveTest { assertNotNull(response.getId()); assertNotNull(response.getLocation()); assertNotNull(response.getTasks()); - assertEquals(connection.getTasksList(response.getId()), response.getId()); + assertEquals(connection.getTasksList(response.getId()).getId(), response.getId()); } @Test