JCLOUDS-40 Remove AsyncBlobStore

This commit is contained in:
Adrian Cole 2014-10-05 11:40:48 -07:00
parent 1bdf8a1588
commit 8e50fbd7a4
7 changed files with 20 additions and 525 deletions

View File

@ -44,7 +44,7 @@ See http://code.google.com/p/jclouds for details."
java.util.Properties
[org.jclouds ContextBuilder]
[org.jclouds.blobstore
AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext
domain.BlobBuilder BlobStore BlobStoreContext
domain.BlobMetadata domain.StorageMetadata domain.PageSet
domain.Blob domain.internal.BlobBuilderImpl options.PutOptions
options.PutOptions$Builder
@ -86,8 +86,6 @@ See http://code.google.com/p/jclouds for details."
(defn blobstore
"Create a logged in context.
Options for communication style
:sync and :async.
Options can also be specified for extension modules
:log4j :enterprise :ning :apachehc :bouncycastle :joda :gae"
[^String provider ^String provider-identity ^String provider-credential
@ -102,9 +100,7 @@ Options can also be specified for extension modules
(overrides (reduce #(do (.put ^Properties %1 (name (first %2)) (second %2)) %1)
(Properties.) (dissoc opts :extensions)))
(buildView BlobStoreContext))]
(if (some #(= :async %) options)
(.getAsyncBlobStore context)
(.getBlobStore context)))))
(.getBlobStore context))))
(defn blobstore-context
"Returns a blobstore context from a blobstore."
@ -117,8 +113,7 @@ Options can also be specified for extension modules
(defn blobstore?
[object]
(or (instance? BlobStore object)
(instance? AsyncBlobStore object)))
(instance? BlobStore object))
(defn blobstore-context?
[object]

View File

@ -1,173 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.blobstore;
import java.util.Set;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobBuilder;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.internal.SubmissionAsyncBlobStore;
import org.jclouds.blobstore.options.CreateContainerOptions;
import org.jclouds.blobstore.options.GetOptions;
import org.jclouds.blobstore.options.ListContainerOptions;
import org.jclouds.blobstore.options.PutOptions;
import org.jclouds.domain.Location;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.ImplementedBy;
/**
* Provides hooks needed to run a blob store asynchronously
*
* @see BlobStore
* @deprecated will be removed in jclouds 1.7, as async interfaces are no longer
* supported. Please use {@link org.jclouds.blobstore.BlobStore}
*/
@Deprecated
@ImplementedBy(SubmissionAsyncBlobStore.class)
public interface AsyncBlobStore {
/**
* @see BlobStore#getContext
*/
BlobStoreContext getContext();
/**
* @see BlobStore#blobBuilder
*/
BlobBuilder blobBuilder(String name);
/**
* @see BlobStore#listAssignableLocations
*/
ListenableFuture<Set<? extends Location>> listAssignableLocations();
/**
* @see BlobStore#list
*/
ListenableFuture<PageSet<? extends StorageMetadata>> list();
/**
* @see BlobStore#containerExists
*/
ListenableFuture<Boolean> containerExists(String container);
/**
* @see BlobStore#createContainerInLocation(Location, String)
*/
ListenableFuture<Boolean> createContainerInLocation(@Nullable Location location, String container);
/**
* @see BlobStore#createContainerInLocation(Location,String,CreateContainerOptions)
*/
ListenableFuture<Boolean> createContainerInLocation(@Nullable Location location, String container,
CreateContainerOptions options);
/**
* @see BlobStore#list(String)
*/
ListenableFuture<PageSet<? extends StorageMetadata>> list(String container);
/**
* @see BlobStore#list(String, ListContainerOptions)
*/
ListenableFuture<PageSet<? extends StorageMetadata>> list(String container, ListContainerOptions options);
/**
* @see BlobStore#clearContainer(String)
*/
ListenableFuture<Void> clearContainer(String container);
/**
* @see BlobStore#clearContainer(String, ListContainerOptions)
*/
ListenableFuture<Void> clearContainer(String container, ListContainerOptions options);
/**
* @see BlobStore#deleteContainer
*/
ListenableFuture<Void> deleteContainer(String container);
/**
* @see BlobStore#deleteContainerIfEmpty
*/
ListenableFuture<Boolean> deleteContainerIfEmpty(String container);
/**
* @see BlobStore#directoryExists
*/
ListenableFuture<Boolean> directoryExists(String container, String directory);
/**
* @see BlobStore#createDirectory
*/
ListenableFuture<Void> createDirectory(String container, String directory);
/**
* @see BlobStore#deleteDirectory
*/
ListenableFuture<Void> deleteDirectory(String containerName, String name);
/**
* @see BlobStore#blobExists
*/
ListenableFuture<Boolean> blobExists(String container, String name);
/**
* @see BlobStore#putBlob(String,Blob)
*/
ListenableFuture<String> putBlob(String container, Blob blob);
/**
* @see BlobStore#putBlob(String,Blob,PutOptions)
*/
ListenableFuture<String> putBlob(String container, Blob blob, PutOptions options);
/**
* @see BlobStore#blobMetadata
*/
ListenableFuture<BlobMetadata> blobMetadata(String container, String key);
/**
* @see BlobStore#getBlob(String, String)
*/
ListenableFuture<Blob> getBlob(String container, String key);
/**
* @see BlobStore#getBlob(String, String, GetOptions)
*/
ListenableFuture<Blob> getBlob(String container, String key, GetOptions options);
/**
* @see BlobStore#removeBlob
*/
ListenableFuture<Void> removeBlob(String container, String key);
/**
* @see BlobStore#countBlobs(String)
*/
ListenableFuture<Long> countBlobs(String container);
/**
* @see BlobStore#countBlobs(String,ListContainerOptions)
*/
ListenableFuture<Long> countBlobs(String container, ListContainerOptions options);
}

View File

@ -32,10 +32,6 @@ import org.jclouds.javax.annotation.Nullable;
/**
* Synchronous access to a BlobStore such as Amazon S3
*
* @see AsyncBlobStore
*
* @see BlobStoreContextFactory
*/
public interface BlobStore {
/**

View File

@ -38,16 +38,6 @@ public interface BlobStoreContext extends Closeable, View {
*/
BlobRequestSigner getSigner();
/**
* @return a portable asynchronous interface for the BlobStore, which returns
* {@code Future}s for each call.
* @deprecated will be removed in jclouds 1.7, as async interfaces are no
* longer supported. Please use
* {@link #getBlobStore()}
*/
@Deprecated
AsyncBlobStore getAsyncBlobStore();
/**
* @return a portable interface for the BlobStore.
*/

View File

@ -22,7 +22,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.Context;
import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
@ -36,7 +35,6 @@ import com.google.common.reflect.TypeToken;
@Singleton
public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
private final AsyncBlobStore ablobStore;
private final BlobStore blobStore;
private final ConsistencyModel consistencyModel;
private final Utils utils;
@ -44,12 +42,9 @@ public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
@Inject
public BlobStoreContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
Utils utils, ConsistencyModel consistencyModel,
AsyncBlobStore ablobStore, BlobStore blobStore,
BlobRequestSigner blobRequestSigner) {
Utils utils, ConsistencyModel consistencyModel, BlobStore blobStore, BlobRequestSigner blobRequestSigner) {
super(backend, backendType);
this.consistencyModel = checkNotNull(consistencyModel, "consistencyModel");
this.ablobStore = checkNotNull(ablobStore, "ablobStore");
this.blobStore = checkNotNull(blobStore, "blobStore");
this.utils = checkNotNull(utils, "utils");
this.blobRequestSigner = checkNotNull(blobRequestSigner, "blobRequestSigner");
@ -65,11 +60,6 @@ public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
return blobStore;
}
@Override
public AsyncBlobStore getAsyncBlobStore() {
return ablobStore;
}
@Override
public Utils utils() {
return utils;

View File

@ -1,293 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.blobstore.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.Constants.PROPERTY_USER_THREADS;
import java.util.Set;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobBuilder;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.options.CreateContainerOptions;
import org.jclouds.blobstore.options.GetOptions;
import org.jclouds.blobstore.options.ListContainerOptions;
import org.jclouds.blobstore.options.PutOptions;
import org.jclouds.domain.Location;
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
/**
* Adapter that allows you to reuse an existing {@link BlobStore} to implement
* the deprecated {@link AsyncBlobStore} interface.
*
* @deprecated will be removed in jclouds 2.0, as async interfaces are no longer
* supported. Please use {@link BlobStore}
*/
@Deprecated
public class SubmissionAsyncBlobStore extends ForwardingObject implements AsyncBlobStore {
private final BlobStore blobstore;
private final ListeningExecutorService executor;
@Inject
public SubmissionAsyncBlobStore(BlobStore blobstore, @Named(PROPERTY_USER_THREADS) ListeningExecutorService executor) {
this.blobstore = checkNotNull(blobstore, "blobstore");
this.executor = checkNotNull(executor, "executor");
}
@Override
protected BlobStore delegate() {
return blobstore;
}
@Override
public BlobStoreContext getContext() {
return delegate().getContext();
}
@Override
public BlobBuilder blobBuilder(String name) {
return delegate().blobBuilder(name);
}
@Override
public ListenableFuture<Set<? extends Location>> listAssignableLocations() {
return executor.submit(new Callable<Set<? extends Location>>() {
public Set<? extends Location> call() {
return delegate().listAssignableLocations();
}
});
}
@Override
public ListenableFuture<PageSet<? extends StorageMetadata>> list() {
return executor.submit(new Callable<PageSet<? extends StorageMetadata>>() {
public PageSet<? extends StorageMetadata> call() {
return delegate().list();
}
});
}
@Override
public ListenableFuture<Boolean> containerExists(final String container) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().containerExists(container);
}
});
}
@Override
public ListenableFuture<Boolean> createContainerInLocation(final Location location, final String container) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().createContainerInLocation(location, container);
}
});
}
@Override
public ListenableFuture<Boolean> createContainerInLocation(final Location location, final String container,
final CreateContainerOptions options) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().createContainerInLocation(location, container, options);
}
});
}
@Override
public ListenableFuture<PageSet<? extends StorageMetadata>> list(final String container) {
return executor.submit(new Callable<PageSet<? extends StorageMetadata>>() {
public PageSet<? extends StorageMetadata> call() {
return delegate().list(container);
}
});
}
@Override
public ListenableFuture<PageSet<? extends StorageMetadata>> list(final String container,
final ListContainerOptions options) {
return executor.submit(new Callable<PageSet<? extends StorageMetadata>>() {
public PageSet<? extends StorageMetadata> call() {
return delegate().list(container, options);
}
});
}
@Override
public ListenableFuture<Void> clearContainer(final String container) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().clearContainer(container);
return null;
}
});
}
@Override
public ListenableFuture<Void> clearContainer(final String container, final ListContainerOptions options) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().clearContainer(container, options);
return null;
}
});
}
@Override
public ListenableFuture<Void> deleteContainer(final String container) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().deleteContainer(container);
return null;
}
});
}
@Override
public ListenableFuture<Boolean> deleteContainerIfEmpty(final String container) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().deleteContainerIfEmpty(container);
}
});
}
@Override
public ListenableFuture<Boolean> directoryExists(final String container, final String directory) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().directoryExists(container, directory);
}
});
}
@Override
public ListenableFuture<Void> createDirectory(final String container, final String directory) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().createDirectory(container, directory);
return null;
}
});
}
@Override
public ListenableFuture<Void> deleteDirectory(final String containerName, final String name) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().deleteDirectory(containerName, name);
return null;
}
});
}
@Override
public ListenableFuture<Boolean> blobExists(final String container, final String name) {
return executor.submit(new Callable<Boolean>() {
public Boolean call() {
return delegate().blobExists(container, name);
}
});
}
@Override
public ListenableFuture<String> putBlob(final String container, final Blob blob) {
return executor.submit(new Callable<String>() {
public String call() {
return delegate().putBlob(container, blob);
}
});
}
@Override
public ListenableFuture<String> putBlob(final String container, final Blob blob, final PutOptions options) {
return executor.submit(new Callable<String>() {
public String call() {
return delegate().putBlob(container, blob, options);
}
});
}
@Override
public ListenableFuture<BlobMetadata> blobMetadata(final String container, final String key) {
return executor.submit(new Callable<BlobMetadata>() {
public BlobMetadata call() {
return delegate().blobMetadata(container, key);
}
});
}
@Override
public ListenableFuture<Blob> getBlob(final String container, final String key) {
return executor.submit(new Callable<Blob>() {
public Blob call() {
return delegate().getBlob(container, key);
}
});
}
@Override
public ListenableFuture<Blob> getBlob(final String container, final String key, final GetOptions options) {
return executor.submit(new Callable<Blob>() {
public Blob call() {
return delegate().getBlob(container, key, options);
}
});
}
@Override
public ListenableFuture<Void> removeBlob(final String container, final String key) {
return executor.submit(new Callable<Void>() {
public Void call() {
delegate().removeBlob(container, key);
return null;
}
});
}
@Override
public ListenableFuture<Long> countBlobs(final String container) {
return executor.submit(new Callable<Long>() {
public Long call() {
return delegate().countBlobs(container);
}
});
}
@Override
public ListenableFuture<Long> countBlobs(final String container, final ListContainerOptions options) {
return executor.submit(new Callable<Long>() {
public Long call() {
return delegate().countBlobs(container, options);
}
});
}
}

View File

@ -24,6 +24,7 @@ import static org.jclouds.blobstore.options.GetOptions.Builder.ifModifiedSince;
import static org.jclouds.blobstore.options.GetOptions.Builder.ifUnmodifiedSince;
import static org.jclouds.blobstore.options.GetOptions.Builder.range;
import static org.jclouds.concurrent.FutureIterables.awaitCompletion;
import static org.jclouds.io.ByteStreams2.hashAndClose;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
@ -55,7 +56,6 @@ import org.jclouds.blobstore.domain.StorageType;
import org.jclouds.crypto.Crypto;
import org.jclouds.encryption.internal.JCECrypto;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.ByteStreams2;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.io.payloads.ByteSourcePayload;
@ -67,7 +67,6 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
@ -76,7 +75,6 @@ import com.google.common.collect.Maps;
import com.google.common.hash.HashCode;
import com.google.common.io.ByteSource;
import com.google.common.io.Files;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.Uninterruptibles;
@ -93,10 +91,6 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
return oneHundredOneConstitutions;
}
public static long getOneHundredOneConstitutionsLength() throws IOException {
return oneHundredOneConstitutions.size();
}
/**
* Attempt to capture the issue detailed in
* http://groups.google.com/group/jclouds/browse_thread/thread/4a7c8d58530b287f
@ -108,7 +102,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
createTestInput(32 * 1024).copyTo(Files.asByteSink(payloadFile));
final Payload testPayload = Payloads.newFilePayload(payloadFile);
final HashCode md5 = ByteStreams2.hashAndClose(testPayload.openStream(), md5());
final HashCode md5 = hashAndClose(testPayload.openStream(), md5());
testPayload.getContentMetadata().setContentType("image/png");
final AtomicInteger blobCount = new AtomicInteger();
@ -127,7 +121,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
assertConsistencyAwareBlobExists(container, name);
blob = view.getBlobStore().getBlob(container, name);
assertEquals(ByteStreams2.hashAndClose(blob.getPayload().openStream(), md5()), md5,
assertEquals(hashAndClose(blob.getPayload().openStream(), md5()), md5,
String.format("md5 didn't match on %s/%s", container, name));
view.getBlobStore().removeBlob(container, name);
@ -158,23 +152,19 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
uploadByteSource(container, name, expectedContentDisposition, supplier);
Map<Integer, ListenableFuture<?>> responses = Maps.newHashMap();
for (int i = 0; i < 10; i++) {
responses.put(i, Futures.transform(view.getAsyncBlobStore().getBlob(container, name),
new Function<Blob, Void>() {
@Override
public Void apply(Blob from) {
try {
validateMetadata(from.getMetadata(), container, name);
assertEquals(ByteStreams2.hashAndClose(from.getPayload().openStream(), md5()), supplier.hash(md5()));
checkContentDisposition(from, expectedContentDisposition);
} catch (IOException e) {
Throwables.propagate(e);
}
return null;
}
}, this.exec));
responses.put(i, this.exec.submit(new Callable<Void>() {
@Override public Void call() throws Exception {
try {
Blob blob = view.getBlobStore().getBlob(container, name);
validateMetadata(blob.getMetadata(), container, name);
assertEquals(hashAndClose(blob.getPayload().openStream(), md5()), supplier.hash(md5()));
checkContentDisposition(blob, expectedContentDisposition);
} catch (IOException e) {
Throwables.propagate(e);
}
return null;
}
}));
}
Map<Integer, Exception> exceptions = awaitCompletion(responses, exec, 30000l, Logger.CONSOLE,
"get constitution");