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

COVERAGE SUMMARY FOR SOURCE FILE [AWSEC2ListNodesStrategy.java]

nameclass, %method, %block, %line, %
AWSEC2ListNodesStrategy.java0%   (0/2)0%   (0/4)0%   (0/59)0%   (0/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AWSEC2ListNodesStrategy0%   (0/1)0%   (0/2)0%   (0/44)0%   (0/6)
AWSEC2ListNodesStrategy (AWSEC2AsyncClient, Set, Function, ExecutorService, S... 0%   (0/1)0%   (0/19)0%   (0/4)
pollRunningInstances (): Iterable 0%   (0/1)0%   (0/25)0%   (0/2)
     
class AWSEC2ListNodesStrategy$10%   (0/1)0%   (0/2)0%   (0/15)0%   (0/2)
AWSEC2ListNodesStrategy$1 (AWSEC2ListNodesStrategy): void 0%   (0/1)0%   (0/6)0%   (0/1)
apply (String): Future 0%   (0/1)0%   (0/9)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.aws.ec2.compute.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Predicates.notNull;
23import static com.google.common.collect.Iterables.concat;
24import static com.google.common.collect.Iterables.filter;
25import static com.google.common.collect.Iterables.transform;
26import static org.jclouds.concurrent.FutureIterables.transformParallel;
27 
28import java.util.Set;
29import java.util.concurrent.ExecutorService;
30import java.util.concurrent.Future;
31 
32import javax.inject.Inject;
33import javax.inject.Named;
34import javax.inject.Singleton;
35 
36import org.jclouds.Constants;
37import org.jclouds.aws.ec2.AWSEC2AsyncClient;
38import org.jclouds.aws.ec2.domain.AWSRunningInstance;
39import org.jclouds.aws.ec2.domain.SpotInstanceRequest;
40import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance;
41import org.jclouds.compute.domain.NodeMetadata;
42import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy;
43import org.jclouds.ec2.domain.RunningInstance;
44import org.jclouds.location.Region;
45 
46import com.google.common.base.Function;
47 
48/**
49 * 
50 * @author Adrian Cole
51 */
52@Singleton
53public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy {
54 
55   protected final AWSEC2AsyncClient client;
56   protected final SpotInstanceRequestToAWSRunningInstance spotConverter;
57 
58   @Inject
59   protected AWSEC2ListNodesStrategy(AWSEC2AsyncClient client, @Region Set<String> regions,
60            Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
61            @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
62            SpotInstanceRequestToAWSRunningInstance spotConverter) {
63      super(client, regions, runningInstanceToNodeMetadata, executor);
64      this.client = checkNotNull(client, "client");
65      this.spotConverter = checkNotNull(spotConverter, "spotConverter");
66   }
67 
68   @Override
69   protected Iterable<? extends RunningInstance> pollRunningInstances() {
70      Iterable<? extends AWSRunningInstance> spots = filter(transform(concat(transformParallel(regions,
71               new Function<String, Future<Set<SpotInstanceRequest>>>() {
72 
73                  @SuppressWarnings("unchecked")
74                  @Override
75                  public Future<Set<SpotInstanceRequest>> apply(String from) {
76                     return (Future<Set<SpotInstanceRequest>>) client.getSpotInstanceServices()
77                              .describeSpotInstanceRequestsInRegion(from);
78                  }
79 
80               }, executor, null, logger, "reservations")), spotConverter), notNull());
81 
82      return concat(super.pollRunningInstances(), spots);
83   }
84}

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