1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  package org.jclouds.compute;
20  
21  import static org.jclouds.compute.util.ComputeServiceUtils.createExecutionErrorMessage;
22  import static org.jclouds.compute.util.ComputeServiceUtils.createNodeErrorMessage;
23  
24  import java.util.Map;
25  import java.util.Set;
26  
27  import org.jclouds.compute.domain.NodeMetadata;
28  import org.jclouds.compute.domain.Template;
29  
30  
31  
32  
33  
34  public class RunNodesException extends Exception {
35  
36     
37     private static final long serialVersionUID = -2272965726680821281L;
38     private final String tag;
39     private final int count;
40     private final Template template;
41     private final Set<? extends NodeMetadata> successfulNodes;
42     private final Map<? extends NodeMetadata, ? extends Throwable> failedNodes;
43     private final Map<?, Exception> executionExceptions;
44  
45     public RunNodesException(String tag, int count, Template template,
46              Set<? extends NodeMetadata> successfulNodes, Map<?, Exception> executionExceptions,
47              Map<? extends NodeMetadata, ? extends Throwable> failedNodes) {
48        super(
49                 String
50                          .format(
51                                   "error running %d node%s tag(%s) location(%s) image(%s) size(%s) options(%s)%n%s%n%s",
52                                   count, count > 1 ? "s" : "", tag, template.getLocation().getId(),
53                                   template.getImage().getProviderId(), template.getHardware()
54                                            .getProviderId(), template.getOptions(),
55                                   createExecutionErrorMessage(executionExceptions),
56                                   createNodeErrorMessage(failedNodes)));
57        this.tag = tag;
58        this.count = count;
59        this.template = template;
60        this.successfulNodes = successfulNodes;
61        this.failedNodes = failedNodes;
62        this.executionExceptions = executionExceptions;
63     }
64  
65     
66  
67  
68  
69     public Set<? extends NodeMetadata> getSuccessfulNodes() {
70        return successfulNodes;
71     }
72  
73     
74  
75  
76  
77     public Map<?, ? extends Throwable> getExecutionErrors() {
78        return executionExceptions;
79     }
80  
81     
82  
83  
84  
85     public Map<? extends NodeMetadata, ? extends Throwable> getNodeErrors() {
86        return failedNodes;
87     }
88  
89     public String getTag() {
90        return tag;
91     }
92  
93     public int getCount() {
94        return count;
95     }
96  
97     public Template getTemplate() {
98        return template;
99     }
100 
101 }