JCLOUDS-457: BlobStore Skeleton

The Amazon Glacier BlobStore skeleton has been added.
This commit is contained in:
Roman Coedo 2014-07-13 12:22:50 +02:00 committed by Andrew Gaul
parent 121d2c13ae
commit 71782b1fd2
4 changed files with 277 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import java.net.URI;
import java.util.Properties;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.glacier.blobstore.config.GlacierBlobStoreContextModule;
import org.jclouds.glacier.config.GlacierParserModule;
import org.jclouds.glacier.config.GlacierRestClientModule;
import org.jclouds.glacier.reference.GlacierHeaders;
@ -81,7 +82,8 @@ public class GlacierApiMetadata extends BaseRestApiMetadata {
.defaultProperties(GlacierApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.view(typeToken(BlobStoreContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>> of(GlacierRestClientModule.class, GlacierParserModule.class));
.defaultModules(ImmutableSet.<Class<? extends Module>> of(GlacierRestClientModule.class,
GlacierParserModule.class, GlacierBlobStoreContextModule.class));
}
@Override

View File

@ -0,0 +1,125 @@
/*
* 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.glacier.blobstore;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import org.jclouds.Constants;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
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.blobstore.util.BlobUtils;
import org.jclouds.collect.Memoized;
import org.jclouds.crypto.Crypto;
import org.jclouds.domain.Location;
import org.jclouds.glacier.GlacierAsyncClient;
import org.jclouds.glacier.GlacierClient;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.inject.Inject;
import com.google.inject.name.Named;
public class GlacierAsyncBlobStore extends BaseAsyncBlobStore {
private final GlacierAsyncClient async;
private final GlacierClient sync;
private final Crypto crypto;
@Inject
GlacierAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
@Memoized Supplier<Set<? extends Location>> locations, GlacierAsyncClient async, Crypto crypto,
GlacierClient sync) {
super(context, blobUtils, userExecutor, defaultLocation, locations);
this.sync = checkNotNull(sync, "sync");
this.async = checkNotNull(async, "async");
this.crypto = checkNotNull(crypto, "crypto");
}
@Override
protected boolean deleteAndVerifyContainerGone(String container) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<PageSet<? extends StorageMetadata>> list() {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Boolean> containerExists(String container) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Boolean> createContainerInLocation(@Nullable Location location, String container) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Boolean> createContainerInLocation(@Nullable Location location, String container,
CreateContainerOptions options) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<PageSet<? extends StorageMetadata>> list(String container,
ListContainerOptions listContainerOptions) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Boolean> blobExists(String container, String key) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<String> putBlob(String container, Blob blob) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<String> putBlob(String container, Blob blob, PutOptions options) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Blob> getBlob(String container, String key, GetOptions getOptions) {
throw new UnsupportedOperationException();
}
@Override
public ListenableFuture<Void> removeBlob(String container, String key) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,115 @@
/*
* 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.glacier.blobstore;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.internal.BaseBlobStore;
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.blobstore.util.BlobUtils;
import org.jclouds.collect.Memoized;
import org.jclouds.crypto.Crypto;
import org.jclouds.domain.Location;
import org.jclouds.glacier.GlacierClient;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Supplier;
import com.google.inject.Inject;
public class GlacierBlobStore extends BaseBlobStore {
private final GlacierClient sync;
private final Crypto crypto;
@Inject
GlacierBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations, GlacierClient sync, Crypto crypto) {
super(context, blobUtils, defaultLocation, locations);
this.sync = checkNotNull(sync, "sync");
this.crypto = checkNotNull(crypto, "crypto");
}
@Override
protected boolean deleteAndVerifyContainerGone(String container) {
return sync.deleteVault(container);
}
@Override
public PageSet<? extends StorageMetadata> list() {
throw new UnsupportedOperationException();
}
@Override
public boolean containerExists(String container) {
return sync.describeVault(container) != null;
}
@Override
public boolean createContainerInLocation(@Nullable Location location, String container) {
return sync.createVault(container) != null;
}
@Override
public boolean createContainerInLocation(@Nullable Location location, String container,
CreateContainerOptions options) {
return createContainerInLocation(location, container);
}
@Override
public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions listContainerOptions) {
throw new UnsupportedOperationException();
}
@Override
public boolean blobExists(String container, String key) {
throw new UnsupportedOperationException();
}
@Override
public String putBlob(String container, Blob blob) {
return sync.uploadArchive(container, blob.getPayload(), blob.getMetadata().getName());
}
@Override
public String putBlob(String container, Blob blob, PutOptions options) {
throw new UnsupportedOperationException();
}
@Override
public BlobMetadata blobMetadata(String container, String key) {
throw new UnsupportedOperationException();
}
@Override
public Blob getBlob(String container, String key, GetOptions getOptions) {
throw new UnsupportedOperationException();
}
@Override
public void removeBlob(String container, String key) {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,34 @@
/*
* 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.glacier.blobstore.config;
import org.jclouds.blobstore.AsyncBlobStore;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.attr.ConsistencyModel;
import org.jclouds.glacier.blobstore.GlacierAsyncBlobStore;
import org.jclouds.glacier.blobstore.GlacierBlobStore;
import com.google.inject.AbstractModule;
public class GlacierBlobStoreContextModule extends AbstractModule {
@Override
protected void configure() {
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
bind(BlobStore.class).to(GlacierBlobStore.class);
bind(AsyncBlobStore.class).to(GlacierAsyncBlobStore.class);
}
}