EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2.compute.strategy]

COVERAGE SUMMARY FOR SOURCE FILE [DescribeImagesParallel.java]

nameclass, %method, %block, %line, %
DescribeImagesParallel.java50%  (1/2)25%  (1/4)24%  (12/49)62%  (5/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DescribeImagesParallel$10%   (0/1)0%   (0/2)0%   (0/23)0%   (0/2)
DescribeImagesParallel$1 (DescribeImagesParallel): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (Map$Entry): Future 0%   (0/1)0%   (0/17)0%   (0/1)
     
class DescribeImagesParallel100% (1/1)50%  (1/2)46%  (12/26)83%  (5/6)
apply (Iterable): Iterable 0%   (0/1)0%   (0/14)0%   (0/1)
DescribeImagesParallel (EC2AsyncClient, ExecutorService): 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.ec2.compute.strategy;
20 
21import static com.google.common.collect.Iterables.concat;
22import static org.jclouds.concurrent.FutureIterables.transformParallel;
23 
24import java.util.Map.Entry;
25import java.util.Set;
26import java.util.concurrent.ExecutorService;
27import java.util.concurrent.Future;
28 
29import javax.annotation.Resource;
30import javax.inject.Inject;
31import javax.inject.Named;
32import javax.inject.Singleton;
33 
34import org.jclouds.Constants;
35import org.jclouds.compute.reference.ComputeServiceConstants;
36import org.jclouds.ec2.EC2AsyncClient;
37import org.jclouds.ec2.options.DescribeImagesOptions;
38import org.jclouds.logging.Logger;
39 
40import com.google.common.base.Function;
41 
42/**
43 * 
44 * @author Adrian Cole
45 */
46@Singleton
47public class DescribeImagesParallel implements
48         Function<Iterable<Entry<String, DescribeImagesOptions>>, Iterable<? extends org.jclouds.ec2.domain.Image>> {
49   @Resource
50   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
51   protected Logger logger = Logger.NULL;
52 
53   protected final EC2AsyncClient async;
54   final ExecutorService executor;
55 
56   @Inject
57   public DescribeImagesParallel(EC2AsyncClient async, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
58      super();
59      this.async = async;
60      this.executor = executor;
61   }
62 
63   @Override
64   public Iterable<? extends org.jclouds.ec2.domain.Image> apply(
65            Iterable<Entry<String, DescribeImagesOptions>> queries) {
66      return concat(transformParallel(
67               queries,
68               new Function<Entry<String, DescribeImagesOptions>, Future<? extends Set<? extends org.jclouds.ec2.domain.Image>>>() {
69 
70                  @Override
71                  public Future<Set<? extends org.jclouds.ec2.domain.Image>> apply(
72                           Entry<String, DescribeImagesOptions> from) {
73                     return async.getAMIServices().describeImagesInRegion(from.getKey(), from.getValue());
74                  }
75 
76               }, executor, null, logger, "amis"));
77   }
78 
79}

[all classes][org.jclouds.ec2.compute.strategy]
EMMA 2.0.5312 (C) Vladimir Roubtsov