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

COVERAGE SUMMARY FOR SOURCE FILE [AWSEC2ComputeServiceContextModule.java]

nameclass, %method, %block, %line, %
AWSEC2ComputeServiceContextModule.java50%  (1/2)38%  (3/8)68%  (84/123)78%  (18/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AWSEC2ComputeServiceContextModule$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/2)
AWSEC2ComputeServiceContextModule$1 (AWSEC2ComputeServiceContextModule, AWSRe... 0%   (0/1)0%   (0/9)0%   (0/1)
get (): Cache 0%   (0/1)0%   (0/4)0%   (0/1)
     
class AWSEC2ComputeServiceContextModule100% (1/1)50%  (3/6)76%  (84/110)86%  (18/21)
provideRegionAndNameToImageSupplierCache (long, AWSRegionAndNameToImageSuppli... 0%   (0/1)0%   (0/12)0%   (0/1)
provideTemplate (Injector, TemplateBuilder): TemplateBuilder 0%   (0/1)0%   (0/6)0%   (0/1)
provideTemplateOptions (Injector, TemplateOptions): TemplateOptions 0%   (0/1)0%   (0/8)0%   (0/1)
AWSEC2ComputeServiceContextModule (): void 100% (1/1)100% (3/3)100% (1/1)
configure (): void 100% (1/1)100% (75/75)100% (15/15)
installDependencies (): void 100% (1/1)100% (6/6)100% (2/2)

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.config;
20 
21import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
22import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX;
23 
24import javax.inject.Named;
25import javax.inject.Singleton;
26 
27import org.jclouds.aws.ec2.compute.AWSEC2TemplateBuilderImpl;
28import org.jclouds.aws.ec2.compute.functions.AWSRunningInstanceToNodeMetadata;
29import org.jclouds.aws.ec2.compute.predicates.AWSEC2InstancePresent;
30import org.jclouds.aws.ec2.compute.strategy.AWSEC2CreateNodesInGroupThenAddToSet;
31import org.jclouds.aws.ec2.compute.strategy.AWSEC2DestroyNodeStrategy;
32import org.jclouds.aws.ec2.compute.strategy.AWSEC2GetNodeMetadataStrategy;
33import org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy;
34import org.jclouds.aws.ec2.compute.strategy.AWSEC2ReviseParsedImage;
35import org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions;
36import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier;
37import org.jclouds.aws.ec2.compute.suppliers.AWSRegionAndNameToImageSupplier;
38import org.jclouds.compute.config.BaseComputeServiceContextModule;
39import org.jclouds.compute.domain.Image;
40import org.jclouds.compute.domain.TemplateBuilder;
41import org.jclouds.compute.options.TemplateOptions;
42import org.jclouds.ec2.compute.config.EC2BindComputeStrategiesByClass;
43import org.jclouds.ec2.compute.config.EC2BindComputeSuppliersByClass;
44import org.jclouds.ec2.compute.domain.RegionAndName;
45import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata;
46import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
47import org.jclouds.ec2.compute.options.EC2TemplateOptions;
48import org.jclouds.ec2.compute.predicates.InstancePresent;
49import org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions;
50import org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet;
51import org.jclouds.ec2.compute.strategy.EC2DestroyNodeStrategy;
52import org.jclouds.ec2.compute.strategy.EC2GetNodeMetadataStrategy;
53import org.jclouds.ec2.compute.strategy.EC2ListNodesStrategy;
54import org.jclouds.ec2.compute.strategy.ReviseParsedImage;
55import org.jclouds.ec2.compute.suppliers.EC2HardwareSupplier;
56import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
57 
58import com.google.common.base.Supplier;
59import com.google.common.cache.Cache;
60import com.google.inject.Injector;
61import com.google.inject.Provides;
62 
63/**
64 * 
65 * @author Adrian Cole
66 */
67public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContextModule {
68   @Override
69   protected void configure() {
70      super.configure();
71      installDependencies();
72      install(new EC2BindComputeStrategiesByClass());
73      install(new EC2BindComputeSuppliersByClass());
74      bind(ReviseParsedImage.class).to(AWSEC2ReviseParsedImage.class);
75      bind(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class).to(
76               CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class);
77      bind(EC2HardwareSupplier.class).to(AWSEC2HardwareSupplier.class);
78      bind(EC2TemplateBuilderImpl.class).to(AWSEC2TemplateBuilderImpl.class);
79      bind(EC2GetNodeMetadataStrategy.class).to(AWSEC2GetNodeMetadataStrategy.class);
80      bind(EC2ListNodesStrategy.class).to(AWSEC2ListNodesStrategy.class);
81      bind(EC2DestroyNodeStrategy.class).to(AWSEC2DestroyNodeStrategy.class);
82      bind(InstancePresent.class).to(AWSEC2InstancePresent.class);
83      bind(EC2CreateNodesInGroupThenAddToSet.class).to(AWSEC2CreateNodesInGroupThenAddToSet.class);
84      bind(RunningInstanceToNodeMetadata.class).to(AWSRunningInstanceToNodeMetadata.class);
85   }
86 
87   protected void installDependencies() {
88      install(new AWSEC2ComputeServiceDependenciesModule());
89   }
90 
91   @Provides
92   @Singleton
93   protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
94            @Named(PROPERTY_SESSION_INTERVAL) long seconds, final AWSRegionAndNameToImageSupplier supplier) {
95      return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Cache<RegionAndName, ? extends Image>>(
96               authException, seconds, new Supplier<Cache<RegionAndName, ? extends Image>>() {
97                  @Override
98                  public Cache<RegionAndName, ? extends Image> get() {
99                     return supplier.get();
100                  }
101               });
102   }
103 
104   @Override
105   protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
106      return template.osFamily(AMZN_LINUX).os64Bit(true);
107   }
108 
109   /**
110    * With amazon linux 2011.09, ssh starts after package updates, which slows the boot process and
111    * runs us out of ssh retries (context property {@code "jclouds.ssh.max-retries"}).
112    * 
113    * @see <a href="http://aws.amazon.com/amazon-linux-ami/latest-release-notes/" />
114    * @see AWSEC2PropertiesBuilder#defaultProperties
115    */
116   @Override
117   protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
118      return options.as(EC2TemplateOptions.class).userData("#cloud-config\nrepo_upgrade: none\n".getBytes());
119   }
120}

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