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

COVERAGE SUMMARY FOR SOURCE FILE [GetAllBlobsInListAndRetryOnFailure.java]

nameclass, %method, %block, %line, %
GetAllBlobsInListAndRetryOnFailure.java50%  (1/2)25%  (1/4)27%  (18/67)70%  (7/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GetAllBlobsInListAndRetryOnFailure$10%   (0/1)0%   (0/2)0%   (0/18)0%   (0/2)
GetAllBlobsInListAndRetryOnFailure$1 (GetAllBlobsInListAndRetryOnFailure, Str... 0%   (0/1)0%   (0/9)0%   (0/1)
apply (BlobMetadata): Future 0%   (0/1)0%   (0/9)0%   (0/1)
     
class GetAllBlobsInListAndRetryOnFailure100% (1/1)50%  (1/2)37%  (18/49)78%  (7/9)
execute (String, ListContainerOptions): Iterable 0%   (0/1)0%   (0/31)0%   (0/2)
GetAllBlobsInListAndRetryOnFailure (ExecutorService, ListBlobsInContainer, As... 100% (1/1)100% (18/18)100% (7/7)

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.blobstore.strategy.internal;
20 
21import static org.jclouds.concurrent.FutureIterables.transformParallel;
22 
23import java.util.concurrent.ExecutorService;
24import java.util.concurrent.Future;
25 
26import javax.annotation.Resource;
27import javax.inject.Named;
28import javax.inject.Singleton;
29 
30import org.jclouds.Constants;
31import org.jclouds.blobstore.AsyncBlobStore;
32import org.jclouds.blobstore.domain.Blob;
33import org.jclouds.blobstore.domain.BlobMetadata;
34import org.jclouds.blobstore.options.ListContainerOptions;
35import org.jclouds.blobstore.reference.BlobStoreConstants;
36import org.jclouds.blobstore.strategy.GetBlobsInListStrategy;
37import org.jclouds.blobstore.strategy.ListBlobsInContainer;
38import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
39import org.jclouds.logging.Logger;
40 
41import com.google.common.base.Function;
42import com.google.inject.Inject;
43 
44/**
45 * Retrieves all blobs in the blobstore under the current path, by the most efficient means
46 * possible.
47 * 
48 * @author Adrian Cole
49 */
50@Singleton
51public class GetAllBlobsInListAndRetryOnFailure implements GetBlobsInListStrategy {
52 
53   protected final ListBlobsInContainer getAllBlobMetadata;
54   protected final BackoffLimitedRetryHandler retryHandler;
55   protected final AsyncBlobStore ablobstore;
56   protected final ExecutorService userExecutor;
57   @Resource
58   @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
59   protected Logger logger = Logger.NULL;
60   /**
61    * maximum duration of an blob Request
62    */
63   @Inject(optional = true)
64   @Named(Constants.PROPERTY_REQUEST_TIMEOUT)
65   protected Long maxTime;
66 
67   @Inject
68   GetAllBlobsInListAndRetryOnFailure(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor,
69            ListBlobsInContainer getAllBlobMetadata, AsyncBlobStore ablobstore, BackoffLimitedRetryHandler retryHandler) {
70      this.userExecutor = userExecutor;
71      this.ablobstore = ablobstore;
72      this.getAllBlobMetadata = getAllBlobMetadata;
73      this.retryHandler = retryHandler;
74   }
75 
76   public Iterable<Blob> execute(final String container, ListContainerOptions options) {
77      Iterable<? extends BlobMetadata> list = getAllBlobMetadata.execute(container, options);
78      return transformParallel(list, new Function<BlobMetadata, Future<Blob>>() {
79 
80         @Override
81         public Future<Blob> apply(BlobMetadata from) {
82            return ablobstore.getBlob(container, from.getName());
83         }
84 
85      }, userExecutor, maxTime, logger, String.format("getting from containerName: %s", container), retryHandler, 3);
86 
87   }
88}

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