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

COVERAGE SUMMARY FOR SOURCE FILE [PutBlobsStrategyImpl.java]

nameclass, %method, %block, %line, %
PutBlobsStrategyImpl.java100% (1/1)50%  (1/2)17%  (12/71)42%  (5/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PutBlobsStrategyImpl100% (1/1)50%  (1/2)17%  (12/71)42%  (5/12)
execute (String, Iterable): void 0%   (0/1)0%   (0/59)0%   (0/7)
PutBlobsStrategyImpl (ExecutorService, AsyncBlobStore): void 100% (1/1)100% (12/12)100% (5/5)

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.awaitCompletion;
22 
23import java.util.Map;
24import java.util.concurrent.ExecutorService;
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.internal.BlobRuntimeException;
34import org.jclouds.blobstore.reference.BlobStoreConstants;
35import org.jclouds.blobstore.strategy.PutBlobsStrategy;
36import org.jclouds.logging.Logger;
37 
38import com.google.common.collect.Maps;
39import java.util.concurrent.Future;
40import com.google.inject.Inject;
41 
42/**
43 * 
44 * @author Adrian Cole
45 */
46@Singleton
47public class PutBlobsStrategyImpl implements PutBlobsStrategy {
48 
49   private final AsyncBlobStore ablobstore;
50   private final ExecutorService userExecutor;
51   @Resource
52   @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
53   protected Logger logger = Logger.NULL;
54   /**
55    * maximum duration of an blob Request
56    */
57   @Inject(optional = true)
58   @Named(Constants.PROPERTY_REQUEST_TIMEOUT)
59   protected Long maxTime;
60 
61   @Inject
62   PutBlobsStrategyImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor,
63            AsyncBlobStore ablobstore) {
64      this.userExecutor = userExecutor;
65      this.ablobstore = ablobstore;
66   }
67 
68   @Override
69   public void execute(String containerName, Iterable<? extends Blob> blobs) {
70      Map<Blob, Future<?>> responses = Maps.newLinkedHashMap();
71      for (Blob blob : blobs) {
72         responses.put(blob, ablobstore.putBlob(containerName, blob));
73      }
74      Map<Blob, Exception> exceptions = awaitCompletion(responses, userExecutor, maxTime, logger,
75               String.format("putting into containerName: %s", containerName));
76      if (exceptions.size() > 0)
77         throw new BlobRuntimeException(String.format("error putting into container %s: %s",
78                  containerName, exceptions));
79   }
80 
81}

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