EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.reliability.solver.sensitivity]

COVERAGE SUMMARY FOR SOURCE FILE [InternalActionSensitivity.java]

nameclass, %method, %block, %line, %
InternalActionSensitivity.java0%   (0/1)0%   (0/5)0%   (0/224)0%   (0/63)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InternalActionSensitivity0%   (0/1)0%   (0/5)0%   (0/224)0%   (0/63)
InternalActionSensitivity (String, String, String, DoubleParameterVariation):... 0%   (0/1)0%   (0/14)0%   (0/5)
alterModel (): boolean 0%   (0/1)0%   (0/19)0%   (0/6)
extractSensitivityInformation (): void 0%   (0/1)0%   (0/117)0%   (0/30)
getLogHeadingsMulti (): List 0%   (0/1)0%   (0/34)0%   (0/9)
getLogSingleResultsMulti (): List 0%   (0/1)0%   (0/40)0%   (0/13)

1package de.uka.ipd.sdq.reliability.solver.sensitivity;
2 
3import java.util.ArrayList;
4import java.util.List;
5 
6import org.eclipse.emf.common.util.EList;
7import org.eclipse.emf.ecore.EObject;
8 
9import de.uka.ipd.sdq.pcm.reliability.InternalFailureOccurrenceDescription;
10import de.uka.ipd.sdq.pcm.repository.Repository;
11import de.uka.ipd.sdq.pcm.seff.InternalAction;
12import de.uka.ipd.sdq.pcm.seff.SeffFactory;
13import de.uka.ipd.sdq.sensitivity.DoubleParameterVariation;
14 
15/**
16 * This class provides rudimentary support for sensitivity analysis of an
17 * internal action failure probability.
18 * 
19 * Further refactorings required.
20 * 
21 * @author brosch
22 * 
23 */
24public class InternalActionSensitivity extends MarkovSensitivity {
25 
26        /**
27         * The base value of this sensitivity.
28         */
29        private double baseValue;
30 
31        /**
32         * The affected internal failure occurrence description.
33         */
34        private InternalFailureOccurrenceDescription description = null;
35 
36        /**
37         * The ID of the failure type.
38         */
39        private String failureTypeId;
40 
41        /**
42         * The ID of the internal action to alter.
43         */
44        private String internalActionId;
45 
46        /**
47         * The constructor.
48         * 
49         * @param name
50         *            the name of the sensitivity analysis
51         * @param internalActionId
52         *            the id of the internal action to alter
53         * @param failureTypeId
54         *            the id of the failure type to alter
55         * @param variation
56         *            the parameter variation
57         */
58        public InternalActionSensitivity(final String name,
59                        final String internalActionId, final String failureTypeId,
60                        final DoubleParameterVariation variation) {
61 
62                // Initialize base variables:
63                super(name, variation);
64 
65                // Further initialization:
66                this.internalActionId = internalActionId;
67                this.failureTypeId = failureTypeId;
68        }
69 
70        /**
71         * Alters the model according to the next sensitivity analysis step.
72         * 
73         * @return indicates if the model could be successfully altered
74         */
75        protected boolean alterModel() {
76 
77                // Check validity:
78                if (description == null) {
79                        return false;
80                }
81 
82                // Set the failure probability:
83                description.setFailureProbability(calculator
84                                .calculateCurrentDoubleValue(getDoubleVariation(),
85                                                getCurrentStepNumber(), baseValue));
86 
87                // Everything ok:
88                return true;
89        }
90 
91        /**
92         * Extracts the relevant sensitivity information from the given model.
93         */
94        protected void extractSensitivityInformation() {
95 
96                // Retrieve all FailureOccurrenceDescriptions in the PCM Repository:
97                List<Repository> repositories = getModel().getRepositories();
98                if (repositories.size() == 0) {
99                        // No repository found!
100                        logger.error("No PCM Repositories found.");
101                        return;
102                }
103 
104                // Search for the relevant internal action:
105                InternalAction internalAction = null;
106                for (Repository repository : repositories) {
107                        EList<EObject> internalActions = helper.getElements(repository,
108                                        SeffFactory.eINSTANCE.createInternalAction().eClass());
109                        for (EObject action : internalActions) {
110                                if (((InternalAction) action).getId().equals(internalActionId)) {
111                                        internalAction = (InternalAction) action;
112                                        break;
113                                }
114                        }
115                        if (internalAction != null) {
116                                break;
117                        }
118                }
119                if (internalAction == null) {
120                        // No corresponding internal action found!
121                        logger.error("Did not find any InternalAction with ID \""
122                                        + internalActionId + "\"");
123                        return;
124                }
125 
126                // Search for the relevant failure occurrence description:
127                for (InternalFailureOccurrenceDescription occurrenceDescription : internalAction
128                                .getInternalFailureOccurrenceDescriptions__InternalAction()) {
129                        if (occurrenceDescription
130                                        .getSoftwareInducedFailureType__InternalFailureOccurrenceDescription()
131                                        .getId().equals(failureTypeId)) {
132                                description = occurrenceDescription;
133                                baseValue = occurrenceDescription.getFailureProbability();
134                        }
135                }
136                if (description == null) {
137                        logger
138                                        .error("Did not find a FailureOccurrenceDescription for FailureType with ID \""
139                                                        + failureTypeId + "\"");
140                }
141        }
142 
143        /**
144         * Builds the headings strings for logging.
145         * 
146         * @return the log headings strings
147         */
148        protected List<List<String>> getLogHeadingsMulti() {
149 
150                // Create a result list:
151                List<List<String>> resultList = new ArrayList<List<String>>();
152 
153                // Create the headings:
154                ArrayList<String> headings = new ArrayList<String>();
155                headings.add("Internal Action Name");
156                headings.add("Internal Action ID");
157                headings.add("Failure Type Name");
158                headings.add("Failure Type ID");
159                headings.add("Failure Probability");
160                resultList.add(headings);
161 
162                // Return the result:
163                return resultList;
164        }
165 
166        /**
167         * Builds the results strings for sensitivity logging.
168         * 
169         * @return the results strings
170         */
171        protected List<String> getLogSingleResultsMulti() {
172 
173                // Create a result list:
174                List<String> resultList = new ArrayList<String>();
175 
176                // Create the result strings:
177                resultList.add(description
178                                .getInternalAction__InternalFailureOccurrenceDescription()
179                                .getEntityName());
180                resultList.add(internalActionId);
181                resultList
182                                .add(description
183                                                .getSoftwareInducedFailureType__InternalFailureOccurrenceDescription()
184                                                .getEntityName());
185                resultList.add(failureTypeId);
186                resultList.add(calculator.getCurrentLogEntry(getDoubleVariation(),
187                                getCurrentStepNumber()));
188 
189                // Return the result:
190                return resultList;
191        }
192}

[all classes][de.uka.ipd.sdq.reliability.solver.sensitivity]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov