git-svn-id: http://jclouds.googlecode.com/svn/trunk@2670 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-19 02:23:30 +00:00
parent 4407490ff0
commit 969bb8ea38
27 changed files with 444 additions and 312 deletions

View File

@ -19,8 +19,8 @@
package org.jclouds.atmosonline.saas.blobstore; package org.jclouds.atmosonline.saas.blobstore;
import static com.google.common.util.concurrent.Futures.compose; 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.blobstore.options.ListContainerOptions.Builder.recursive;
import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable;
import java.net.URI; import java.net.URI;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -98,7 +98,7 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob
return null; return null;
} }
})); }), service);
} }
/** /**
@ -140,7 +140,7 @@ public class AtmosAsyncBlobStore extends BaseAtmosBlobStore implements AsyncBlob
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> containerExists(String container) { public ListenableFuture<Boolean> containerExists(String container) {

View File

@ -182,6 +182,7 @@ public interface S3Client {
* /> * />
* *
*/ */
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
boolean putBucketInRegion(Region region, String bucketName, PutBucketOptions... options); boolean putBucketInRegion(Region region, String bucketName, PutBucketOptions... options);
/** /**

View File

@ -18,8 +18,15 @@
*/ */
package org.jclouds.aws.s3; 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.List;
import java.util.Properties; import java.util.Properties;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import org.jclouds.aws.s3.config.S3ContextModule; 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.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -50,7 +58,17 @@ public class S3ContextBuilder extends RestContextBuilder<S3AsyncClient, S3Client
public S3ContextBuilder(Properties props) { public S3ContextBuilder(Properties props) {
super(new TypeLiteral<S3AsyncClient>() { super(new TypeLiteral<S3AsyncClient>() {
}, new TypeLiteral<S3Client>() { }, new TypeLiteral<S3Client>() {
}, props); }, convert(props));
}
private static Properties convert(Properties props) {
for (Entry<String, String> 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 @Override

View File

@ -19,8 +19,8 @@
package org.jclouds.aws.s3.blobstore; package org.jclouds.aws.s3.blobstore;
import static com.google.common.util.concurrent.Futures.compose; 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.blobstore.options.ListContainerOptions.Builder.recursive;
import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.Callable; 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 * This implementation uses the S3 HEAD Object command to return the result
*/ */
public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) { public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) {
return compose(makeListenable(async.headObject(container, key)), return compose(makeListenable(async.headObject(container, key), service),
new Function<ObjectMetadata, BlobMetadata>() { new Function<ObjectMetadata, BlobMetadata>() {
@Override @Override
@ -106,7 +106,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Void> deleteContainer(final String container) { public ListenableFuture<Void> deleteContainer(final String container) {
@ -118,7 +118,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> createContainerInLocation(String location, String container) { public ListenableFuture<Boolean> createContainerInLocation(String location, String container) {
@ -137,7 +137,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> directoryExists(final String container, final String directory) { public ListenableFuture<Boolean> directoryExists(final String container, final String directory) {
@ -152,7 +152,7 @@ public class S3AsyncBlobStore extends BaseS3BlobStore implements AsyncBlobStore
} }
} }
})); }), service);
} }
public ListenableFuture<Blob> getBlob(String container, String key, public ListenableFuture<Blob> getBlob(String container, String key,

View File

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
@ -63,13 +64,13 @@ import org.jclouds.blobstore.domain.MutableBlobMetadata;
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions; import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore; import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
import org.jclouds.blobstore.options.ListContainerOptions; import org.jclouds.blobstore.options.ListContainerOptions;
import org.jclouds.concurrent.internal.ConcurrentUtils;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -90,6 +91,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
private final BlobToObjectMetadata blob2ObjectMetadata; private final BlobToObjectMetadata blob2ObjectMetadata;
private final BucketToContainerListOptions bucket2ContainerListOptions; private final BucketToContainerListOptions bucket2ContainerListOptions;
private final ResourceToBucketList resource2BucketList; private final ResourceToBucketList resource2BucketList;
private final ExecutorService executorService;
@Inject @Inject
private StubS3AsyncClient(StubAsyncBlobStore blobStore, private StubS3AsyncClient(StubAsyncBlobStore blobStore,
@ -98,7 +100,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob, HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
BlobToObject blob2Object, BlobToObjectMetadata blob2ObjectMetadata, BlobToObject blob2Object, BlobToObjectMetadata blob2ObjectMetadata,
BucketToContainerListOptions bucket2ContainerListOptions, BucketToContainerListOptions bucket2ContainerListOptions,
ResourceToBucketList resource2BucketList) { ResourceToBucketList resource2BucketList, ExecutorService executorService) {
this.blobStore = blobStore; this.blobStore = blobStore;
this.objectProvider = objectProvider; this.objectProvider = objectProvider;
this.blobProvider = blobProvider; this.blobProvider = blobProvider;
@ -110,6 +112,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
this.bucket2ContainerListOptions = checkNotNull(bucket2ContainerListOptions, this.bucket2ContainerListOptions = checkNotNull(bucket2ContainerListOptions,
"bucket2ContainerListOptions"); "bucket2ContainerListOptions");
this.resource2BucketList = checkNotNull(resource2BucketList, "resource2BucketList"); this.resource2BucketList = checkNotNull(resource2BucketList, "resource2BucketList");
this.executorService = checkNotNull(executorService, "executorService");
} }
public static final String TEST_ACL_ID = "1a405254c932b52e5b5caaa88186bc431a1bacb9ece631f835daddaf0c47677c"; public static final String TEST_ACL_ID = "1a405254c932b52e5b5caaa88186bc431a1bacb9ece631f835daddaf0c47677c";
@ -268,8 +271,8 @@ public class StubS3AsyncClient implements S3AsyncClient {
} }
public ListenableFuture<ObjectMetadata> headObject(String bucketName, String key) { public ListenableFuture<ObjectMetadata> headObject(String bucketName, String key) {
return compose(Futures.makeListenable(blobStore.blobMetadata(bucketName, key)), return compose(ConcurrentUtils.makeListenable(blobStore.blobMetadata(bucketName, key),
new Function<BlobMetadata, ObjectMetadata>() { executorService), new Function<BlobMetadata, ObjectMetadata>() {
@Override @Override
public ObjectMetadata apply(BlobMetadata from) { public ObjectMetadata apply(BlobMetadata from) {
return blob2ObjectMetadata.apply(from); return blob2ObjectMetadata.apply(from);

View File

@ -26,8 +26,8 @@ import javax.inject.Singleton;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.ContainerNotFoundException;
import org.jclouds.blobstore.domain.ResourceMetadata; import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.domain.ResourceType; import org.jclouds.blobstore.domain.StorageType;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.samples.googleappengine.domain.ContainerResult; import org.jclouds.samples.googleappengine.domain.ContainerResult;
@ -38,7 +38,7 @@ import com.google.common.collect.Sets;
@Singleton @Singleton
public class BlobStoreContextToContainerResult implements Function<String, ContainerResult> { public class BlobStoreContextToContainerResult implements Function<String, ContainerResult> {
private final class BuildContainerResult implements Function<ResourceMetadata, ContainerResult> { private final class BuildContainerResult implements Function<StorageMetadata, ContainerResult> {
private final String host; private final String host;
private final BlobStoreContext<?, ?> context; private final BlobStoreContext<?, ?> context;
private final String contextName; private final String contextName;
@ -49,7 +49,7 @@ public class BlobStoreContextToContainerResult implements Function<String, Conta
this.contextName = contextName; this.contextName = contextName;
} }
public ContainerResult apply(ResourceMetadata from) { public ContainerResult apply(StorageMetadata from) {
String status; String status;
try { try {
try { try {
@ -77,11 +77,11 @@ public class BlobStoreContextToContainerResult implements Function<String, Conta
final BlobStoreContext<?, ?> context = contexts.get(contextName); final BlobStoreContext<?, ?> context = contexts.get(contextName);
final String host = context.getEndPoint().getHost(); final String host = context.getEndPoint().getHost();
try { try {
ResourceMetadata md = Iterables.getLast(Sets.newTreeSet(Iterables.filter(context StorageMetadata md = Iterables.getLast(Sets.newTreeSet(Iterables.filter(context
.getBlobStore().list(), new Predicate<ResourceMetadata>() { .getBlobStore().list(), new Predicate<StorageMetadata>() {
public boolean apply(ResourceMetadata input) { public boolean apply(StorageMetadata input) {
return input.getType() == ResourceType.CONTAINER; return input.getType() == StorageType.CONTAINER;
} }
}))); })));

View File

@ -80,13 +80,13 @@
<dependency> <dependency>
<groupId>com.google.appengine</groupId> <groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId> <artifactId>appengine-api-stubs</artifactId>
<version>1.2.5</version> <version>1.3.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.appengine</groupId> <groupId>com.google.appengine</groupId>
<artifactId>appengine-local-runtime</artifactId> <artifactId>appengine-local-runtime</artifactId>
<version>1.2.5</version> <version>1.3.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.aws.s3; package org.jclouds.aws.s3;
import static org.jclouds.aws.s3.options.PutBucketOptions.Builder.createIn;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
@ -35,7 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.inject.Provider; 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.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -89,7 +87,7 @@ public abstract class BasePerformanceLiveTest extends
protected String createScratchContainerInEU() throws InterruptedException, ExecutionException, protected String createScratchContainerInEU() throws InterruptedException, ExecutionException,
TimeoutException { TimeoutException {
String containerName = getScratchContainerName(); String containerName = getScratchContainerName();
context.getApi().putBucketIfNotExists(containerName, createIn(LocationConstraint.EU)); context.getApi().putBucketInRegion(Region.EU_WEST_1, containerName);
return containerName; return containerName;
} }

View File

@ -19,8 +19,8 @@
package org.jclouds.azure.storage.blob.blobstore; package org.jclouds.azure.storage.blob.blobstore;
import static com.google.common.util.concurrent.Futures.compose; 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.blobstore.options.ListContainerOptions.Builder.recursive;
import static org.jclouds.concurrent.internal.ConcurrentUtils.makeListenable;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -106,7 +106,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob
return null; return null;
} }
})); }), service);
} }
/** /**
@ -167,7 +167,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> directoryExists(final String container, final String directory) { public ListenableFuture<Boolean> directoryExists(final String container, final String directory) {
@ -182,7 +182,7 @@ public class AzureAsyncBlobStore extends BaseAzureBlobStore implements AsyncBlob
} }
} }
})); }), service);
} }
} }

View File

@ -21,7 +21,7 @@ package org.jclouds.blobstore.integration.internal;
import static com.google.common.base.Preconditions.checkNotNull; 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.immediateFailedFuture;
import static com.google.common.util.concurrent.Futures.immediateFuture; 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.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -593,7 +593,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> directoryExists(final String container, final String directory) { public ListenableFuture<Boolean> directoryExists(final String container, final String directory) {
@ -607,7 +607,7 @@ public class StubAsyncBlobStore implements AsyncBlobStore {
} }
} }
})); }), service);
} }
public Blob newBlob(String name) { public Blob newBlob(String name) {

View File

@ -0,0 +1,111 @@
/**
*
* 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.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.
* <p/>
* Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed.
*/
public static <T> ListenableFuture<T> makeListenable(Future<T> future, ExecutorService executorService) {
if (future instanceof ListenableFuture<?>) {
return (ListenableFuture<T>) future;
}
return new ListenableFutureAdapter<T>(executorService, future);
}
/**
* Just like {@code Futures#ListenableFutureAdapter} except that we pass in an executorService.
* <p/>
* Temporary hack until http://code.google.com/p/guava-libraries/issues/detail?id=317 is fixed.
*/
private static class ListenableFutureAdapter<T> extends ForwardingFuture<T> implements
ListenableFuture<T> {
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<T> delegate;
ListenableFutureAdapter(ExecutorService executorService, final Future<T> delegate) {
this.adapterExecutor = executorService;
this.delegate = delegate;
}
@Override
protected Future<T> 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);
}
}
}

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.http.internal; 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.io.IOException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -64,7 +64,8 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
} }
public ListenableFuture<HttpResponse> submit(HttpCommand command) { public ListenableFuture<HttpResponse> submit(HttpCommand command) {
return makeListenable(executorService.submit(new HttpResponseCallable(command))); return makeListenable(executorService.submit(new HttpResponseCallable(command)),
executorService);
} }
public class HttpResponseCallable implements Callable<HttpResponse> { public class HttpResponseCallable implements Callable<HttpResponse> {

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.concurrent; 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 static org.testng.Assert.assertEquals;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -76,7 +76,7 @@ public class FutureExceptionParserTest {
throw exception; throw exception;
} }
})); }), executorService);
future = new FutureExceptionParser(future, new Function<Exception, String>() { future = new FutureExceptionParser(future, new Function<Exception, String>() {

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.concurrent.internal; 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 static org.testng.Assert.assertEquals;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -79,7 +79,7 @@ public class SyncProxyTest {
return "foo"; return "foo";
} }
})); }), executorService);
} }
public ListenableFuture<String> getRuntimeException() { public ListenableFuture<String> getRuntimeException() {
@ -89,7 +89,7 @@ public class SyncProxyTest {
throw new RuntimeException(); throw new RuntimeException();
} }
})); }), executorService);
} }
public ListenableFuture<String> getTypedException() throws FileNotFoundException { public ListenableFuture<String> getTypedException() throws FileNotFoundException {
@ -99,7 +99,7 @@ public class SyncProxyTest {
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
})); }), executorService);
} }
public String newString() { public String newString() {
@ -118,7 +118,7 @@ public class SyncProxyTest {
return "foo"; return "foo";
} }
})); }), executorService);
} }
public ListenableFuture<String> take100MillisecondsAndTimeout() { public ListenableFuture<String> take100MillisecondsAndTimeout() {
@ -133,7 +133,7 @@ public class SyncProxyTest {
return "foo"; return "foo";
} }
})); }), executorService);
} }
public ListenableFuture<String> take100MillisecondsAndOverride() { public ListenableFuture<String> take100MillisecondsAndOverride() {

View File

@ -53,7 +53,7 @@ public class AddTweetsControllerTest {
for (String name : new String[] { "1", "2" }) { for (String name : new String[] { "1", "2" }) {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getAsyncBlobStore().createContainer(container).get(); context.getAsyncBlobStore().createContainerInLocation(null, container).get();
Blob blob = context.getAsyncBlobStore().newBlob("1"); Blob blob = context.getAsyncBlobStore().newBlob("1");
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
blob.setPayload("I love beans!"); blob.setPayload("I love beans!");

View File

@ -60,7 +60,7 @@ public class StoreTweetsControllerTest {
.<String, BlobStoreContext<?, ?>> of("test1", new StubBlobStoreContextBuilder() .<String, BlobStoreContext<?, ?>> of("test1", new StubBlobStoreContextBuilder()
.buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext()); .buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext());
for (BlobStoreContext<?, ?> blobstore : contexts.values()) { for (BlobStoreContext<?, ?> blobstore : contexts.values()) {
blobstore.getAsyncBlobStore().createContainer("favo").get(); blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get();
} }
return contexts; return contexts;
} }

View File

@ -44,7 +44,7 @@ public class KeyToStoredTweetStatusTest {
BlobMap createMap() throws InterruptedException, ExecutionException { BlobMap createMap() throws InterruptedException, ExecutionException {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getBlobStore().createContainer("test1"); context.getBlobStore().createContainerInLocation(null, "test1");
return context.createBlobMap("test1"); return context.createBlobMap("test1");
} }

View File

@ -50,7 +50,7 @@ public class ServiceToStoredTweetStatusesTest {
for (String name : new String[] { "1", "2" }) { for (String name : new String[] { "1", "2" }) {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getAsyncBlobStore().createContainer(container).get(); context.getAsyncBlobStore().createContainerInLocation(null, container).get();
Blob blob = context.getAsyncBlobStore().newBlob("1"); Blob blob = context.getAsyncBlobStore().newBlob("1");
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
blob.setPayload("I love beans!"); blob.setPayload("I love beans!");

View File

@ -42,8 +42,6 @@ import org.jclouds.aws.s3.S3PropertiesBuilder;
import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder;
import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory;
import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; 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.blobstore.BlobStoreContext;
import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder;
import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder;
@ -58,8 +56,8 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
* Starts up the Google App Engine for Java Development environment and deploys * Starts up the Google App Engine for Java Development environment and deploys an application which
* an application which tests accesses twitter and blobstores. * tests accesses twitter and blobstores.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -73,64 +71,65 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
@Parameters( { "warfile", "devappserver.address", "devappserver.port" }) @Parameters( { "warfile", "devappserver.address", "devappserver.port" })
public void startDevAppServer(final String warfile, final String address, public void startDevAppServer(final String warfile, final String address, final String port)
final String port) throws Exception { throws Exception {
url = new URL(String.format("http://%s:%s", address, port)); url = new URL(String.format("http://%s:%s", address, port));
Properties props = new Properties(); Properties props = new Properties();
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System
checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); .getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS,
// WATCH THIS.. when adding a new context, you must update the string // WATCH THIS.. when adding a new context, you must update the string
String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), // String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(),
CloudFilesBlobStoreContextBuilder.class.getName(), // CloudFilesBlobStoreContextBuilder.class.getName(),
AzureBlobStoreContextBuilder.class.getName())); // AzureBlobStoreContextBuilder.class.getName()));
String.format("%s,%s", S3BlobStoreContextBuilder.class.getName(),
CloudFilesBlobStoreContextBuilder.class.getName()));
props = new TwitterPropertiesBuilder(props).withCredentials( props = new TwitterPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER),
System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)) System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build();
.build();
props = new S3PropertiesBuilder(props).withCredentials( props = new S3PropertiesBuilder(props)
checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), .withCredentials(
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)) checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID),
.build(); PROPERTY_AWS_ACCESSKEYID),
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY,
PROPERTY_AWS_SECRETACCESSKEY)).build();
props = new CloudFilesPropertiesBuilder(props).withCredentials( props = new CloudFilesPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)) System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build();
.build();
props = new AzureBlobPropertiesBuilder(props).withCredentials( props = new AzureBlobPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT),
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)) PROPERTY_AZURESTORAGE_ACCOUNT),
.build(); System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build();
server = new GoogleDevServer(); server = new GoogleDevServer();
server.writePropertiesAndStartServer(address, port, warfile, props); server.writePropertiesAndStartServer(address, port, warfile, props);
} }
@BeforeClass @BeforeClass
void clearAndCreateContainers() throws InterruptedException, void clearAndCreateContainers() throws InterruptedException, ExecutionException,
ExecutionException, TimeoutException { TimeoutException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext( BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext(checkNotNull(
checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY));
BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext( BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY));
BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext( // BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext(checkNotNull(
checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), // System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT),
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); // System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY));
//
this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); // this.contexts = ImmutableSet.of(s3Context, cfContext, azContext);
this.contexts = ImmutableSet.of(s3Context, cfContext);
boolean deleted = false; boolean deleted = false;
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
if (context.getBlobStore().containerExists(container)) { if (context.getBlobStore().containerExists(container)) {
System.err.printf("deleting container %s at %s%n", container, System.err.printf("deleting container %s at %s%n", container, context.getEndPoint());
context.getEndPoint());
context.getBlobStore().deleteContainer(container); context.getBlobStore().deleteContainer(container);
deleted = true; deleted = true;
} }
@ -140,9 +139,8 @@ public class TweetStoreLiveTest {
Thread.sleep(30000); Thread.sleep(30000);
} }
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
System.err.printf("creating container %s at %s%n", container, System.err.printf("creating container %s at %s%n", container, context.getEndPoint());
context.getEndPoint()); context.getBlobStore().createContainerInLocation(null, container);
context.getBlobStore().createContainer(container);
} }
if (deleted) { if (deleted) {
System.err.println("sleeping 5 seconds to allow containers to create"); System.err.println("sleeping 5 seconds to allow containers to create");
@ -166,10 +164,10 @@ public class TweetStoreLiveTest {
public void testPrimeContainers() throws IOException, InterruptedException { public void testPrimeContainers() throws IOException, InterruptedException {
URL gurl = new URL(url, "/store/do"); URL gurl = new URL(url, "/store/do");
for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { for (String context : new String[] { "S3", "CloudFiles" }) {
// for (String context : new String[] { "S3", "Azure", "CloudFiles" }) {
System.out.println("storing at context: " + context); System.out.println("storing at context: " + context);
HttpURLConnection connection = (HttpURLConnection) gurl HttpURLConnection connection = (HttpURLConnection) gurl.openConnection();
.openConnection();
connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); connection.addRequestProperty("X-AppEngine-QueueName", "twitter");
connection.addRequestProperty("context", context); connection.addRequestProperty("context", context);
InputStream i = connection.getInputStream(); InputStream i = connection.getInputStream();

View File

@ -53,7 +53,7 @@ public class AddTweetsControllerTest {
for (String name : new String[] { "1", "2" }) { for (String name : new String[] { "1", "2" }) {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getAsyncBlobStore().createContainer(container).get(); context.getAsyncBlobStore().createContainerInLocation(null, container).get();
Blob blob = context.getAsyncBlobStore().newBlob("1"); Blob blob = context.getAsyncBlobStore().newBlob("1");
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
blob.setPayload("I love beans!"); blob.setPayload("I love beans!");

View File

@ -60,7 +60,7 @@ public class StoreTweetsControllerTest {
.<String, BlobStoreContext<?, ?>> of("test1", new StubBlobStoreContextBuilder() .<String, BlobStoreContext<?, ?>> of("test1", new StubBlobStoreContextBuilder()
.buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext()); .buildContext(), "test2", new StubBlobStoreContextBuilder().buildContext());
for (BlobStoreContext<?, ?> blobstore : contexts.values()) { for (BlobStoreContext<?, ?> blobstore : contexts.values()) {
blobstore.getAsyncBlobStore().createContainer("favo").get(); blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get();
} }
return contexts; return contexts;
} }

View File

@ -44,7 +44,7 @@ public class KeyToStoredTweetStatusTest {
BlobMap createMap() throws InterruptedException, ExecutionException { BlobMap createMap() throws InterruptedException, ExecutionException {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getBlobStore().createContainer("test1"); context.getBlobStore().createContainerInLocation(null, "test1");
return context.createBlobMap("test1"); return context.createBlobMap("test1");
} }

View File

@ -50,7 +50,7 @@ public class ServiceToStoredTweetStatusesTest {
for (String name : new String[] { "1", "2" }) { for (String name : new String[] { "1", "2" }) {
BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder() BlobStoreContext<AsyncBlobStore, BlobStore> context = new StubBlobStoreContextBuilder()
.buildContext(); .buildContext();
context.getAsyncBlobStore().createContainer(container).get(); context.getAsyncBlobStore().createContainerInLocation(null, container).get();
Blob blob = context.getAsyncBlobStore().newBlob("1"); Blob blob = context.getAsyncBlobStore().newBlob("1");
blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank");
blob.setPayload("I love beans!"); blob.setPayload("I love beans!");

View File

@ -42,8 +42,6 @@ import org.jclouds.aws.s3.S3PropertiesBuilder;
import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder;
import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory;
import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; 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.blobstore.BlobStoreContext;
import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder;
import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder;
@ -58,8 +56,8 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
* Starts up the Google App Engine for Java Development environment and deploys * Starts up the Google App Engine for Java Development environment and deploys an application which
* an application which tests accesses twitter and blobstores. * tests accesses twitter and blobstores.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -73,64 +71,69 @@ public class TweetStoreLiveTest {
@BeforeTest @BeforeTest
@Parameters( { "warfile", "devappserver.address", "devappserver.port" }) @Parameters( { "warfile", "devappserver.address", "devappserver.port" })
public void startDevAppServer(final String warfile, final String address, public void startDevAppServer(final String warfile, final String address, final String port)
final String port) throws Exception { throws Exception {
url = new URL(String.format("http://%s:%s", address, port)); url = new URL(String.format("http://%s:%s", address, port));
Properties props = new Properties(); Properties props = new Properties();
props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, checkNotNull(System
checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); .getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER));
props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS, props.setProperty(PROPERTY_BLOBSTORE_CONTEXTBUILDERS,
// WATCH THIS.. when adding a new context, you must update the string // WATCH THIS.. when adding a new context, you must update the string
String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(), // String.format("%s,%s,%s", S3BlobStoreContextBuilder.class.getName(),
CloudFilesBlobStoreContextBuilder.class.getName(), // CloudFilesBlobStoreContextBuilder.class.getName(),
AzureBlobStoreContextBuilder.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( props = new TwitterPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER), checkNotNull(System.getProperty(PROPERTY_TWITTER_USER), PROPERTY_TWITTER_USER),
System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)) System.getProperty(PROPERTY_TWITTER_PASSWORD, PROPERTY_TWITTER_PASSWORD)).build();
.build();
props = new S3PropertiesBuilder(props).withCredentials( props = new S3PropertiesBuilder(props)
checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), .withCredentials(
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)) checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID),
.build(); PROPERTY_AWS_ACCESSKEYID),
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY,
PROPERTY_AWS_SECRETACCESSKEY)).build();
props = new CloudFilesPropertiesBuilder(props).withCredentials( props = new CloudFilesPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)) System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)).build();
.build();
props = new AzureBlobPropertiesBuilder(props).withCredentials( props = new AzureBlobPropertiesBuilder(props).withCredentials(
checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT),
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)) PROPERTY_AZURESTORAGE_ACCOUNT),
.build(); System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)).build();
server = new GoogleDevServer(); server = new GoogleDevServer();
server.writePropertiesAndStartServer(address, port, warfile, props); server.writePropertiesAndStartServer(address, port, warfile, props);
} }
@BeforeClass @BeforeClass
void clearAndCreateContainers() throws InterruptedException, void clearAndCreateContainers() throws InterruptedException, ExecutionException,
ExecutionException, TimeoutException { TimeoutException {
container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER));
BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext( BlobStoreContext<?, ?> s3Context = S3BlobStoreContextFactory.createContext(checkNotNull(
checkNotNull(System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System.getProperty(PROPERTY_AWS_ACCESSKEYID), PROPERTY_AWS_ACCESSKEYID), System
System.getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY)); .getProperty(PROPERTY_AWS_SECRETACCESSKEY, PROPERTY_AWS_SECRETACCESSKEY));
BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext( BlobStoreContext<?, ?> cfContext = CloudFilesBlobStoreContextFactory.createContext(
checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER), checkNotNull(System.getProperty(PROPERTY_RACKSPACE_USER), PROPERTY_RACKSPACE_USER),
System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY)); System.getProperty(PROPERTY_RACKSPACE_KEY, PROPERTY_RACKSPACE_KEY));
BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext( // BlobStoreContext<?, ?> azContext = AzureBlobStoreContextFactory.createContext(checkNotNull(
checkNotNull(System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT), // System.getProperty(PROPERTY_AZURESTORAGE_ACCOUNT), PROPERTY_AZURESTORAGE_ACCOUNT),
System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY)); // System.getProperty(PROPERTY_AZURESTORAGE_KEY, PROPERTY_AZURESTORAGE_KEY));
//
this.contexts = ImmutableSet.of(s3Context, cfContext, azContext); // this.contexts = ImmutableSet.of(s3Context, cfContext, azContext);
this.contexts = ImmutableSet.of(s3Context, cfContext);
boolean deleted = false; boolean deleted = false;
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
if (context.getBlobStore().containerExists(container)) { if (context.getBlobStore().containerExists(container)) {
System.err.printf("deleting container %s at %s%n", container, System.err.printf("deleting container %s at %s%n", container, context.getEndPoint());
context.getEndPoint());
context.getBlobStore().deleteContainer(container); context.getBlobStore().deleteContainer(container);
deleted = true; deleted = true;
} }
@ -140,9 +143,8 @@ public class TweetStoreLiveTest {
Thread.sleep(30000); Thread.sleep(30000);
} }
for (BlobStoreContext<?, ?> context : contexts) { for (BlobStoreContext<?, ?> context : contexts) {
System.err.printf("creating container %s at %s%n", container, System.err.printf("creating container %s at %s%n", container, context.getEndPoint());
context.getEndPoint()); context.getBlobStore().createContainerInLocation(null, container);
context.getBlobStore().createContainer(container);
} }
if (deleted) { if (deleted) {
System.err.println("sleeping 5 seconds to allow containers to create"); System.err.println("sleeping 5 seconds to allow containers to create");
@ -166,10 +168,10 @@ public class TweetStoreLiveTest {
public void testPrimeContainers() throws IOException, InterruptedException { public void testPrimeContainers() throws IOException, InterruptedException {
URL gurl = new URL(url, "/store/do"); URL gurl = new URL(url, "/store/do");
for (String context : new String[] { "S3", "Azure", "CloudFiles" }) { for (String context : new String[] { "S3", "CloudFiles" }) {
// for (String context : new String[] { "S3", "Azure", "CloudFiles" }) {
System.out.println("storing at context: " + context); System.out.println("storing at context: " + context);
HttpURLConnection connection = (HttpURLConnection) gurl HttpURLConnection connection = (HttpURLConnection) gurl.openConnection();
.openConnection();
connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); connection.addRequestProperty("X-AppEngine-QueueName", "twitter");
connection.addRequestProperty("context", context); connection.addRequestProperty("context", context);
InputStream i = connection.getInputStream(); InputStream i = connection.getInputStream();

View File

@ -19,7 +19,7 @@
package org.jclouds.http.pool; package org.jclouds.http.pool;
import static com.google.common.base.Preconditions.checkArgument; 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.net.URI;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
@ -148,10 +148,10 @@ public class ConnectionPoolTransformingHttpCommandExecutorService<C> extends Bas
transformerLogger.debug("Processed intermediate result for: %s", o); transformerLogger.debug("Processed intermediate result for: %s", o);
return result; return result;
} }
})); }), executorService);
HttpCommandRendezvous<T> rendezvous = new HttpCommandRendezvous<T>(command, channel, HttpCommandRendezvous<T> rendezvous = new HttpCommandRendezvous<T>(command, channel,
makeListenable(future)); makeListenable(future, executorService));
commandQueue.add(rendezvous); commandQueue.add(rendezvous);
return rendezvous.getListenableFuture(); return rendezvous.getListenableFuture();
} }

View File

@ -19,7 +19,7 @@
package org.jclouds.rackspace.cloudfiles.blobstore; package org.jclouds.rackspace.cloudfiles.blobstore;
import static com.google.common.util.concurrent.Futures.compose; 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 static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
import java.util.SortedSet; import java.util.SortedSet;
@ -108,7 +108,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements
return null; return null;
} }
})); }), service);
} }
/** /**
@ -128,7 +128,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> containerExists(String container) { public ListenableFuture<Boolean> containerExists(String container) {
@ -179,7 +179,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements
return null; return null;
} }
})); }), service);
} }
public ListenableFuture<Boolean> directoryExists(final String container, final String directory) { public ListenableFuture<Boolean> directoryExists(final String container, final String directory) {
@ -193,7 +193,7 @@ public class CloudFilesAsyncBlobStore extends BaseCloudFilesBlobStore implements
} }
} }
})); }), service);
} }
} }

View File

@ -129,7 +129,7 @@ public class VCloudClientLiveTest {
assertNotNull(response.getId()); assertNotNull(response.getId());
assertNotNull(response.getLocation()); assertNotNull(response.getLocation());
assertNotNull(response.getTasks()); assertNotNull(response.getTasks());
assertEquals(connection.getTasksList(response.getId()), response.getId()); assertEquals(connection.getTasksList(response.getId()).getId(), response.getId());
} }
@Test @Test