EMMA Coverage Report (generated Mon Oct 17 05:41:20 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/19)0%   (0/232)0%   (0/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SwiftAsyncBlobStore0%   (0/1)0%   (0/15)0%   (0/204)0%   (0/34)
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)
createContainerInLocation (Location, String, CreateContainerOptions): Listena... 0%   (0/1)0%   (0/13)0%   (0/3)
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)
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)
     
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 * 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.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.CreateContainerOptions;
42import org.jclouds.blobstore.options.ListContainerOptions;
43import org.jclouds.blobstore.options.PutOptions;
44import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
45import org.jclouds.blobstore.util.BlobUtils;
46import org.jclouds.collect.Memoized;
47import org.jclouds.concurrent.Futures;
48import org.jclouds.domain.Location;
49import org.jclouds.http.options.GetOptions;
50import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
51import org.jclouds.openstack.swift.CommonSwiftClient;
52import org.jclouds.openstack.swift.blobstore.functions.BlobStoreListContainerOptionsToListContainerOptions;
53import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
54import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceList;
55import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetadata;
56import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob;
57import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata;
58import org.jclouds.openstack.swift.domain.ContainerMetadata;
59import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata;
60import org.jclouds.openstack.swift.domain.ObjectInfo;
61import org.jclouds.openstack.swift.domain.SwiftObject;
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 * 
70 * @author Adrian Cole
71 */
72@Singleton
73public class SwiftAsyncBlobStore extends BaseAsyncBlobStore {
74   private final CommonSwiftClient sync;
75   private final CommonSwiftAsyncClient async;
76   private final ContainerToResourceMetadata container2ResourceMd;
77   private final BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions;
78   private final ContainerToResourceList container2ResourceList;
79   private final ObjectToBlob object2Blob;
80   private final BlobToObject blob2Object;
81   private final ObjectToBlobMetadata object2BlobMd;
82   private final BlobToHttpGetOptions blob2ObjectGetOptions;
83   private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
84 
85   @Inject
86   protected SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
87            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier<Location> defaultLocation,
88            @Memoized Supplier<Set<? extends Location>> locations, CommonSwiftClient sync,
89            CommonSwiftAsyncClient async, ContainerToResourceMetadata container2ResourceMd,
90            BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
91            ContainerToResourceList container2ResourceList, ObjectToBlob object2Blob, BlobToObject blob2Object,
92            ObjectToBlobMetadata object2BlobMd, BlobToHttpGetOptions blob2ObjectGetOptions,
93            Provider<FetchBlobMetadata> fetchBlobMetadataProvider) {
94      super(context, blobUtils, service, defaultLocation, locations);
95      this.sync = sync;
96      this.async = async;
97      this.container2ResourceMd = container2ResourceMd;
98      this.container2ContainerListOptions = container2ContainerListOptions;
99      this.container2ResourceList = container2ResourceList;
100      this.object2Blob = object2Blob;
101      this.blob2Object = blob2Object;
102      this.object2BlobMd = object2BlobMd;
103      this.blob2ObjectGetOptions = blob2ObjectGetOptions;
104      this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
105   }
106 
107   /**
108    * This implementation invokes {@link CommonSwiftAsyncClient#listContainers}
109    */
110   @Override
111   public ListenableFuture<PageSet<? extends StorageMetadata>> list() {
112      return Futures.compose(async.listContainers(),
113               new Function<Set<ContainerMetadata>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
114                  public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(
115                           Set<ContainerMetadata> from) {
116                     return new PageSetImpl<StorageMetadata>(Iterables.transform(from, container2ResourceMd), null);
117                  }
118               }, service);
119   }
120 
121   /**
122    * This implementation invokes {@link CommonSwiftAsyncClient#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    * Note that location is currently ignored.
134    */
135   @Override
136   public ListenableFuture<Boolean> createContainerInLocation(Location location, String container) {
137      return async.createContainer(container);
138   }
139 
140   /**
141    * This implementation invokes {@link CommonSwiftAsyncClient#listBucket}
142    * 
143    * @param container
144    *           container name
145    */
146   @Override
147   public ListenableFuture<PageSet<? extends StorageMetadata>> list(String container, ListContainerOptions options) {
148      org.jclouds.openstack.swift.options.ListContainerOptions httpOptions = container2ContainerListOptions
149               .apply(options);
150      ListenableFuture<PageSet<ObjectInfo>> returnVal = async.listObjects(container, httpOptions);
151      ListenableFuture<PageSet<? extends StorageMetadata>> list = Futures.compose(returnVal, container2ResourceList,
152               service);
153      return options.isDetailed() ? Futures.compose(list, fetchBlobMetadataProvider.get().setContainerName(container),
154               service) : list;
155   }
156 
157   /**
158    * This implementation invokes {@link CommonSwiftAsyncClient#objectExists}
159    * 
160    * @param container
161    *           container name
162    * @param key
163    *           object key
164    */
165   @Override
166   public ListenableFuture<Boolean> blobExists(String container, String key) {
167      return async.objectExists(container, key);
168   }
169 
170   /**
171    * This implementation invokes {@link CommonSwiftAsyncClient#headObject}
172    * 
173    * @param container
174    *           container name
175    * @param key
176    *           object key
177    */
178   @Override
179   public ListenableFuture<BlobMetadata> blobMetadata(String container, String key) {
180      return Futures.compose(async.getObjectInfo(container, key),
181               new Function<MutableObjectInfoWithMetadata, BlobMetadata>() {
182 
183                  @Override
184                  public BlobMetadata apply(MutableObjectInfoWithMetadata from) {
185                     return object2BlobMd.apply(from);
186                  }
187 
188               }, service);
189   }
190 
191   /**
192    * This implementation invokes {@link CommonSwiftAsyncClient#getObject}
193    * 
194    * @param container
195    *           container name
196    * @param key
197    *           object key
198    */
199   @Override
200   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
201      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
202      ListenableFuture<SwiftObject> returnVal = async.getObject(container, key, httpOptions);
203      return Futures.compose(returnVal, object2Blob, service);
204   }
205 
206   /**
207    * This implementation invokes {@link CommonSwiftAsyncClient#putObject}
208    * 
209    * @param container
210    *           container name
211    * @param blob
212    *           object
213    */
214   @Override
215   public ListenableFuture<String> putBlob(String container, Blob blob) {
216      createParentIfNeededAsync(this, container, blob);
217      return async.putObject(container, blob2Object.apply(blob));
218   }
219 
220   /**
221    * This implementation invokes {@link CommonSwiftAsyncClient#removeObject}
222    * 
223    * @param container
224    *           container name
225    * @param key
226    *           object key
227    */
228   @Override
229   public ListenableFuture<Void> removeBlob(String container, String key) {
230      return async.removeObject(container, key);
231   }
232 
233   @Override
234   protected boolean deleteAndVerifyContainerGone(String container) {
235      sync.deleteContainerIfEmpty(container);
236      return !sync.containerExists(container);
237   }
238 
239   @Override
240   public ListenableFuture<String> putBlob(String container, Blob blob, PutOptions options) {
241      // TODO implement options
242      return putBlob(container, blob);
243   }
244 
245   @Override
246   public ListenableFuture<Boolean> createContainerInLocation(Location location, String container,
247            CreateContainerOptions options) {
248      if (options.isPublicRead())
249         throw new UnsupportedOperationException("publicRead");
250      return createContainerInLocation(location, container);
251   }
252}

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