EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.compute.config]

COVERAGE SUMMARY FOR SOURCE FILE [ComputeServiceTimeoutsModule.java]

nameclass, %method, %block, %line, %
ComputeServiceTimeoutsModule.java100% (1/1)83%  (5/6)65%  (40/62)76%  (4.6/6)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComputeServiceTimeoutsModule100% (1/1)83%  (5/6)65%  (40/62)76%  (4.6/6)
runScriptRunning (ScriptStatusReturnsZero, ComputeServiceConstants$Timeouts):... 0%   (0/1)0%   (0/16)0%   (0/1)
nodeRunning (NodeRunning, ComputeServiceConstants$Timeouts): Predicate 100% (1/1)86%  (12/14)85%  (0.8/1)
serverSuspended (NodeSuspended, ComputeServiceConstants$Timeouts): Predicate 100% (1/1)86%  (12/14)85%  (0.8/1)
serverTerminated (NodeTerminated, ComputeServiceConstants$Timeouts): Predicate 100% (1/1)86%  (12/14)85%  (0.8/1)
ComputeServiceTimeoutsModule (): void 100% (1/1)100% (3/3)100% (1/1)
configure (): void 100% (1/1)100% (1/1)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.compute.config;
20 
21import static com.google.common.base.Predicates.not;
22 
23import javax.inject.Named;
24import javax.inject.Singleton;
25 
26import org.jclouds.compute.domain.NodeMetadata;
27import org.jclouds.compute.predicates.NodeRunning;
28import org.jclouds.compute.predicates.NodeSuspended;
29import org.jclouds.compute.predicates.NodeTerminated;
30import org.jclouds.compute.predicates.ScriptStatusReturnsZero;
31import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient;
32import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
33import org.jclouds.predicates.RetryablePredicate;
34 
35import com.google.common.base.Predicate;
36import com.google.inject.AbstractModule;
37import com.google.inject.Provides;
38 
39/**
40 * 
41 * @author Adrian Cole
42 * 
43 */
44public class ComputeServiceTimeoutsModule extends AbstractModule {
45 
46   @Provides
47   @Singleton
48   @Named("NODE_RUNNING")
49   protected Predicate<NodeMetadata> nodeRunning(NodeRunning stateRunning, Timeouts timeouts) {
50      return timeouts.nodeRunning == 0 ? stateRunning : new RetryablePredicate<NodeMetadata>(stateRunning,
51            timeouts.nodeRunning);
52   }
53 
54   @Provides
55   @Singleton
56   @Named("NODE_TERMINATED")
57   protected Predicate<NodeMetadata> serverTerminated(NodeTerminated stateTerminated, Timeouts timeouts) {
58      return timeouts.nodeTerminated == 0 ? stateTerminated : new RetryablePredicate<NodeMetadata>(stateTerminated,
59            timeouts.nodeTerminated);
60   }
61   
62 
63   @Provides
64   @Singleton
65   @Named("NODE_SUSPENDED")
66   protected Predicate<NodeMetadata> serverSuspended(NodeSuspended stateSuspended, Timeouts timeouts) {
67      return timeouts.nodeSuspended == 0 ? stateSuspended : new RetryablePredicate<NodeMetadata>(stateSuspended,
68            timeouts.nodeSuspended);
69   }
70 
71   @Provides
72   @Singleton
73   @Named("SCRIPT_COMPLETE")
74   protected Predicate<CommandUsingClient> runScriptRunning(ScriptStatusReturnsZero stateRunning, Timeouts timeouts) {
75      return timeouts.scriptComplete == 0 ? not(stateRunning) : new RetryablePredicate<CommandUsingClient>(
76            not(stateRunning), timeouts.scriptComplete);
77   }
78 
79   @Override
80   protected void configure() {
81 
82   }
83}

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