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

COVERAGE SUMMARY FOR SOURCE FILE [RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java]

nameclass, %method, %block, %line, %
RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.java0%   (0/1)0%   (0/4)0%   (0/70)0%   (0/12)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete0%   (0/1)0%   (0/4)0%   (0/70)0%   (0/12)
RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete (BlockUntilInitScrip... 0%   (0/1)0%   (0/20)0%   (0/4)
doCall (): ExecResponse 0%   (0/1)0%   (0/14)0%   (0/4)
future (): BlockUntilInitScriptStatusIsZeroThenReturnOutput 0%   (0/1)0%   (0/30)0%   (0/3)
init (): RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete 0%   (0/1)0%   (0/6)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.compute.callables;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23 
24import java.util.concurrent.TimeUnit;
25 
26import javax.inject.Inject;
27 
28import org.jclouds.compute.domain.ExecResponse;
29import org.jclouds.compute.domain.NodeMetadata;
30import org.jclouds.compute.options.RunScriptOptions;
31import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
32import org.jclouds.scriptbuilder.domain.Statement;
33import org.jclouds.ssh.SshClient;
34 
35import com.google.common.base.Function;
36import com.google.common.base.Throwables;
37import com.google.inject.assistedinject.Assisted;
38 
39/**
40 * 
41 * @author Adrian Cole
42 */
43public class RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete extends RunScriptOnNodeAsInitScriptUsingSsh {
44   protected final Timeouts timeouts;
45   protected final BlockUntilInitScriptStatusIsZeroThenReturnOutput.Factory statusFactory;
46 
47   @Inject
48   public RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete(
49            BlockUntilInitScriptStatusIsZeroThenReturnOutput.Factory statusFactory, Timeouts timeouts,
50            Function<NodeMetadata, SshClient> sshFactory, InitScriptConfigurationForTasks initScriptConfiguration,
51            @Assisted NodeMetadata node, @Assisted Statement script, @Assisted RunScriptOptions options) {
52      super(sshFactory, initScriptConfiguration, node, script, options);
53      this.statusFactory = checkNotNull(statusFactory, "statusFactory");
54      this.timeouts = checkNotNull(timeouts, "timeouts");
55   }
56 
57   @Override
58   public ExecResponse doCall() {
59      try {
60         return future().get(timeouts.scriptComplete, TimeUnit.MILLISECONDS);
61      } catch (Exception e) {
62         Throwables.propagate(e);
63         return null;
64      }
65   }
66 
67   public BlockUntilInitScriptStatusIsZeroThenReturnOutput future() {
68      ExecResponse returnVal = super.doCall();
69      checkState(returnVal.getExitCode() == 0, String.format("task: %s had non-zero exit status: %s", init
70               .getInstanceName(), returnVal));
71      return statusFactory.create(this).init();
72   }
73 
74   @Override
75   public RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete init() {
76      return RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete.class.cast(super.init());
77   }
78}

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