EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.cloudsigma.compute.config]

COVERAGE SUMMARY FOR SOURCE FILE [CloudSigmaComputeServiceContextModule.java]

nameclass, %method, %block, %line, %
CloudSigmaComputeServiceContextModule.java92%  (11/12)71%  (12/17)81%  (158/195)67%  (14/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CloudSigmaComputeServiceContextModule$GetDrive0%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
CloudSigmaComputeServiceContextModule$GetDrive (CloudSigmaClient): void 0%   (0/1)0%   (0/6)0%   (0/3)
apply (String): DriveInfo 0%   (0/1)0%   (0/5)0%   (0/1)
     
class CloudSigmaComputeServiceContextModule100% (1/1)40%  (2/5)79%  (98/124)82%  (14/17)
cache (CloudSigmaComputeServiceContextModule$GetDrive): Map 0%   (0/1)0%   (0/6)0%   (0/1)
provideTemplate (Injector, TemplateBuilder): TemplateBuilder 0%   (0/1)0%   (0/10)0%   (0/1)
supplyDriveUnclaimed (DriveClaimed, ComputeServiceConstants$Timeouts): Predicate 0%   (0/1)0%   (0/10)0%   (0/1)
CloudSigmaComputeServiceContextModule (): void 100% (1/1)100% (5/5)100% (2/2)
configure (): void 100% (1/1)100% (93/93)100% (12/12)
     
class CloudSigmaComputeServiceContextModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$1 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$10100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$10 (CloudSigmaComputeServiceContextModu... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$2 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$3100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$3 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$4100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$4 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$5100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$5 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$6100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$6 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$7100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$7 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$8100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$8 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)
     
class CloudSigmaComputeServiceContextModule$9100% (1/1)100% (1/1)100% (6/6)100% (1/1)
CloudSigmaComputeServiceContextModule$9 (CloudSigmaComputeServiceContextModul... 100% (1/1)100% (6/6)100% (1/1)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.cloudsigma.compute.config;
20 
21import static org.jclouds.compute.domain.OsFamily.UBUNTU;
22 
23import java.util.Map;
24import java.util.concurrent.TimeUnit;
25 
26import javax.inject.Inject;
27import javax.inject.Singleton;
28 
29import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
30import org.jclouds.cloudsigma.CloudSigmaClient;
31import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
32import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName;
33import org.jclouds.cloudsigma.compute.functions.PreinstalledDiskToImage;
34import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata;
35import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume;
36import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.FindImageForId;
37import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer;
38import org.jclouds.cloudsigma.domain.Device;
39import org.jclouds.cloudsigma.domain.DriveInfo;
40import org.jclouds.cloudsigma.domain.Server;
41import org.jclouds.cloudsigma.domain.ServerInfo;
42import org.jclouds.cloudsigma.predicates.DriveClaimed;
43import org.jclouds.compute.ComputeServiceAdapter;
44import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
45import org.jclouds.compute.domain.Hardware;
46import org.jclouds.compute.domain.Image;
47import org.jclouds.compute.domain.NodeMetadata;
48import org.jclouds.compute.domain.OsFamilyVersion64Bit;
49import org.jclouds.compute.domain.TemplateBuilder;
50import org.jclouds.compute.domain.Volume;
51import org.jclouds.compute.reference.ComputeServiceConstants;
52import org.jclouds.domain.Location;
53import org.jclouds.functions.IdentityFunction;
54import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
55import org.jclouds.predicates.RetryablePredicate;
56 
57import com.google.common.base.Function;
58import com.google.common.base.Predicate;
59import com.google.common.base.Predicates;
60import com.google.common.base.Supplier;
61import com.google.common.collect.MapMaker;
62import com.google.inject.Injector;
63import com.google.inject.Provides;
64import com.google.inject.TypeLiteral;
65 
66/**
67 * 
68 * @author Adrian Cole
69 */
70public class CloudSigmaComputeServiceContextModule
71      extends
72      ComputeServiceAdapterContextModule<CloudSigmaClient, CloudSigmaAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
73 
74   public CloudSigmaComputeServiceContextModule() {
75      super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
76   }
77 
78   @Override
79   protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
80      return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true).minRam(1024);
81   }
82 
83   @SuppressWarnings({ "unchecked", "rawtypes" })
84   @Override
85   protected void configure() {
86      super.configure();
87      bind(new TypeLiteral<ComputeServiceAdapter<ServerInfo, Hardware, DriveInfo, Location>>() {
88      }).to(CloudSigmaComputeServiceAdapter.class);
89      bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() {
90      }).to(ServerInfoToNodeMetadata.class);
91      bind(new TypeLiteral<Function<Hardware, Hardware>>() {
92      }).to((Class) IdentityFunction.class);
93      bind(new TypeLiteral<Function<DriveInfo, Image>>() {
94      }).to(PreinstalledDiskToImage.class);
95      bind(new TypeLiteral<Function<Location, Location>>() {
96      }).to((Class) IdentityFunction.class);
97      bind(new TypeLiteral<Function<Device, Volume>>() {
98      }).to(DeviceToVolume.class);
99      bind(new TypeLiteral<Function<Server, String>>() {
100      }).to(GetImageIdFromServer.class);
101      bind(new TypeLiteral<Function<String, Image>>() {
102      }).to(FindImageForId.class);
103      bind(new TypeLiteral<Function<String, OsFamilyVersion64Bit>>() {
104      }).to(ParseOsFamilyVersion64BitFromImageName.class);
105      bind(new TypeLiteral<Supplier<Location>>() {
106      }).to(OnlyLocationOrFirstZone.class);
107   }
108 
109   @Provides
110   @Singleton
111   protected Map<String, DriveInfo> cache(GetDrive getDrive) {
112      return new MapMaker().makeComputingMap(getDrive);
113   }
114 
115   @Singleton
116   public static class GetDrive implements Function<String, DriveInfo> {
117      private final CloudSigmaClient client;
118 
119      @Inject
120      public GetDrive(CloudSigmaClient client) {
121         this.client = client;
122      }
123 
124      @Override
125      public DriveInfo apply(String input) {
126         return client.getDriveInfo(input);
127      }
128   }
129 
130   @Provides
131   @Singleton
132   protected Predicate<DriveInfo> supplyDriveUnclaimed(DriveClaimed driveClaimed,
133         ComputeServiceConstants.Timeouts timeouts) {
134      return new RetryablePredicate<DriveInfo>(Predicates.not(driveClaimed), timeouts.nodeRunning, 1000,
135            TimeUnit.MILLISECONDS);
136   }
137}

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