EMMA Coverage Report (generated Tue Jun 21 05:51:52 EDT 2011)
[all classes][org.jclouds.openstack.swift.blobstore]

COVERAGE SUMMARY FOR SOURCE FILE [SwiftAsyncBlobStore.java]

nameclass, %method, %block, %line, %
SwiftAsyncBlobStore.java0%   (0/3)0%   (0/17)0%   (0/214)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SwiftAsyncBlobStore0%   (0/1)0%   (0/13)0%   (0/186)0%   (0/30)
SwiftAsyncBlobStore (BlobStoreContext, BlobUtils, ExecutorService, Supplier, ... 0%   (0/1)0%   (0/41)0%   (0/12)
access$000 (SwiftAsyncBlobStore): ContainerToResourceMetadata 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (SwiftAsyncBlobStore): ObjectToBlobMetadata 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/5)0%   (0/1)
deleteAndVerifyContainerGone (String): boolean 0%   (0/1)0%   (0/14)0%   (0/2)
getBlob (String, String, GetOptions): ListenableFuture 0%   (0/1)0%   (0/24)0%   (0/3)
list (): ListenableFuture 0%   (0/1)0%   (0/13)0%   (0/1)
list (String, ListContainerOptions): ListenableFuture 0%   (0/1)0%   (0/39)0%   (0/4)
putBlob (String, Blob): ListenableFuture 0%   (0/1)0%   (0/14)0%   (0/2)
removeBlob (String, String): ListenableFuture 0%   (0/1)0%   (0/6)0%   (0/1)
     
class SwiftAsyncBlobStore$10%   (0/1)0%   (0/2)0%   (0/16)0%   (0/2)
SwiftAsyncBlobStore$1 (SwiftAsyncBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Set): PageSet 0%   (0/1)0%   (0/10)0%   (0/1)
     
class SwiftAsyncBlobStore$20%   (0/1)0%   (0/2)0%   (0/12)0%   (0/2)
SwiftAsyncBlobStore$2 (SwiftAsyncBlobStore): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (MutableObjectInfoWithMetadata): BlobMetadata 0%   (0/1)0%   (0/6)0%   (0/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.openstack.swift.blobstore;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.blobstore.util.BlobStoreUtils.createParentIfNeededAsync;
23 
24import java.util.Set;
25import java.util.concurrent.ExecutorService;
26 
27import javax.inject.Inject;
28import javax.inject.Named;
29import javax.inject.Provider;
30import javax.inject.Singleton;
31 
32import org.jclouds.Constants;
33import org.jclouds.blobstore.BlobStoreContext;
34import org.jclouds.blobstore.domain.Blob;
35import org.jclouds.blobstore.domain.BlobMetadata;
36import org.jclouds.blobstore.domain.PageSet;
37import org.jclouds.blobstore.domain.StorageMetadata;
38import org.jclouds.blobstore.domain.internal.PageSetImpl;
39import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
40import org.jclouds.blobstore.internal.BaseAsyncBlobStore;
41import org.jclouds.blobstore.options.ListContainerOptions;
42import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
43import org.jclouds.blobstore.util.BlobUtils;
44import org.jclouds.collect.Memoized;
45import org.jclouds.concurrent.Futures;
46import org.jclouds.domain.Location;
47import org.jclouds.http.options.GetOptions;
48import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
49import org.jclouds.openstack.swift.CommonSwiftClient;
50import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
51import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
52import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList;
53import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata;
54import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob;
55import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
56import org.jclouds.openstack.swift.domain.ContainerMetadata;
57import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata;
58import org.jclouds.openstack.swift.domain.ObjectInfo;
59import org.jclouds.openstack.swift.domain.SwiftObject;
60 
61import com.google.common.base.Function;
62import com.google.common.base.Supplier;
63import com.google.common.collect.Iterables;
64import com.google.common.util.concurrent.ListenableFuture;
65 
66/**
67 * 
68 * @author Adrian Cole
69 */
70@Singleton
71public class SwiftAsyncBlobStore extends BaseAsyncBlobStore {
72   private final CommonSwiftClient sync;
73   private final CommonSwiftAsyncClient async;
74   private final ContainerToResourceMetadata container2ResourceMd;
75   private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions;
76   private final ContainerToResourceList container2ResourceList;
77   private final ObjectToBlob object2Blob;
78   private final BlobToObject blob2Object;
79   private final ObjectToBlobMetadata object2BlobMd;
80   private final BlobToHttpGetOptions blob2ObjectGetOptions;
81   private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
82 
83   @Inject
84   SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
85            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
86            @Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync, CommonSwiftAsyncClient async,
87            ContainerToResourceMetadata container2ResourceMd,
88            BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
89            ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object,
90            ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions,
91            Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
92      super(context, blobUtils, service, defaultLocation, locations);
93      this.sync = sync;
94      this.async = async;
95      this.container2ResourceMd = container2ResourceMd;
96      this.container2ContainerListOptions = container2ContainerListOptions;
97      this.container2ResourceList = container2ResourceList;
98      this.object2Blob = object2Blob;
99      this.blob2Object = blob2Object;
100      this.object2BlobMd = object2BlobMd;
101      this.blob2ObjectGetOptions = blob2ObjectGetOptions;
102      this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
103   }
104 
105   /**
106    * This implementation invokes {@link CommonSwiftAsyncClient#listContainers}
107    */
108   @Override
109   public ListenableFuture<PageSet<? extends StorageMetadata>> list() {
110      return Futures.compose(async.listContainers(),
111               new Function<Set<ContainerMetadata>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
112                  public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(
113                           Set<ContainerMetadata> from) {
114                     return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd), null);
115                  }
116               }, service);
117   }
118 
119   /**
120    * This implementation invokes {@link CommonSwiftAsyncClient#containerExists}
121    * 
122    * @param container
123    *           container name
124    */
125   @Override
126   public ListenableFuture<Boolean> containerExists(String container) {
127      return async.containerExists(container);
128   }
129 
130   /**
131    * Note that location is currently ignored.
132    */
133   @Override
134   public ListenableFuture<Boolean> createContainerInLocation(Location location, String container) {
135      return async.createContainer(container);
136   }
137 
138   /**
139    * This implementation invokes {@link CommonSwiftAsyncClient#listBucket}
140    * 
141    * @param container
142    *           container name
143    */
144   @Override
145   public ListenableFuture<PageSet<? extends StorageMetadata>> list(String container, ListContainerOptions options) {
146      org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions
147               .apply(options);
148      ListenableFuture<PageSet<ObjectInfo>> returnVal = async.listObjects(container, httpOptions);
149      ListenableFuture<PageSet<? extends StorageMetadata>> list = Futures.compose(returnVal, container2ResourceList,
150               service);
151      return options.isDetailed() ? Futures.compose(list, fetchBlobMetadataProvider.get().setContainerName(container),
152               service) : list;
153   }
154 
155   /**
156    * This implementation invokes {@link CommonSwiftAsyncClient#objectExists}
157    * 
158    * @param container
159    *           container name
160    * @param key
161    *           object key
162    */
163   @Override
164   public ListenableFuture<Boolean> blobExists(String container, String key) {
165      return async.objectExists(container, key);
166   }
167 
168   /**
169    * This implementation invokes {@link CommonSwiftAsyncClient#headObject}
170    * 
171    * @param container
172    *           container name
173    * @param key
174    *           object key
175    */
176   @Override
177   public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) {
178      return Futures.compose(async.getObjectInfo(container, key),
179               new Function<MutableObjectInfoWithMetadata, BlobMetadata>() {
180 
181                  @Override
182                  public BlobMetadata apply(MutableObjectInfoWithMetadata from) {
183                     return object2BlobMd.apply(from);
184                  }
185 
186               }, service);
187   }
188 
189   /**
190    * This implementation invokes {@link CommonSwiftAsyncClient#getObject}
191    * 
192    * @param container
193    *           container name
194    * @param key
195    *           object key
196    */
197   @Override
198   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
199      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
200      ListenableFuture<SwiftObject> returnVal = async.getObject(container, key, httpOptions);
201      return Futures.compose(returnVal, object2Blob, service);
202   }
203 
204   /**
205    * This implementation invokes {@link CommonSwiftAsyncClient#putObject}
206    * 
207    * @param container
208    *           container name
209    * @param blob
210    *           object
211    */
212   @Override
213   public ListenableFuture<String> putBlob(String container, Blob blob) {
214      createParentIfNeededAsync(this, container, blob);
215      return async.putObject(container, blob2Object.apply(blob));
216   }
217 
218   /**
219    * This implementation invokes {@link CommonSwiftAsyncClient#removeObject}
220    * 
221    * @param container
222    *           container name
223    * @param key
224    *           object key
225    */
226   @Override
227   public ListenableFuture<Void> removeBlob(String container, String key) {
228      return async.removeObject(container, key);
229   }
230 
231   @Override
232   protected boolean deleteAndVerifyContainerGone(String container) {
233      sync.deleteContainerIfEmpty(container);
234      return !sync.containerExists(container);
235   }
236 
237}

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