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

COVERAGE SUMMARY FOR SOURCE FILE [MarkovFailureTypeHelper.java]

nameclass, %method, %block, %line, %
MarkovFailureTypeHelper.java0%   (0/1)0%   (0/8)0%   (0/525)0%   (0/166)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarkovFailureTypeHelper0%   (0/1)0%   (0/8)0%   (0/525)0%   (0/166)
MarkovFailureTypeHelper (): void 0%   (0/1)0%   (0/8)0%   (0/2)
getFailureTypes (MarkovEvaluationType, List, ResourceEnvironment, System): List 0%   (0/1)0%   (0/33)0%   (0/9)
getHardwareFailureTypes (MarkovEvaluationType, ResourceEnvironment, System): ... 0%   (0/1)0%   (0/106)0%   (0/35)
getNetworkFailureTypes (MarkovEvaluationType, ResourceEnvironment, System): List 0%   (0/1)0%   (0/97)0%   (0/35)
getRDSEFF (BasicComponent, OperationSignature): ServiceEffectSpecification 0%   (0/1)0%   (0/23)0%   (0/6)
getResourceTimeoutFailureTypes (MarkovEvaluationType, System): List 0%   (0/1)0%   (0/47)0%   (0/15)
getSoftwareFailureTypes (MarkovEvaluationType, List, System): List 0%   (0/1)0%   (0/186)0%   (0/57)
removeDoubleFailureTypes (List): List 0%   (0/1)0%   (0/25)0%   (0/7)

1package de.uka.ipd.sdq.reliability.core.helper;
2 
3import java.util.ArrayList;
4import java.util.Iterator;
5import java.util.List;
6 
7import org.eclipse.emf.common.util.EList;
8import org.eclipse.emf.ecore.EObject;
9 
10import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext;
11import de.uka.ipd.sdq.pcm.qosannotations.QoSAnnotations;
12import de.uka.ipd.sdq.pcm.qosannotations.SpecifiedQoSAnnotation;
13import de.uka.ipd.sdq.pcm.qosannotations.qos_reliability.SpecifiedReliabilityAnnotation;
14import de.uka.ipd.sdq.pcm.reliability.ExternalFailureOccurrenceDescription;
15import de.uka.ipd.sdq.pcm.reliability.FailureType;
16import de.uka.ipd.sdq.pcm.reliability.HardwareInducedFailureType;
17import de.uka.ipd.sdq.pcm.reliability.InternalFailureOccurrenceDescription;
18import de.uka.ipd.sdq.pcm.reliability.NetworkInducedFailureType;
19import de.uka.ipd.sdq.pcm.reliability.SoftwareInducedFailureType;
20import de.uka.ipd.sdq.pcm.repository.BasicComponent;
21import de.uka.ipd.sdq.pcm.repository.OperationInterface;
22import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
23import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole;
24import de.uka.ipd.sdq.pcm.repository.OperationSignature;
25import de.uka.ipd.sdq.pcm.repository.PassiveResource;
26import de.uka.ipd.sdq.pcm.repository.ProvidedRole;
27import de.uka.ipd.sdq.pcm.repository.Repository;
28import de.uka.ipd.sdq.pcm.repository.RepositoryComponent;
29import de.uka.ipd.sdq.pcm.repository.RepositoryFactory;
30import de.uka.ipd.sdq.pcm.resourceenvironment.CommunicationLinkResourceSpecification;
31import de.uka.ipd.sdq.pcm.resourceenvironment.LinkingResource;
32import de.uka.ipd.sdq.pcm.resourceenvironment.ProcessingResourceSpecification;
33import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer;
34import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceEnvironment;
35import de.uka.ipd.sdq.pcm.resourcetype.CommunicationLinkResourceType;
36import de.uka.ipd.sdq.pcm.resourcetype.ProcessingResourceType;
37import de.uka.ipd.sdq.pcm.seff.InternalAction;
38import de.uka.ipd.sdq.pcm.seff.SeffFactory;
39import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification;
40import de.uka.ipd.sdq.pcm.system.System;
41import de.uka.ipd.sdq.reliability.core.MarkovEvaluationType;
42import de.uka.ipd.sdq.reliability.core.MarkovFailureType;
43import de.uka.ipd.sdq.reliability.core.MarkovHardwareInducedFailureType;
44import de.uka.ipd.sdq.reliability.core.MarkovNetworkInducedFailureType;
45import de.uka.ipd.sdq.reliability.core.MarkovResourceTimeoutFailureType;
46import de.uka.ipd.sdq.reliability.core.MarkovSoftwareInducedFailureType;
47 
48/**
49 * This class provides auxiliary functionality for managing MarkovFailureTypes.
50 * 
51 * @author brosch
52 * 
53 */
54public class MarkovFailureTypeHelper {
55 
56        /**
57         * Provides EMF utility functions.
58         */
59        private EMFHelper helper = new EMFHelper();
60 
61        /**
62         * Retrieves a list of potential failure types from a given PCM model
63         * instance.
64         * 
65         * @param evaluationType
66         *            the degree of differentiation between failure types
67         * @param repositories
68         *            the list of PCm Repository models
69         * @param environment
70         *            the PCM ResourceEnvironment model
71         * @param system
72         *            the PCM System model
73         * @return the list of potential failure types
74         */
75        public List<MarkovFailureType> getFailureTypes(
76                        final MarkovEvaluationType evaluationType,
77                        final List<Repository> repositories,
78                        final ResourceEnvironment environment, final System system) {
79                List<MarkovFailureType> failureTypes = getNetworkFailureTypes(
80                                evaluationType, environment, system);
81                failureTypes.addAll(getHardwareFailureTypes(evaluationType,
82                                environment, system));
83                failureTypes.addAll(getResourceTimeoutFailureTypes(evaluationType,
84                                system));
85                failureTypes.addAll(getSoftwareFailureTypes(evaluationType,
86                                repositories, system));
87                return removeDoubleFailureTypes(failureTypes);
88 
89        }
90 
91        /**
92         * Retrieves the list of processing resource failure types from the given
93         * PCM model.
94         * 
95         * @param evaluationType
96         *            the degree of differentiation between failure types
97         * @param environment
98         *            the PCM Resource Environment model
99         * @param system
100         *            the PCM System model
101         * @return the list of processing resource failure types
102         */
103        private List<MarkovFailureType> getHardwareFailureTypes(
104                        final MarkovEvaluationType evaluationType,
105                        final ResourceEnvironment environment, final System system) {
106 
107                // Initialize the list of results:
108                ArrayList<MarkovFailureType> resultList = new ArrayList<MarkovFailureType>();
109 
110                // Handle the PCM resource environment model:
111                for (ResourceContainer container : environment
112                                .getResourceContainer_ResourceEnvironment()) {
113                        for (ProcessingResourceSpecification specification : container
114                                        .getActiveResourceSpecifications_ResourceContainer()) {
115                                ProcessingResourceType resourceType = specification
116                                                .getActiveResourceType_ActiveResourceSpecification();
117                                resultList.add(MarkovHardwareInducedFailureType
118                                                .createInternalFailureType(evaluationType, container,
119                                                                resourceType));
120                        }
121                }
122 
123                // Handle the PCM system model:
124                for (QoSAnnotations qos : system.getQosAnnotations_System()) {
125                        for (SpecifiedQoSAnnotation annotation : qos
126                                        .getSpecifiedQoSAnnotations_QoSAnnotations()) {
127                                if (annotation instanceof SpecifiedReliabilityAnnotation) {
128                                        SpecifiedReliabilityAnnotation relAnnotation = ((SpecifiedReliabilityAnnotation) annotation);
129                                        for (ExternalFailureOccurrenceDescription description : relAnnotation
130                                                        .getExternalFailureOccurrenceDescriptions__SpecifiedReliabilityAnnotation()) {
131                                                FailureType failureType = description
132                                                                .getFailureType__ExternalFailureOccurrenceDescription();
133                                                if (failureType instanceof HardwareInducedFailureType) {
134                                                        HardwareInducedFailureType hardwareFailureType = ((HardwareInducedFailureType) failureType);
135                                                        resultList
136                                                                        .add(MarkovHardwareInducedFailureType
137                                                                                        .createExternalFailureType(
138                                                                                                        evaluationType,
139                                                                                                        hardwareFailureType
140                                                                                                                        .getProcessingResourceType__HardwareInducedFailureType(),
141                                                                                                        annotation
142                                                                                                                        .getSignature_SpecifiedQoSAnnation(),
143                                                                                                        annotation
144                                                                                                                        .getRole_SpecifiedQoSAnnotation(),
145                                                                                                        ((OperationRequiredRole) annotation
146                                                                                                                        .getRole_SpecifiedQoSAnnotation())
147                                                                                                                        .getRequiredInterface__OperationRequiredRole()));
148                                                }
149                                        }
150                                }
151                        }
152                }
153 
154                // Return the result:
155                return resultList;
156        }
157 
158        /**
159         * Retrieves the list of communication failure types from the given PCM
160         * model.
161         * 
162         * @param evaluationType
163         *            the degree of differentiation between failure types
164         * @param environment
165         *            the PCM Resource Environment model
166         * @param system
167         *            the PCM System model
168         * @return the list of communication resource failure types
169         */
170        private List<MarkovFailureType> getNetworkFailureTypes(
171                        final MarkovEvaluationType evaluationType,
172                        final ResourceEnvironment environment, final System system) {
173 
174                // Initialize the list of results:
175                ArrayList<MarkovFailureType> resultList = new ArrayList<MarkovFailureType>();
176 
177                // Handle the PCM resource environment model:
178                for (LinkingResource commLink : environment
179                                .getLinkingResources__ResourceEnvironment()) {
180                        CommunicationLinkResourceSpecification specification = commLink
181                                        .getCommunicationLinkResourceSpecifications_LinkingResource();
182                        CommunicationLinkResourceType resourceType = specification
183                                        .getCommunicationLinkResourceType_CommunicationLinkResourceSpecification();
184                        resultList.add(MarkovNetworkInducedFailureType
185                                        .createInternalFailureType(evaluationType, commLink,
186                                                        resourceType));
187                }
188 
189                // Handle the PCM system model:
190                for (QoSAnnotations qos : system.getQosAnnotations_System()) {
191                        for (SpecifiedQoSAnnotation annotation : qos
192                                        .getSpecifiedQoSAnnotations_QoSAnnotations()) {
193                                if (annotation instanceof SpecifiedReliabilityAnnotation) {
194                                        SpecifiedReliabilityAnnotation relAnnotation = ((SpecifiedReliabilityAnnotation) annotation);
195                                        for (ExternalFailureOccurrenceDescription description : relAnnotation
196                                                        .getExternalFailureOccurrenceDescriptions__SpecifiedReliabilityAnnotation()) {
197                                                FailureType failureType = description
198                                                                .getFailureType__ExternalFailureOccurrenceDescription();
199                                                if (failureType instanceof NetworkInducedFailureType) {
200                                                        CommunicationLinkResourceType resourceType = ((NetworkInducedFailureType) failureType)
201                                                                        .getCommunicationLinkResourceType__NetworkInducedFailureType();
202                                                        resultList
203                                                                        .add(MarkovNetworkInducedFailureType
204                                                                                        .createExternalFailureType(
205                                                                                                        evaluationType,
206                                                                                                        resourceType,
207                                                                                                        annotation
208                                                                                                                        .getSignature_SpecifiedQoSAnnation(),
209                                                                                                        annotation
210                                                                                                                        .getRole_SpecifiedQoSAnnotation(),
211                                                                                                        ((OperationRequiredRole) annotation
212                                                                                                                        .getRole_SpecifiedQoSAnnotation())
213                                                                                                                        .getRequiredInterface__OperationRequiredRole()));
214                                                }
215                                        }
216                                }
217                        }
218                }
219 
220                // Return the result:
221                return resultList;
222        }
223 
224        /**
225         * Retrieves the list of resource timeout failure types from the given PCM
226         * model.
227         * 
228         * @param evaluationType
229         *            the degree of differentiation between failure types
230         * @param system
231         *            the PCM System model
232         * @return the list of resource timeout failure types
233         */
234        private List<MarkovFailureType> getResourceTimeoutFailureTypes(
235                        final MarkovEvaluationType evaluationType, final System system) {
236 
237                // Initialize the list of results:
238                ArrayList<MarkovFailureType> resultList = new ArrayList<MarkovFailureType>();
239 
240                // Handle the PCM system model:
241                for (AssemblyContext context : system
242                                .getAssemblyContexts__ComposedStructure()) {
243                        RepositoryComponent component = context
244                                        .getEncapsulatedComponent__AssemblyContext();
245                        if (!(component instanceof BasicComponent)) {
246                                continue;
247                        }
248                        for (PassiveResource resource : ((BasicComponent) component)
249                                        .getPassiveResource_BasicComponent()) {
250                                resultList
251                                                .add(MarkovResourceTimeoutFailureType
252                                                                .createResourceTimeoutFailureType(
253                                                                                evaluationType, context,
254                                                                                ((BasicComponent) component), resource));
255                        }
256                }
257 
258                // Return the result:
259                return resultList;
260        }
261 
262        /**
263         * Retrieves the list of software failure types from the given PCM model.
264         * 
265         * @param evaluationType
266         *            the degree of differentiation between failure types
267         * @param repositories
268         *            the PCM Repository models
269         * @param system
270         *            the PCM System model
271         * @return the list of software failure types
272         */
273        private List<MarkovFailureType> getSoftwareFailureTypes(
274                        final MarkovEvaluationType evaluationType,
275                        final List<Repository> repositories, final System system) {
276 
277                // Initialize the list of results:
278                ArrayList<MarkovFailureType> resultList = new ArrayList<MarkovFailureType>();
279 
280                // Handle the PCM repository models:
281                for (Repository repository : repositories) {
282                        EList<EObject> components = helper
283                                        .getElements(repository, RepositoryFactory.eINSTANCE
284                                                        .createBasicComponent().eClass());
285                        for (Object c_object : components) {
286                                BasicComponent component = (BasicComponent) c_object;
287                                for (ProvidedRole role : component
288                                                .getProvidedRoles_InterfaceProvidingEntity()) {
289                                        if (role instanceof OperationProvidedRole) {
290                                                OperationProvidedRole opRole = (OperationProvidedRole) role;
291                                                OperationInterface iface = opRole
292                                                                .getProvidedInterface__OperationProvidedRole();
293                                                for (OperationSignature signature : iface
294                                                                .getSignatures__OperationInterface()) {
295                                                        ServiceEffectSpecification rdseff = getRDSEFF(
296                                                                        component, signature);
297                                                        EList<EObject> internalActions = helper
298                                                                        .getElements(rdseff, SeffFactory.eINSTANCE
299                                                                                        .createInternalAction().eClass());
300                                                        for (Object a_object : internalActions) {
301                                                                InternalAction internalAction = (InternalAction) a_object;
302                                                                for (InternalFailureOccurrenceDescription description : internalAction
303                                                                                .getInternalFailureOccurrenceDescriptions__InternalAction()) {
304                                                                        resultList
305                                                                                        .add(MarkovSoftwareInducedFailureType
306                                                                                                        .createInternalFailureType(
307                                                                                                                        evaluationType,
308                                                                                                                        description
309                                                                                                                                        .getSoftwareInducedFailureType__InternalFailureOccurrenceDescription(),
310                                                                                                                        internalAction,
311                                                                                                                        signature, opRole,
312                                                                                                                        iface, component));
313                                                                }
314                                                        }
315                                                }
316                                        }
317                                }
318                        }
319                }
320 
321                // Handle the PCM system model:
322                for (QoSAnnotations qos : system.getQosAnnotations_System()) {
323                        for (SpecifiedQoSAnnotation annotation : qos
324                                        .getSpecifiedQoSAnnotations_QoSAnnotations()) {
325                                if (annotation instanceof SpecifiedReliabilityAnnotation) {
326                                        SpecifiedReliabilityAnnotation relAnnotation = ((SpecifiedReliabilityAnnotation) annotation);
327                                        for (ExternalFailureOccurrenceDescription description : relAnnotation
328                                                        .getExternalFailureOccurrenceDescriptions__SpecifiedReliabilityAnnotation()) {
329                                                FailureType failureType = description
330                                                                .getFailureType__ExternalFailureOccurrenceDescription();
331                                                if (failureType instanceof SoftwareInducedFailureType) {
332                                                        SoftwareInducedFailureType softwareFailureType = ((SoftwareInducedFailureType) failureType);
333                                                        resultList
334                                                                        .add(MarkovSoftwareInducedFailureType
335                                                                                        .createExternalFailureType(
336                                                                                                        evaluationType,
337                                                                                                        softwareFailureType,
338                                                                                                        annotation
339                                                                                                                        .getSignature_SpecifiedQoSAnnation(),
340                                                                                                        annotation
341                                                                                                                        .getRole_SpecifiedQoSAnnotation(),
342                                                                                                        ((OperationRequiredRole) annotation
343                                                                                                                        .getRole_SpecifiedQoSAnnotation())
344                                                                                                                        .getRequiredInterface__OperationRequiredRole()));
345                                                }
346                                        }
347                                }
348                        }
349                }
350 
351                // Return the result:
352                return resultList;
353        }
354 
355        /**
356         * Retrieves an RDSEFF for a given component and signature.
357         * 
358         * @param component
359         *            the component
360         * @param signature
361         *            the signature
362         * @return the RDSEFF
363         */
364        private ServiceEffectSpecification getRDSEFF(
365                        final BasicComponent component, final OperationSignature signature) {
366                for (ServiceEffectSpecification rdseff : component
367                                .getServiceEffectSpecifications__BasicComponent()) {
368                        if (rdseff.getDescribedService__SEFF().getId().equals(
369                                        signature.getId())) {
370                                return rdseff;
371                        }
372                }
373                return null;
374        }
375 
376        /**
377         * Removes doubles from the list of failure types.
378         * 
379         * Double failure types can occur if the distinction of failure types is not
380         * at the most fine-granular level.
381         * 
382         * @param failureTypes
383         *            the list of failure types
384         * @return the result list
385         */
386        private List<MarkovFailureType> removeDoubleFailureTypes(
387                        final List<MarkovFailureType> failureTypes) {
388                ArrayList<MarkovFailureType> resultList = new ArrayList<MarkovFailureType>();
389                Iterator<MarkovFailureType> iterator = failureTypes.iterator();
390                while (iterator.hasNext()) {
391                        MarkovFailureType failureType = iterator.next();
392                        if (!resultList.contains(failureType)) {
393                                resultList.add(failureType);
394                        }
395                }
396                return resultList;
397        }
398}

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