EMMA Coverage Report (generated Mon Oct 17 05:41:20 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)84%  (158/189)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)
load (String): DriveInfo 0%   (0/1)0%   (0/5)0%   (0/1)
     
class CloudSigmaComputeServiceContextModule100% (1/1)40%  (2/5)83%  (98/118)82%  (14/17)
cache (CloudSigmaComputeServiceContextModule$GetDrive): Cache 0%   (0/1)0%   (0/4)0%   (0/1)
provideTemplate (Injector, TemplateBuilder): TemplateBuilder 0%   (0/1)0%   (0/6)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 * 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.cloudsigma.compute.config;
20 
21import java.util.concurrent.TimeUnit;
22 
23import javax.inject.Inject;
24import javax.inject.Singleton;
25 
26import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
27import org.jclouds.cloudsigma.CloudSigmaClient;
28import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
29import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName;
30import org.jclouds.cloudsigma.compute.functions.PreinstalledDiskToImage;
31import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata;
32import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume;
33import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.FindImageForId;
34import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer;
35import org.jclouds.cloudsigma.domain.Device;
36import org.jclouds.cloudsigma.domain.DriveInfo;
37import org.jclouds.cloudsigma.domain.Server;
38import org.jclouds.cloudsigma.domain.ServerInfo;
39import org.jclouds.cloudsigma.predicates.DriveClaimed;
40import org.jclouds.compute.ComputeServiceAdapter;
41import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
42import org.jclouds.compute.domain.Hardware;
43import org.jclouds.compute.domain.Image;
44import org.jclouds.compute.domain.NodeMetadata;
45import org.jclouds.compute.domain.OsFamily;
46import org.jclouds.compute.domain.OsFamilyVersion64Bit;
47import org.jclouds.compute.domain.TemplateBuilder;
48import org.jclouds.compute.domain.Volume;
49import org.jclouds.compute.reference.ComputeServiceConstants;
50import org.jclouds.domain.Location;
51import org.jclouds.functions.IdentityFunction;
52import org.jclouds.location.suppliers.OnlyLocationOrFirstZone;
53import org.jclouds.predicates.RetryablePredicate;
54 
55import com.google.common.base.Function;
56import com.google.common.base.Predicate;
57import com.google.common.base.Predicates;
58import com.google.common.base.Supplier;
59import com.google.common.cache.Cache;
60import com.google.common.cache.CacheBuilder;
61import com.google.common.cache.CacheLoader;
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(OsFamily.UBUNTU).imageNameMatches(".*automated SSH Access.*");
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 Cache<String, DriveInfo> cache(GetDrive getDrive) {
112      return CacheBuilder.newBuilder().build(getDrive);
113   }
114 
115   @Singleton
116   public static class GetDrive extends CacheLoader<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 load(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