EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.azureblob.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [AzureAsyncBlobStore.java]

nameclass, %method, %block, %line, %
AzureAsyncBlobStore.java33%  (1/3)5%   (1/20)23%  (56/239)29%  (10/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AzureAsyncBlobStore$10%   (0/1)0%   (0/2)0%   (0/17)0%   (0/2)
AzureAsyncBlobStore$1 (AzureAsyncBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (BoundedSet): PageSet 0%   (0/1)0%   (0/11)0%   (0/1)
     
class AzureAsyncBlobStore$20%   (0/1)0%   (0/2)0%   (0/12)0%   (0/2)
AzureAsyncBlobStore$2 (AzureAsyncBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (BlobProperties): BlobMetadata 0%   (0/1)0%   (0/6)0%   (0/1)
     
class AzureAsyncBlobStore100% (1/1)6%   (1/16)27%  (56/210)32%  (10/31)
access$000 (AzureAsyncBlobStore): ContainerToResourceMetadata 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (AzureAsyncBlobStore): BlobPropertiesToBlobMetadata 0%   (0/1)0%   (0/3)0%   (0/1)
blobExists (String, String): ListenableFuture 0%   (0/1)0%   (0/6)0%   (0/1)
blobMetadata (String, String): ListenableFuture 0%   (0/1)0%   (0/13)0%   (0/1)
containerExists (String): ListenableFuture 0%   (0/1)0%   (0/5)0%   (0/1)
createContainerInLocation (Location, String): ListenableFuture 0%   (0/1)0%   (0/7)0%   (0/1)
createContainerInLocation (Location, String, CreateContainerOptions): Listena... 0%   (0/1)0%   (0/22)0%   (0/4)
deleteAndVerifyContainerGone (String): boolean 0%   (0/1)0%   (0/5)0%   (0/1)
deleteContainer (String): ListenableFuture 0%   (0/1)0%   (0/5)0%   (0/1)
getBlob (String, String, GetOptions): ListenableFuture 0%   (0/1)0%   (0/24)0%   (0/3)
list (): ListenableFuture 0%   (0/1)0%   (0/17)0%   (0/1)
list (String, ListContainerOptions): ListenableFuture 0%   (0/1)0%   (0/24)0%   (0/3)
putBlob (String, Blob): ListenableFuture 0%   (0/1)0%   (0/9)0%   (0/1)
putBlob (String, Blob, PutOptions): ListenableFuture 0%   (0/1)0%   (0/5)0%   (0/1)
removeBlob (String, String): ListenableFuture 0%   (0/1)0%   (0/6)0%   (0/1)
AzureAsyncBlobStore (BlobStoreContext, BlobUtils, ExecutorService, Supplier, ... 100% (1/1)100% (56/56)100% (10/10)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.azureblob.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.azure.storage.options.ListOptions.Builder.includeMetadata;
23 
24import java.util.Set;
25import java.util.concurrent.ExecutorService;
26 
27import javax.inject.Inject;
28import javax.inject.Named;
29import javax.inject.Singleton;
30 
31import org.jclouds.Constants;
32import org.jclouds.azure.storage.domain.BoundedSet;
33import org.jclouds.azureblob.AzureBlobAsyncClient;
34import org.jclouds.azureblob.blobstore.functions.AzureBlobToBlob;
35import org.jclouds.azureblob.blobstore.functions.BlobPropertiesToBlobMetadata;
36import org.jclouds.azureblob.blobstore.functions.BlobToAzureBlob;
37import org.jclouds.azureblob.blobstore.functions.ContainerToResourceMetadata;
38import org.jclouds.azureblob.blobstore.functions.ListBlobsResponseToResourceList;
39import org.jclouds.azureblob.blobstore.functions.ListOptionsToListBlobsOptions;
40import org.jclouds.azureblob.domain.AzureBlob;
41import org.jclouds.azureblob.domain.BlobProperties;
42import org.jclouds.azureblob.domain.ContainerProperties;
43import org.jclouds.azureblob.domain.ListBlobsResponse;
44import org.jclouds.azureblob.domain.PublicAccess;
45import org.jclouds.azureblob.options.ListBlobsOptions;
46import org.jclouds.blobstore.BlobStoreContext;
47import org.jclouds.blobstore.domain.Blob;
48import org.jclouds.blobstore.domain.BlobMetadata;
49import org.jclouds.blobstore.domain.PageSet;
50import org.jclouds.blobstore.domain.StorageMetadata;
51import org.jclouds.blobstore.domain.internal.PageSetImpl;
52import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
53import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
54import org.jclouds.blobstore.options.CreateContainerOptions;
55import org.jclouds.blobstore.options.ListContainerOptions;
56import org.jclouds.blobstore.options.PutOptions;
57import org.jclouds.blobstore.util.BlobUtils;
58import org.jclouds.collect.Memoized;
59import org.jclouds.concurrent.Futures;
60import org.jclouds.domain.Location;
61import org.jclouds.http.options.GetOptions;
62 
63import com.google.common.base.Function;
64import com.google.common.base.Supplier;
65import com.google.common.collect.Iterables;
66import com.google.common.util.concurrent.ListenableFuture;
67 
68/**
69 * @author Adrian Cole
70 */
71@Singleton
72public class AzureAsyncBlobStore extends BaseAsyncBlobStore {
73   private final AzureBlobAsyncClient async;
74   private final ContainerToResourceMetadata container2ResourceMd;
75   private final ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions;
76   private final ListBlobsResponseToResourceList azure2BlobStoreResourceList;
77   private final AzureBlobToBlob azureBlob2Blob;
78   private final BlobToAzureBlob blob2AzureBlob;
79   private final BlobPropertiesToBlobMetadata blob2BlobMd;
80   private final BlobToHttpGetOptions blob2ObjectGetOptions;
81 
82   @Inject
83   AzureAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
84            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
85            @Memoized Supplier<Set<? extends Location>> locations, AzureBlobAsyncClient async,
86            ContainerToResourceMetadata container2ResourceMd,
87            ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions,
88            ListBlobsResponseToResourceList azure2BlobStoreResourceList, AzureBlobToBlob azureBlob2Blob,
89            BlobToAzureBlob blob2AzureBlob, BlobPropertiesToBlobMetadata blob2BlobMd,
90            BlobToHttpGetOptions blob2ObjectGetOptions) {
91      super(context, blobUtils, service, defaultLocation, locations);
92      this.async = checkNotNull(async, "async");
93      this.container2ResourceMd = checkNotNull(container2ResourceMd, "container2ResourceMd");
94      this.blobStore2AzureContainerListOptions = checkNotNull(blobStore2AzureContainerListOptions,
95               "blobStore2AzureContainerListOptions");
96      this.azure2BlobStoreResourceList = checkNotNull(azure2BlobStoreResourceList, "azure2BlobStoreResourceList");
97      this.azureBlob2Blob = checkNotNull(azureBlob2Blob, "azureBlob2Blob");
98      this.blob2AzureBlob = checkNotNull(blob2AzureBlob, "blob2AzureBlob");
99      this.blob2BlobMd = checkNotNull(blob2BlobMd, "blob2BlobMd");
100      this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
101   }
102 
103   /**
104    * This implementation invokes {@link AzureBlobAsyncClient#listContainers} with the
105    * {@link org.jclouds.azure.storage.options.ListOptions#includeMetadata} option.
106    */
107   @Override
108   public ListenableFuture<org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>> list() {
109      return Futures
110               .compose(
111                        async.listContainers(includeMetadata()),
112                        new Function<BoundedSet<ContainerProperties>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
113                           public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(
114                                    BoundedSet<ContainerProperties> from) {
115                              return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd),
116                                       from.getNextMarker());
117                           }
118                        }, service);
119   }
120 
121   /**
122    * This implementation invokes {@link AzureBlobAsyncClient#containerExists}
123    * 
124    * @param container
125    *           container name
126    */
127   @Override
128   public ListenableFuture<Boolean> containerExists(String container) {
129      return async.containerExists(container);
130   }
131 
132   /**
133    * This implementation invokes {@link AzureBlobAsyncClient#createContainer}
134    * 
135    * @param location
136    *           ignored
137    * @param container
138    *           container name
139    */
140   @Override
141   public ListenableFuture<Boolean> createContainerInLocation(Location location, String container) {
142      return async.createContainer(container);
143   }
144 
145   /**
146    * This implementation invokes {@link AzureBlobAsyncClient#listBucket}
147    * 
148    * @param container
149    *           container name
150    */
151   @Override
152   public ListenableFuture<PageSet<? extends StorageMetadata>> list(String container, ListContainerOptions options) {
153      ListBlobsOptions azureOptions = blobStore2AzureContainerListOptions.apply(options);
154      ListenableFuture<ListBlobsResponse> returnVal = async.listBlobs(container, azureOptions.includeMetadata());
155      return Futures.compose(returnVal, azure2BlobStoreResourceList, service);
156   }
157 
158   /**
159    * This implementation invokes {@link AzureBlobAsyncClient#deleteContainer}
160    * 
161    * @param container
162    *           container name
163    */
164   @Override
165   public ListenableFuture<Void> deleteContainer(final String container) {
166      return async.deleteContainer(container);
167   }
168 
169   /**
170    * This implementation invokes {@link AzureBlobAsyncClient#getBlob}
171    * 
172    * @param container
173    *           container name
174    * @param key
175    *           blob key
176    */
177   @Override
178   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
179      GetOptions azureOptions = blob2ObjectGetOptions.apply(options);
180      ListenableFuture<AzureBlob> returnVal = async.getBlob(container, key, azureOptions);
181      return Futures.compose(returnVal, azureBlob2Blob, service);
182   }
183 
184   /**
185    * This implementation invokes {@link AzureBlobAsyncClient#putBlob}
186    * 
187    * @param container
188    *           container name
189    * @param blob
190    *           blob
191    */
192   @Override
193   public ListenableFuture<String> putBlob(String container, Blob blob) {
194      return async.putBlob(container, blob2AzureBlob.apply(blob));
195   }
196 
197   /**
198    * This implementation invokes {@link AzureBlobAsyncClient#deleteObject}
199    * 
200    * @param container
201    *           container name
202    * @param key
203    *           blob key
204    */
205   @Override
206   public ListenableFuture<Void> removeBlob(String container, String key) {
207      return async.deleteBlob(container, key);
208   }
209 
210   /**
211    * This implementation invokes {@link AzureBlobAsyncClient#blobExists}
212    * 
213    * @param container
214    *           bucket name
215    * @param credential
216    *           object key
217    */
218   @Override
219   public ListenableFuture<Boolean> blobExists(String container, String name) {
220      return async.blobExists(container, name);
221   }
222 
223   /**
224    * This implementation invokes {@link AzureBlobAsyncClient#getBlobProperties}
225    * 
226    * @param container
227    *           container name
228    * @param key
229    *           blob key
230    */
231   @Override
232   public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) {
233      return Futures.compose(async.getBlobProperties(container, key), new Function<BlobProperties, BlobMetadata>() {
234 
235         @Override
236         public BlobMetadata apply(BlobProperties from) {
237            return blob2BlobMd.apply(from);
238         }
239 
240      }, service);
241   }
242 
243   @Override
244   protected boolean deleteAndVerifyContainerGone(String container) {
245      throw new UnsupportedOperationException("please use deleteContainer");
246   }
247 
248   @Override
249   public ListenableFuture<String> putBlob(String container, Blob blob, PutOptions options) {
250      // TODO implement options
251      return putBlob(container, blob);
252   }
253 
254   @Override
255   public ListenableFuture<Boolean> createContainerInLocation(Location location, String container,
256            CreateContainerOptions options) {
257      org.jclouds.azureblob.options.CreateContainerOptions createContainerOptions = new org.jclouds.azureblob.options.CreateContainerOptions();
258      if (options.isPublicRead())
259         createContainerOptions.withPublicAccess(PublicAccess.CONTAINER);
260      return async.createContainer(container, createContainerOptions);
261   }
262}

[all classes][org.jclouds.azureblob.blobstore]
EMMA 2.0.5312 (C) Vladimir Roubtsov