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

COVERAGE SUMMARY FOR SOURCE FILE [RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java]

nameclass, %method, %block, %line, %
RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap.java0%   (0/1)0%   (0/3)0%   (0/141)0%   (0/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap0%   (0/1)0%   (0/3)0%   (0/141)0%   (0/19)
RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap (RunScriptOnNode, Map,... 0%   (0/1)0%   (0/24)0%   (0/6)
call (): ExecResponse 0%   (0/1)0%   (0/101)0%   (0/12)
toString (): String 0%   (0/1)0%   (0/16)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.strategy;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static com.google.common.base.Preconditions.checkState;
23import static com.google.common.base.Throwables.getRootCause;
24 
25import java.util.Map;
26import java.util.concurrent.Callable;
27 
28import javax.annotation.Resource;
29import javax.inject.Named;
30 
31import org.jclouds.compute.callables.RunScriptOnNode;
32import org.jclouds.compute.domain.ExecResponse;
33import org.jclouds.compute.domain.NodeMetadata;
34import org.jclouds.compute.reference.ComputeServiceConstants;
35import org.jclouds.logging.Logger;
36 
37import com.google.common.base.Objects;
38import com.google.inject.assistedinject.AssistedInject;
39 
40/**
41 * 
42 * @author Adrian Cole
43 */
44public class RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap implements Callable<ExecResponse> {
45 
46   @Resource
47   @Named(ComputeServiceConstants.COMPUTE_LOGGER)
48   protected Logger logger = Logger.NULL;
49   private final RunScriptOnNode runScriptOnNode;
50   private final Map<NodeMetadata, Exception> badNodes;
51   private final Map<NodeMetadata, ExecResponse> goodNodes;
52 
53   private transient boolean tainted;
54 
55   @AssistedInject
56   public RunScriptOnNodeAndAddToGoodMapOrPutExceptionIntoBadMap(RunScriptOnNode runScriptOnNode,
57            Map<NodeMetadata, ExecResponse> goodNodes, Map<NodeMetadata, Exception> badNodes) {
58      this.runScriptOnNode = checkNotNull(runScriptOnNode, "runScriptOnNode");
59      this.badNodes = checkNotNull(badNodes, "badNodes");
60      this.goodNodes = checkNotNull(goodNodes, "goodNodes");
61   }
62 
63   @Override
64   public ExecResponse call() {
65      checkState(runScriptOnNode != null, "runScriptOnNode must be set");
66      checkState(!tainted, "this object is not designed to be reused: %s", toString());
67      tainted = true;
68      try {
69         ExecResponse exec = runScriptOnNode.call();
70         logger.trace("<< script output for node(%s): %s", runScriptOnNode.getNode().getId(), exec);
71         logger.debug("<< options applied node(%s)", runScriptOnNode.getNode().getId());
72         goodNodes.put(runScriptOnNode.getNode(), exec);
73         return exec;
74      } catch (Exception e) {
75         logger.error(e, "<< problem applying options to node(%s): ", runScriptOnNode.getNode().getId(),
76                  getRootCause(e).getMessage());
77         badNodes.put(runScriptOnNode.getNode(), e);
78      }
79      return null;
80   }
81 
82   @Override
83   public String toString() {
84      return Objects.toStringHelper(this).add("runScriptOnNode", runScriptOnNode).add("goodNodes", goodNodes).add(
85               "badNodes", badNodes).toString();
86   }
87 
88}

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