EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.blobstore.internal]

COVERAGE SUMMARY FOR SOURCE FILE [BaseBlobStore.java]

nameclass, %method, %block, %line, %
BaseBlobStore.java0%   (0/2)0%   (0/18)0%   (0/163)0%   (0/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BaseBlobStore0%   (0/1)0%   (0/16)0%   (0/137)0%   (0/31)
BaseBlobStore (BlobStoreContext, BlobUtils, Supplier, Supplier): void 0%   (0/1)0%   (0/27)0%   (0/6)
blobBuilder (String): BlobBuilder 0%   (0/1)0%   (0/6)0%   (0/1)
clearAndDeleteContainer (String): void 0%   (0/1)0%   (0/36)0%   (0/6)
clearContainer (String): void 0%   (0/1)0%   (0/5)0%   (0/2)
clearContainer (String, ListContainerOptions): void 0%   (0/1)0%   (0/6)0%   (0/2)
countBlobs (String): long 0%   (0/1)0%   (0/5)0%   (0/1)
countBlobs (String, ListContainerOptions): long 0%   (0/1)0%   (0/6)0%   (0/1)
createDirectory (String, String): void 0%   (0/1)0%   (0/6)0%   (0/2)
deleteContainer (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
deleteDirectory (String, String): void 0%   (0/1)0%   (0/6)0%   (0/2)
directoryExists (String, String): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
getBlob (String, String): Blob 0%   (0/1)0%   (0/6)0%   (0/1)
getContext (): BlobStoreContext 0%   (0/1)0%   (0/3)0%   (0/1)
list (String): PageSet 0%   (0/1)0%   (0/5)0%   (0/1)
listAssignableLocations (): Set 0%   (0/1)0%   (0/5)0%   (0/1)
newBlob (String): Blob 0%   (0/1)0%   (0/5)0%   (0/1)
     
class BaseBlobStore$10%   (0/1)0%   (0/2)0%   (0/26)0%   (0/5)
BaseBlobStore$1 (BaseBlobStore, String): void 0%   (0/1)0%   (0/9)0%   (0/1)
get (): Boolean 0%   (0/1)0%   (0/17)0%   (0/4)

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.blobstore.internal;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
23 
24import java.util.Set;
25 
26import javax.inject.Inject;
27 
28import org.jclouds.blobstore.BlobStore;
29import org.jclouds.blobstore.BlobStoreContext;
30import org.jclouds.blobstore.ContainerNotFoundException;
31import org.jclouds.blobstore.domain.Blob;
32import org.jclouds.blobstore.domain.BlobBuilder;
33import org.jclouds.blobstore.domain.PageSet;
34import org.jclouds.blobstore.domain.StorageMetadata;
35import org.jclouds.blobstore.options.ListContainerOptions;
36import org.jclouds.blobstore.util.BlobUtils;
37import org.jclouds.blobstore.util.internal.BlobUtilsImpl;
38import org.jclouds.collect.Memoized;
39import org.jclouds.domain.Location;
40import org.jclouds.util.Assertions;
41 
42import com.google.common.base.Supplier;
43 
44/**
45 * 
46 * @author Adrian Cole
47 */
48public abstract class BaseBlobStore implements BlobStore {
49 
50   protected final BlobStoreContext context;
51   protected final BlobUtils blobUtils;
52   protected final Supplier<Location> defaultLocation;
53   protected final Supplier<Set<? extends Location>> locations;
54 
55   @Inject
56   protected BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
57         @Memoized Supplier<Set<? extends Location>> locations) {
58      this.context = checkNotNull(context, "context");
59      this.blobUtils = checkNotNull(blobUtils, "blobUtils");
60      this.defaultLocation = checkNotNull(defaultLocation, "defaultLocation");
61      this.locations = checkNotNull(locations, "locations");
62   }
63 
64   @Override
65   public BlobStoreContext getContext() {
66      return context;
67   }
68 
69   /**
70    * invokes {@link BlobUtilsImpl#newBlob }
71    */
72   @Override
73   public Blob newBlob(String name) {
74      return blobUtils.newBlob(name);
75   }
76 
77   /**
78    * invokes {@link BlobUtilsImpl#blobBuilder }
79    */
80   @Override
81   public BlobBuilder blobBuilder(String name) {
82      return blobUtils.blobBuilder().name(name);
83   }
84 
85   /**
86    * This implementation invokes
87    * {@link #list(String,org.jclouds.blobstore.options.ListContainerOptions)}
88    * 
89    * @param container
90    *           container name
91    */
92   @Override
93   public PageSet<? extends StorageMetadata> list(String container) {
94      return this.list(container, org.jclouds.blobstore.options.ListContainerOptions.NONE);
95   }
96 
97   /**
98    * This implementation invokes {@link BlobUtilsImpl#directoryExists}
99    * 
100    * @param container
101    *           container name
102    * @param directory
103    *           virtual path
104    */
105   @Override
106   public boolean directoryExists(String containerName, String directory) {
107      return blobUtils.directoryExists(containerName, directory);
108   }
109 
110   /**
111    * This implementation invokes {@link BlobUtilsImpl#createDirectory}
112    * 
113    * @param container
114    *           container name
115    * @param directory
116    *           virtual path
117    */
118   @Override
119   public void createDirectory(String containerName, String directory) {
120      blobUtils.createDirectory(containerName, directory);
121   }
122 
123   /**
124    * This implementation invokes {@link #countBlobs} with the
125    * {@link ListContainerOptions#recursive} option.
126    * 
127    * @param container
128    *           container name
129    */
130   @Override
131   public long countBlobs(String container) {
132      return countBlobs(container, recursive());
133   }
134 
135   /**
136    * This implementation invokes {@link BlobUtilsImpl#countBlobs}
137    * 
138    * @param container
139    *           container name
140    */
141   @Override
142   public long countBlobs(String containerName, ListContainerOptions options) {
143      return blobUtils.countBlobs(containerName, options);
144   }
145 
146   /**
147    * This implementation invokes {@link #clearContainer} with the
148    * {@link ListContainerOptions#recursive} option.
149    * 
150    * @param container
151    *           container name
152    */
153   @Override
154   public void clearContainer(String containerName) {
155      clearContainer(containerName, recursive());
156   }
157 
158   /**
159    * This implementation invokes {@link BlobUtilsImpl#clearContainer}
160    * 
161    * @param container
162    *           container name
163    */
164   @Override
165   public void clearContainer(String containerName, ListContainerOptions options) {
166      blobUtils.clearContainer(containerName, options);
167   }
168 
169   /**
170    * This implementation invokes {@link BlobUtilsImpl#deleteDirectory}.
171    * 
172    * @param container
173    *           container name
174    */
175   @Override
176   public void deleteDirectory(String containerName, String directory) {
177      blobUtils.deleteDirectory(containerName, directory);
178   }
179 
180   /**
181    * This implementation invokes
182    * {@link #getBlob(String,String,org.jclouds.blobstore.options.GetOptions)}
183    * 
184    * @param container
185    *           container name
186    * @param key
187    *           blob key
188    */
189   @Override
190   public Blob getBlob(String container, String key) {
191      return getBlob(container, key, org.jclouds.blobstore.options.GetOptions.NONE);
192   }
193 
194   /**
195    * This implementation invokes {@link #deleteAndEnsurePathGone}
196    * 
197    * @param container
198    *           bucket name
199    */
200   @Override
201   public void deleteContainer(final String container) {
202      clearAndDeleteContainer(container);
203   }
204 
205   protected void clearAndDeleteContainer(final String container) {
206      try {
207         if (!Assertions.eventuallyTrue(new Supplier<Boolean>() {
208            public Boolean get() {
209               try {
210                  clearContainer(container, recursive());
211                  return deleteAndVerifyContainerGone(container);
212               } catch (ContainerNotFoundException e) {
213                  return true;
214               }
215            }
216 
217         }, 30000)) {
218            throw new IllegalStateException(container + " still exists after deleting!");
219         }
220      } catch (InterruptedException e) {
221         new IllegalStateException(container + " interrupted during deletion!", e);
222      }
223   }
224 
225   @Override
226   public Set<? extends Location> listAssignableLocations() {
227      return locations.get();
228   }
229 
230   protected abstract boolean deleteAndVerifyContainerGone(String container);
231 
232}

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