1 | package de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs; |
2 | |
3 | import org.eclipse.core.runtime.IProgressMonitor; |
4 | |
5 | import de.uka.ipd.sdq.codegen.simucontroller.runconfig.SimuComWorkflowConfiguration; |
6 | import de.uka.ipd.sdq.reliability.core.FailureStatistics; |
7 | import de.uka.ipd.sdq.reliability.core.MarkovEvaluationType; |
8 | import de.uka.ipd.sdq.reliability.core.helper.MarkovFailureTypeHelper; |
9 | import de.uka.ipd.sdq.workflow.IBlackboardInteractingJob; |
10 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
11 | import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException; |
12 | import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException; |
13 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
14 | import de.uka.ipd.sdq.workflow.pcm.blackboard.PCMResourceSetPartition; |
15 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractPCMWorkflowRunConfiguration; |
16 | import de.uka.ipd.sdq.workflow.pcm.jobs.LoadPCMModelsIntoBlackboardJob; |
17 | |
18 | /** |
19 | * Represents a step where the types of all possible failure-on-demand |
20 | * occurrences during the simulation are determined. |
21 | * |
22 | * @author brosch |
23 | * |
24 | */ |
25 | public class DetermineFailureTypesJob implements |
26 | IBlackboardInteractingJob<MDSDBlackboard> { |
27 | |
28 | /** |
29 | * The blackboard where the PCM model resides. |
30 | */ |
31 | private MDSDBlackboard blackboard; |
32 | |
33 | /** |
34 | * The configuration of the workflow. |
35 | */ |
36 | private AbstractPCMWorkflowRunConfiguration configuration = null; |
37 | |
38 | /** |
39 | * Provides functionality for managing failure types. |
40 | */ |
41 | private MarkovFailureTypeHelper helper = new MarkovFailureTypeHelper(); |
42 | |
43 | /** |
44 | * The constructor. |
45 | * |
46 | * @param configuration |
47 | * the configuration of the workflow |
48 | */ |
49 | public DetermineFailureTypesJob( |
50 | AbstractPCMWorkflowRunConfiguration configuration) { |
51 | super(); |
52 | this.configuration = configuration; |
53 | } |
54 | |
55 | /* |
56 | * (non-Javadoc) |
57 | * |
58 | * @seede.uka.ipd.sdq.workflow.IJob#execute(org.eclipse.core.runtime. |
59 | * IProgressMonitor) |
60 | */ |
61 | public void execute(final IProgressMonitor monitor) |
62 | throws JobFailedException, UserCanceledException { |
63 | |
64 | // Check for the "simulate failures" option: |
65 | SimuComWorkflowConfiguration config = (SimuComWorkflowConfiguration) configuration; |
66 | if (!config.getSimulateFailures()) { |
67 | return; |
68 | } |
69 | |
70 | // Retrieve the PCM models that are already loaded into memory: |
71 | PCMResourceSetPartition pcmPartition = (PCMResourceSetPartition) this.blackboard |
72 | .getPartition(LoadPCMModelsIntoBlackboardJob.PCM_MODELS_PARTITION_ID); |
73 | |
74 | // Derive the failure types for the simulation: |
75 | FailureStatistics.getInstance().setFailureTypes( |
76 | helper.getFailureTypes(MarkovEvaluationType.POINTSOFFAILURE, |
77 | pcmPartition.getRepositories(), pcmPartition |
78 | .getResourceEnvironment(), pcmPartition |
79 | .getSystem())); |
80 | } |
81 | |
82 | /* |
83 | * (non-Javadoc) |
84 | * |
85 | * @see de.uka.ipd.sdq.workflow.IJob#getName() |
86 | */ |
87 | public String getName() { |
88 | return "Perform Failure Types Determination"; |
89 | } |
90 | |
91 | /* |
92 | * (non-Javadoc) |
93 | * |
94 | * @seede.uka.ipd.sdq.workflow.IJob#rollback(org.eclipse.core.runtime. |
95 | * IProgressMonitor) |
96 | */ |
97 | public void rollback(IProgressMonitor monitor) |
98 | throws RollbackFailedException { |
99 | } |
100 | |
101 | /* |
102 | * (non-Javadoc) |
103 | * |
104 | * @see |
105 | * de.uka.ipd.sdq.workflow.IBlackboardInteractingJob#setBlackboard(de.uka |
106 | * .ipd.sdq.workflow.Blackboard) |
107 | */ |
108 | public void setBlackboard(final MDSDBlackboard blackboard) { |
109 | this.blackboard = blackboard; |
110 | } |
111 | } |