| 1 | package de.uka.ipd.sdq.codegen.simucontroller.workflow.jobs; |
| 2 | |
| 3 | import org.eclipse.core.runtime.CoreException; |
| 4 | |
| 5 | import de.fzi.se.accuracy.jobs.TransformPCMForAccuracyInfluenceAnalysisJob; |
| 6 | import de.uka.ipd.sdq.cip.workflow.jobs.CompletionJob; |
| 7 | import de.uka.ipd.sdq.codegen.simucontroller.debug.IDebugListener; |
| 8 | import de.uka.ipd.sdq.codegen.simucontroller.runconfig.AbstractSimulationWorkflowConfiguration; |
| 9 | import de.uka.ipd.sdq.pcm.transformations.ApplyConnectorCompletionsJob; |
| 10 | import de.uka.ipd.sdq.workflow.launchconfig.extension.AbstractExtendableJob; |
| 11 | import de.uka.ipd.sdq.workflow.mdsd.blackboard.MDSDBlackboard; |
| 12 | import de.uka.ipd.sdq.workflow.pcm.jobs.EventsTransformationJob; |
| 13 | import de.uka.ipd.sdq.workflow.pcm.jobs.LoadMiddlewareConfigurationIntoBlackboardJob; |
| 14 | import de.uka.ipd.sdq.workflow.pcm.jobs.LoadPCMModelsIntoBlackboardJob; |
| 15 | import de.uka.ipd.sdq.workflow.pcm.jobs.StoreAllPCMModelsJob; |
| 16 | import de.uka.ipd.sdq.workflow.pcm.jobs.ValidatePCMModelsJob; |
| 17 | |
| 18 | /** |
| 19 | * Abstract job for launching a Palladio simulation. Each concrete simulator provides an |
| 20 | * implementation of this class. |
| 21 | * |
| 22 | * @author Steffen |
| 23 | * @author Philipp Merkle |
| 24 | * |
| 25 | */ |
| 26 | public abstract class AbstractSimulationJob<C extends AbstractSimulationWorkflowConfiguration> extends AbstractExtendableJob<MDSDBlackboard> { |
| 27 | |
| 28 | protected IDebugListener debugListener = null; |
| 29 | |
| 30 | public AbstractSimulationJob(C configuration, IDebugListener listener) throws CoreException { |
| 31 | this(configuration, listener, true); |
| 32 | |
| 33 | } |
| 34 | |
| 35 | public AbstractSimulationJob(C configuration) throws CoreException { |
| 36 | this(configuration,null); |
| 37 | } |
| 38 | |
| 39 | public AbstractSimulationJob(C configuration, IDebugListener listener, boolean loadModels) throws CoreException { |
| 40 | super(); |
| 41 | |
| 42 | if (listener == null && configuration.isDebug()) |
| 43 | throw new IllegalArgumentException("Debug listener has to be non-null for debug runs"); |
| 44 | this.debugListener = listener; |
| 45 | |
| 46 | // Stage Preparation |
| 47 | // 1. Load PCM Models into memory |
| 48 | if (loadModels == true) { |
| 49 | this.addJob(new LoadPCMModelsIntoBlackboardJob(configuration)); |
| 50 | } |
| 51 | this.addJob(new LoadMiddlewareConfigurationIntoBlackboardJob(configuration)); |
| 52 | |
| 53 | // 2. Validate PCM Models |
| 54 | this.addJob(new ValidatePCMModelsJob(configuration)); |
| 55 | |
| 56 | handleJobExtensions(WorkflowHooks.WORKFLOW_ID_AFTER_LOAD_VALIDATE,configuration); |
| 57 | |
| 58 | // -- Stage Model modification |
| 59 | // 3.1 Modification for AccuracyInfluenceAnalysis |
| 60 | if (configuration.isAccuracyInfluenceAnalysisEnabled()) { |
| 61 | this.add(new TransformPCMForAccuracyInfluenceAnalysisJob(configuration)); |
| 62 | } |
| 63 | |
| 64 | // 3.2 Modifications for SensitivityAnalysis |
| 65 | if(configuration.isSensitivityAnalysisEnabled()){ |
| 66 | this.add(new TransformPCMForSensitivityAnalysisJob(configuration)); |
| 67 | } |
| 68 | |
| 69 | // 4. Apply Completions |
| 70 | this.add(new CompletionJob(configuration)); |
| 71 | |
| 72 | // 5. Transform Event Model Elements |
| 73 | this.add(new EventsTransformationJob(configuration)); |
| 74 | |
| 75 | // 6. Apply connector completion transformation |
| 76 | if (configuration.getSimulateLinkingResources()) { |
| 77 | this.addJob(new ApplyConnectorCompletionsJob(configuration)); |
| 78 | } |
| 79 | |
| 80 | // -- Stage analysis |
| 81 | // 7. Store resulting model(s) |
| 82 | this.add(new StoreAllPCMModelsJob(configuration)); |
| 83 | |
| 84 | this.addSimulatorSpecificJobs(configuration); |
| 85 | } |
| 86 | |
| 87 | protected abstract void addSimulatorSpecificJobs(C configuration); |
| 88 | |
| 89 | } |