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 [ResourceMTTRSensitivity.java]

nameclass, %method, %block, %line, %
ResourceMTTRSensitivity.java0%   (0/1)0%   (0/5)0%   (0/206)0%   (0/59)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceMTTRSensitivity0%   (0/1)0%   (0/5)0%   (0/206)0%   (0/59)
ResourceMTTRSensitivity (String, String, String, DoubleParameterVariation): void 0%   (0/1)0%   (0/14)0%   (0/5)
alterModel (): boolean 0%   (0/1)0%   (0/19)0%   (0/5)
extractSensitivityInformation (): void 0%   (0/1)0%   (0/99)0%   (0/28)
getLogHeadingsMulti (): List 0%   (0/1)0%   (0/34)0%   (0/9)
getLogSingleResultsMulti (): List 0%   (0/1)0%   (0/40)0%   (0/12)

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.resourceenvironment.ProcessingResourceSpecification;
10import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
11import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceenvironmentFactory;
12import de.uka.ipd.sdq.sensitivity.DoubleParameterVariation;
13 
14/**
15 * This class provides rudimentary support for sensitivity analysis of a
16 * hardware resource MTTR value.
17 * 
18 * @author brosch
19 * 
20 */
21public class ResourceMTTRSensitivity extends MarkovSensitivity {
22 
23        /**
24         * The base value.
25         */
26        private double baseValue;
27 
28        /**
29         * The resource type to alter.
30         */
31        private String processingResourceTypeId;
32 
33        /**
34         * The resource container to alter.
35         */
36        private String resourceContainerId;
37 
38        /**
39         * The affected processing resource specification.
40         */
41        private ProcessingResourceSpecification specification = null;
42 
43        /**
44         * The constructor.
45         * 
46         * @param name
47         *            the name of the sensitivity analysis
48         * @param resourceContainerId
49         *            the resource container to alter
50         * @param processingResourceTypeId
51         *            the resource type to alter
52         * @param variation
53         *            the parameter variation
54         */
55        public ResourceMTTRSensitivity(final String name,
56                        final String resourceContainerId,
57                        final String processingResourceTypeId,
58                        final DoubleParameterVariation variation) {
59 
60                // Initialize basic variables:
61                super(name, variation);
62 
63                // Further initializations:
64                this.resourceContainerId = resourceContainerId;
65                this.processingResourceTypeId = processingResourceTypeId;
66        }
67 
68        /**
69         * Alters the model according to the next sensitivity analysis step.
70         * 
71         * @return indicates if the model could be successfully altered
72         */
73        protected boolean alterModel() {
74 
75                // Check validity:
76                if (specification == null) {
77                        return false;
78                }
79 
80                // Set the failure probability:
81                specification.setMTTR(calculator.calculateCurrentDoubleValue(
82                                getDoubleVariation(), getCurrentStepNumber(), baseValue));
83 
84                // Everything ok:
85                return true;
86        }
87 
88        /**
89         * Extracts the relevant sensitivity information from the given model.
90         */
91        protected void extractSensitivityInformation() {
92 
93                // Retrieve the PCM resource environment:
94                if (getModel().getResourceEnvironment() == null) {
95                        // No resource environment found!
96                        logger.error("No PCM ResourceEnvironment found.");
97                        return;
98                }
99 
100                // Search for the relevant resource container:
101                ResourceContainer resourceContainer = null;
102                EList<EObject> resourceContainers = helper.getElements(getModel()
103                                .getResourceEnvironment(), ResourceenvironmentFactory.eINSTANCE
104                                .createResourceContainer().eClass());
105                for (EObject object : resourceContainers) {
106                        if (((ResourceContainer) object).getId()
107                                        .equals(resourceContainerId)) {
108                                resourceContainer = (ResourceContainer) object;
109                                break;
110                        }
111                }
112                if (resourceContainer == null) {
113                        // No corresponding resource container found!
114                        logger.error("Did not find any ResourceContainer with ID \""
115                                        + resourceContainerId + "\"");
116                        return;
117                }
118 
119                // Search for the relevant processing resource specification:
120                for (ProcessingResourceSpecification resourceSpecification : resourceContainer
121                                .getActiveResourceSpecifications_ResourceContainer()) {
122                        if (resourceSpecification
123                                        .getActiveResourceType_ActiveResourceSpecification()
124                                        .getId().equals(processingResourceTypeId)) {
125                                specification = resourceSpecification;
126                                return;
127                        }
128                }
129                if (specification == null) {
130                        logger
131                                        .error("Did not find any ProcessingResourceSpecification with ID \""
132                                                        + processingResourceTypeId + "\"");
133                }
134        }
135 
136        /**
137         * Builds the headings strings for logging.
138         * 
139         * @return the log headings strings
140         */
141        protected List<List<String>> getLogHeadingsMulti() {
142 
143                // Create a result list:
144                List<List<String>> resultList = new ArrayList<List<String>>();
145 
146                // Create the headings:
147                ArrayList<String> headings = new ArrayList<String>();
148                headings.add("Resource Container Name");
149                headings.add("Resource Container ID");
150                headings.add("Resource Type Name");
151                headings.add("Resourcce Type ID");
152                headings.add("Mean Time To Repair");
153                resultList.add(headings);
154 
155                // Return the result:
156                return resultList;
157        }
158 
159        /**
160         * Builds the results strings for sensitivity logging.
161         * 
162         * @return the results strings
163         */
164        protected List<String> getLogSingleResultsMulti() {
165 
166                // Create a result list:
167                List<String> resultList = new ArrayList<String>();
168 
169                // Create the result strings:
170                resultList.add(specification
171                                .getResourceContainer_ProcessingResourceSpecification()
172                                .getEntityName());
173                resultList.add(resourceContainerId);
174                resultList.add(specification
175                                .getActiveResourceType_ActiveResourceSpecification()
176                                .getEntityName());
177                resultList.add(processingResourceTypeId);
178                resultList.add(calculator.getCurrentLogEntry(getDoubleVariation(),
179                                getCurrentStepNumber()));
180 
181                // Return the result:
182                return resultList;
183        }
184}

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