1 | package de.uka.ipd.sdq.codegen.simucontroller.runconfig; |
2 | |
3 | import java.util.List; |
4 | import java.util.Map; |
5 | |
6 | import org.apache.log4j.Logger; |
7 | |
8 | import de.uka.ipd.sdq.simucomframework.SimuComConfig; |
9 | import de.uka.ipd.sdq.simulation.AbstractSimulationConfig; |
10 | import de.uka.ipd.sdq.workflow.pcm.runconfig.AccuracyInfluenceAnalysisState; |
11 | import de.uka.ipd.sdq.workflow.pcm.runconfig.ExperimentRunDescriptor; |
12 | import de.uka.ipd.sdq.workflow.pcm.runconfig.SensitivityAnalysisConfiguration; |
13 | |
14 | /** |
15 | */ |
16 | public class SimuComWorkflowConfiguration extends AbstractSimulationWorkflowConfiguration { |
17 | /** Logger for this class. */ |
18 | private static final Logger logger = Logger.getLogger(SimuComWorkflowConfiguration.class); |
19 | |
20 | private SimuComConfig simuComConfig = null; |
21 | |
22 | private boolean simulateFailures; |
23 | |
24 | |
25 | /** |
26 | * Constructor requiring to set the ILaunchConfiguration and mode this configuration is running in. |
27 | * This is necessary to realize the extendability of the simucom workflow with additional jobs |
28 | * using the extension points provided by the palladio workflow engine. |
29 | * |
30 | * @param launchConfiguration The launch configuration object to be provided to the extending jobs. |
31 | * @param mode The mode of the workflow currently runs in (run/debug) |
32 | */ |
33 | public SimuComWorkflowConfiguration(Map<String, Object> attributes) { |
34 | super(attributes); |
35 | } |
36 | |
37 | |
38 | |
39 | public AbstractSimulationConfig getSimulationConfiguration() { |
40 | return simuComConfig; |
41 | } |
42 | |
43 | public void setSimuComConfiguration(SimuComConfig simuComConfig) { |
44 | checkFixed(); |
45 | this.simuComConfig = simuComConfig; |
46 | this.simulateFailures = simuComConfig.getSimulateFailures(); |
47 | this.setSimulateLinkingResources(simuComConfig.getSimulateLinkingResources()); |
48 | } |
49 | |
50 | @Override |
51 | public void setAccuracyInfluenceAnalysisState( |
52 | AccuracyInfluenceAnalysisState accuracyInfluenceAnalysisState) { |
53 | super.setAccuracyInfluenceAnalysisState(accuracyInfluenceAnalysisState); |
54 | if (isAccuracyInfluenceAnalysisEnabled()) { |
55 | simuComConfig.setAdditionalExperimentRunDescription(" (" + getAccuracyInfluenceAnalysisState() + ")"); |
56 | } |
57 | } |
58 | |
59 | public boolean getSimulateFailures() { |
60 | return simulateFailures; |
61 | } |
62 | |
63 | public void setSimulateFailures(boolean simulateFailures) { |
64 | checkFixed(); |
65 | this.simulateFailures = simulateFailures; |
66 | } |
67 | |
68 | public String getErrorMessage() { |
69 | // must be null; otherwise a non-empty error message will result in |
70 | // a workflow config being considered invalid |
71 | return null; |
72 | } |
73 | |
74 | public void setDefaults() { |
75 | throw new RuntimeException("Not implemented. No defaults defined."); |
76 | } |
77 | |
78 | public SimuComWorkflowConfiguration copy( |
79 | List<SensitivityAnalysisConfiguration> sconfList) { |
80 | SimuComWorkflowConfiguration result; |
81 | try { |
82 | result = (SimuComWorkflowConfiguration) clone(); |
83 | } catch (CloneNotSupportedException e) { |
84 | logger.fatal("Could not clone configuration.", e); |
85 | result = null; |
86 | } |
87 | |
88 | String name = this.simuComConfig.getNameBase(); |
89 | ExperimentRunDescriptor descriptor = new ExperimentRunDescriptor(name, |
90 | sconfList); |
91 | result.simuComConfig = this.simuComConfig.copy(descriptor); |
92 | result.sensitivityAnalysisConfigurationList = sconfList; |
93 | return result; |
94 | } |
95 | |
96 | @Override |
97 | protected Object clone() throws CloneNotSupportedException { |
98 | SimuComWorkflowConfiguration config = (SimuComWorkflowConfiguration) super.clone(); |
99 | config.setFeatureConfigFile(this.getFeatureConfigFile()); |
100 | config.simuComConfig = this.simuComConfig.getClone(); |
101 | config.simulateFailures = this.simulateFailures; |
102 | config.setSimulateLinkingResources(this.getSimulateLinkingResources()); |
103 | return config; |
104 | } |
105 | |
106 | /** |
107 | * @return A clone of this instance. |
108 | */ |
109 | public SimuComWorkflowConfiguration getClone() { |
110 | SimuComWorkflowConfiguration config; |
111 | try { |
112 | config = (SimuComWorkflowConfiguration) this.clone(); |
113 | } catch (CloneNotSupportedException e) { |
114 | logger.fatal("Could not clone configuration.", e); |
115 | config = null; |
116 | } |
117 | return config; |
118 | } |
119 | |
120 | } |