1 | package de.uka.ipd.sdq.reliability.solver.reporting; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | import java.util.Map; |
6 | import java.util.TreeSet; |
7 | |
8 | import de.uka.ipd.sdq.pcm.usagemodel.UsageScenario; |
9 | import de.uka.ipd.sdq.pcmsolver.runconfig.PCMSolverWorkflowRunConfiguration; |
10 | import de.uka.ipd.sdq.reliability.core.MarkovEvaluationType; |
11 | import de.uka.ipd.sdq.reliability.core.MarkovFailureType; |
12 | import de.uka.ipd.sdq.reliability.core.MarkovHardwareInducedFailureType; |
13 | import de.uka.ipd.sdq.reliability.core.MarkovNetworkInducedFailureType; |
14 | import de.uka.ipd.sdq.reliability.core.MarkovSoftwareInducedFailureType; |
15 | import de.uka.ipd.sdq.reliability.solver.pcm2markov.MarkovResultApproximation; |
16 | import de.uka.ipd.sdq.reliability.solver.pcm2markov.MarkovTransformationResult; |
17 | |
18 | /** |
19 | * Class used for aggregation and output of success/failure probabilities that |
20 | * were calculated during a reliability analysis. |
21 | * |
22 | * @author Daniel Patejdl |
23 | * |
24 | */ |
25 | public class MarkovReporting { |
26 | /** |
27 | * Configuration properties for the reliability solver workflow. |
28 | */ |
29 | PCMSolverWorkflowRunConfiguration configuration; |
30 | |
31 | /** |
32 | * Will store the overall failure probabilities of entities (components' |
33 | * internal actions, their services and service operations, external |
34 | * services and their operations). |
35 | */ |
36 | List<ImpactAnalysisFailureProbabilityAggregation> failureProbabilityAggregations; |
37 | |
38 | /** |
39 | * A list of MarkovReportItem instances, which are generated as a result of |
40 | * all Markov transformation results. They will be used for later output to |
41 | * the user. |
42 | */ |
43 | List<MarkovReportItem> markovReportItems; |
44 | |
45 | /** |
46 | * List of aggregated results of a PCM2MarkovTransformation |
47 | */ |
48 | private List<MarkovTransformationResult> markovResults; |
49 | |
50 | /** |
51 | * Creates a new MarkovReporting instance that is used for result |
52 | * aggregation according to the given Markov transformation results. |
53 | * |
54 | * @param markovResults |
55 | * the Markov transformation results |
56 | * @param config |
57 | * the configuration properties for the reliability solver |
58 | * workflow |
59 | */ |
60 | public MarkovReporting(List<MarkovTransformationResult> markovResults, |
61 | PCMSolverWorkflowRunConfiguration configuration) { |
62 | this.markovResults = markovResults; |
63 | this.configuration = configuration; |
64 | // failureProbabilityAggregations = new |
65 | // ArrayList<ImpactAnalysisFailureProbabilityAggregation>(); |
66 | markovReportItems = new ArrayList<MarkovReportItem>(); |
67 | |
68 | createMarkovReportItems(); |
69 | } |
70 | |
71 | /** |
72 | * Calculates all components' internal action failure probabilities for |
73 | * later output. |
74 | */ |
75 | private void calculateComponentsInternalActionFailureProbabilities( |
76 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
77 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
78 | .keySet()) { |
79 | if (!failureType.isSystemExternal()) { // only consider (internal) |
80 | // components |
81 | if (failureType instanceof MarkovSoftwareInducedFailureType) { |
82 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) failureType; |
83 | |
84 | /* |
85 | * If the component ID is not in our data structure, we will |
86 | * add a new entry to it. If the component ID is already in |
87 | * the data structure, we will not add it again, but we will |
88 | * add to (the existing failure probability) the current |
89 | * failure type's probability. |
90 | */ |
91 | boolean foundEntry = false; |
92 | List<String> identifiers = new ArrayList<String>(1); |
93 | identifiers |
94 | .add(softwareInducedFailureType.getComponentId()); |
95 | List<String> nameParts = new ArrayList<String>(1); |
96 | nameParts |
97 | .add(softwareInducedFailureType.getComponentName()); |
98 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
99 | if (aggregation |
100 | .compareToIdentifier( |
101 | ImpactAnalysisFailureType.COMPONENTS_INTERNAL_ACTIONS, |
102 | identifiers)) { |
103 | // this component ID is already in our data |
104 | // structure, therefore we do not |
105 | // add a new entry, but update the existing one |
106 | // accordingly |
107 | aggregation |
108 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
109 | .get(failureType)); |
110 | foundEntry = true; |
111 | break; // found and updated the entry, so we are |
112 | // done |
113 | } |
114 | } |
115 | if (!foundEntry) { |
116 | // we did not find a fitting entry, so we add a new one |
117 | // and set its values accordingly |
118 | failureProbabilityAggregations |
119 | .add(new ImpactAnalysisFailureProbabilityAggregation( |
120 | ImpactAnalysisFailureType.COMPONENTS_INTERNAL_ACTIONS, |
121 | identifiers, nameParts, |
122 | cumulatedFailureTypeProbabilities |
123 | .get(failureType))); |
124 | } |
125 | } |
126 | } |
127 | } |
128 | } |
129 | |
130 | /** |
131 | * Calculates all components' service (interface) failure probabilities for |
132 | * later output. |
133 | */ |
134 | private void calculateComponentsServiceFailureProbabilities( |
135 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
136 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
137 | .keySet()) { |
138 | if (!failureType.isSystemExternal()) { // only consider (internal) |
139 | // components |
140 | if (failureType instanceof MarkovSoftwareInducedFailureType) { |
141 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) failureType; |
142 | boolean foundEntry = false; |
143 | List<String> identifiers = new ArrayList<String>(2); |
144 | identifiers |
145 | .add(softwareInducedFailureType.getComponentId()); |
146 | identifiers |
147 | .add(softwareInducedFailureType.getInterfaceId()); |
148 | List<String> nameParts = new ArrayList<String>(2); |
149 | nameParts |
150 | .add(softwareInducedFailureType.getComponentName()); |
151 | nameParts |
152 | .add(softwareInducedFailureType.getInterfaceName()); |
153 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
154 | if (aggregation.compareToIdentifier( |
155 | ImpactAnalysisFailureType.COMPONENTS_SERVICES, |
156 | identifiers)) { |
157 | // this entity is already in our data structure, |
158 | // therefore we do not |
159 | // add a new entry, but update the existing one |
160 | // accordingly |
161 | aggregation |
162 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
163 | .get(failureType)); |
164 | foundEntry = true; |
165 | break; // found and updated the entry, so we are |
166 | // done |
167 | } |
168 | } |
169 | if (!foundEntry) { |
170 | // we did not find a fitting entry, so we add a new one |
171 | // and set its values |
172 | // accordingly |
173 | failureProbabilityAggregations |
174 | .add(new ImpactAnalysisFailureProbabilityAggregation( |
175 | ImpactAnalysisFailureType.COMPONENTS_SERVICES, |
176 | identifiers, nameParts, |
177 | cumulatedFailureTypeProbabilities |
178 | .get(failureType))); |
179 | } |
180 | } |
181 | } |
182 | } |
183 | } |
184 | |
185 | /** |
186 | * Calculates all components' service operation (signature) failure |
187 | * probabilities for later output. |
188 | */ |
189 | private void calculateComponentsServiceOperationFailureProbabilities( |
190 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
191 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
192 | .keySet()) { |
193 | if (!failureType.isSystemExternal()) { // only consider (internal) |
194 | // components |
195 | if (failureType instanceof MarkovSoftwareInducedFailureType) { |
196 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) failureType; |
197 | boolean foundEntry = false; |
198 | List<String> identifiers = new ArrayList<String>(3); |
199 | identifiers |
200 | .add(softwareInducedFailureType.getComponentId()); |
201 | identifiers |
202 | .add(softwareInducedFailureType.getInterfaceId()); |
203 | identifiers |
204 | .add(softwareInducedFailureType.getSignatureId()); |
205 | List<String> nameParts = new ArrayList<String>(3); |
206 | nameParts |
207 | .add(softwareInducedFailureType.getComponentName()); |
208 | nameParts |
209 | .add(softwareInducedFailureType.getInterfaceName()); |
210 | nameParts |
211 | .add(softwareInducedFailureType.getSignatureName()); |
212 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
213 | if (aggregation |
214 | .compareToIdentifier( |
215 | ImpactAnalysisFailureType.COMPONENTS_SERVICE_OPERATIONS, |
216 | identifiers)) { |
217 | // this entity is already in our data structure, |
218 | // therefore we do not |
219 | // add a new entry, but update the existing one |
220 | // accordingly |
221 | aggregation |
222 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
223 | .get(failureType)); |
224 | foundEntry = true; |
225 | break; // found and updated the entry, so we are |
226 | // done |
227 | } |
228 | } |
229 | if (!foundEntry) { |
230 | // we did not find a fitting entry, so we add a new one |
231 | // and set its values |
232 | // accordingly |
233 | failureProbabilityAggregations |
234 | .add(new ImpactAnalysisFailureProbabilityAggregation( |
235 | ImpactAnalysisFailureType.COMPONENTS_SERVICE_OPERATIONS, |
236 | identifiers, nameParts, |
237 | cumulatedFailureTypeProbabilities |
238 | .get(failureType))); |
239 | } |
240 | } |
241 | } |
242 | } |
243 | } |
244 | |
245 | /** |
246 | * Calculates all external service (role and interface) failure |
247 | * probabilities for later output. |
248 | */ |
249 | private void calculateExternalServiceFailureProbabilities( |
250 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
251 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
252 | .keySet()) { |
253 | if (failureType.isSystemExternal()) { // only consider external |
254 | // services |
255 | boolean foundEntry = false; |
256 | List<String> identifiers = new ArrayList<String>(2); |
257 | identifiers.add(failureType.getRoleId()); |
258 | identifiers.add(failureType.getInterfaceId()); |
259 | List<String> nameParts = new ArrayList<String>(2); |
260 | nameParts.add(failureType.getRoleName()); |
261 | nameParts.add(failureType.getInterfaceName()); |
262 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
263 | if (aggregation.compareToIdentifier( |
264 | ImpactAnalysisFailureType.EXTERNAL_SERVICES, |
265 | identifiers)) { |
266 | // this entity is already in our data structure, |
267 | // therefore we do not |
268 | // add a new entry, but update the existing one |
269 | // accordingly |
270 | aggregation |
271 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
272 | .get(failureType)); |
273 | foundEntry = true; |
274 | break; // found and updated the entry, so we are done |
275 | } |
276 | } |
277 | if (!foundEntry) { |
278 | // we did not find a fitting entry, so we add a new one and |
279 | // set its values |
280 | // accordingly |
281 | failureProbabilityAggregations |
282 | .add(new ImpactAnalysisFailureProbabilityAggregation( |
283 | ImpactAnalysisFailureType.EXTERNAL_SERVICES, |
284 | identifiers, nameParts, |
285 | cumulatedFailureTypeProbabilities |
286 | .get(failureType))); |
287 | } |
288 | } |
289 | } |
290 | } |
291 | |
292 | /** |
293 | * Calculates all external service operation (signature) failure |
294 | * probabilities for later output. |
295 | */ |
296 | private void calculateExternalServiceOperationFailureProbabilities( |
297 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
298 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
299 | .keySet()) { |
300 | if (failureType.isSystemExternal()) { // only consider external |
301 | // services |
302 | boolean foundEntry = false; |
303 | List<String> identifiers = new ArrayList<String>(3); |
304 | identifiers.add(failureType.getRoleId()); |
305 | identifiers.add(failureType.getInterfaceId()); |
306 | identifiers.add(failureType.getSignatureId()); |
307 | List<String> nameParts = new ArrayList<String>(3); |
308 | nameParts.add(failureType.getRoleName()); |
309 | nameParts.add(failureType.getInterfaceName()); |
310 | nameParts.add(failureType.getSignatureName()); |
311 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
312 | if (aggregation |
313 | .compareToIdentifier( |
314 | ImpactAnalysisFailureType.EXTERNAL_SERVICE_OPERATIONS, |
315 | identifiers)) { |
316 | // this entity is already in our data structure, |
317 | // therefore we do not |
318 | // add a new entry, but update the existing one |
319 | // accordingly |
320 | aggregation |
321 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
322 | .get(failureType)); |
323 | foundEntry = true; |
324 | break; // found and updated the entry, so we are done |
325 | } |
326 | } |
327 | if (!foundEntry) { |
328 | // we did not find a fitting entry, so we add a new one and |
329 | // set its values |
330 | // accordingly |
331 | failureProbabilityAggregations |
332 | .add(new ImpactAnalysisFailureProbabilityAggregation( |
333 | ImpactAnalysisFailureType.EXTERNAL_SERVICE_OPERATIONS, |
334 | identifiers, nameParts, |
335 | cumulatedFailureTypeProbabilities |
336 | .get(failureType))); |
337 | } |
338 | } |
339 | } |
340 | } |
341 | |
342 | private void createClassesFailureAnalysisTable( |
343 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities, |
344 | double cumulatedPhysicalStateProbability, boolean doApproximate, |
345 | MarkovReportItem markovReportItem) { |
346 | double failureProbability; |
347 | MarkovReportingTable failureCategoryTable = new MarkovReportingTable( |
348 | "Failure mode categories"); |
349 | List<String> failureCategoryTableHeaderRow = new ArrayList<String>(2); |
350 | failureCategoryTableHeaderRow.add("Category"); |
351 | failureCategoryTableHeaderRow.add("Failure Mode Probability"); |
352 | failureCategoryTable.setHeaderRow(failureCategoryTableHeaderRow); |
353 | |
354 | // determine failure probabilities |
355 | ClassesFailureProbabilityAggregation softwareInducedFailureAggregation = new ClassesFailureProbabilityAggregation( |
356 | FailureAnalysisFailureType.SOFTWARE_INDUCED); |
357 | ClassesFailureProbabilityAggregation hardwareInducedFailureAggregation = new ClassesFailureProbabilityAggregation( |
358 | FailureAnalysisFailureType.HARDWARE_INDUCED); |
359 | ClassesFailureProbabilityAggregation networkInducedFailureAggregation = new ClassesFailureProbabilityAggregation( |
360 | FailureAnalysisFailureType.NETWORK_INDUCED); |
361 | for (MarkovFailureType type : cumulatedFailureTypeProbabilities |
362 | .keySet()) { |
363 | if (!type.isSystemExternal()) { // only consider internal failures |
364 | if (type instanceof MarkovSoftwareInducedFailureType) { |
365 | softwareInducedFailureAggregation |
366 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
367 | .get(type)); |
368 | } else if (type instanceof MarkovHardwareInducedFailureType) { |
369 | hardwareInducedFailureAggregation |
370 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
371 | .get(type)); |
372 | } else if (type instanceof MarkovNetworkInducedFailureType) { |
373 | networkInducedFailureAggregation |
374 | .addToFailureProbabilityBy(cumulatedFailureTypeProbabilities |
375 | .get(type)); |
376 | } |
377 | } |
378 | } |
379 | |
380 | // create rows of table |
381 | List<String> row = new ArrayList<String>(failureCategoryTableHeaderRow |
382 | .size()); |
383 | row.add("Software-induced failure"); |
384 | failureProbability = softwareInducedFailureAggregation |
385 | .getFailureProbability(); |
386 | row.add(String.valueOf(doApproximate ? getFormattedProbabilityAsString( |
387 | failureProbability, failureProbability + 1 |
388 | - cumulatedPhysicalStateProbability) |
389 | : getFormattedProbabilityAsString(failureProbability))); |
390 | if (failureProbability > 0.0) { |
391 | failureCategoryTable.addRow(row); |
392 | } |
393 | |
394 | row = new ArrayList<String>(failureCategoryTableHeaderRow.size()); |
395 | row.add("Hardware-induced failure"); |
396 | failureProbability = hardwareInducedFailureAggregation |
397 | .getFailureProbability(); |
398 | row.add(String.valueOf(doApproximate ? getFormattedProbabilityAsString( |
399 | failureProbability, failureProbability + 1 |
400 | - cumulatedPhysicalStateProbability) |
401 | : getFormattedProbabilityAsString(failureProbability))); |
402 | if (failureProbability > 0.0) { |
403 | failureCategoryTable.addRow(row); |
404 | } |
405 | |
406 | row = new ArrayList<String>(failureCategoryTableHeaderRow.size()); |
407 | row.add("Network-induced failure"); |
408 | failureProbability = networkInducedFailureAggregation |
409 | .getFailureProbability(); |
410 | row.add(String.valueOf(doApproximate ? getFormattedProbabilityAsString( |
411 | failureProbability, failureProbability + 1 |
412 | - cumulatedPhysicalStateProbability) |
413 | : getFormattedProbabilityAsString(failureProbability))); |
414 | if (failureProbability > 0.0) { |
415 | failureCategoryTable.addRow(row); |
416 | } |
417 | |
418 | // finally, add table to report item if it contains at least one row |
419 | if (failureCategoryTable.getRows().size() > 0) { |
420 | markovReportItem.addFailureModeTable(failureCategoryTable); |
421 | } |
422 | } |
423 | |
424 | private void createFailureAnalysisTables( |
425 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities, |
426 | double cumulatedPhysicalStateProbability, boolean doApproximate, |
427 | MarkovReportItem markovReportItem, MarkovEvaluationType mode) { |
428 | switch (mode) { |
429 | case SINGLE: |
430 | // do nothing |
431 | break; |
432 | case CLASSES: // failure categories |
433 | createClassesFailureAnalysisTable( |
434 | cumulatedFailureTypeProbabilities, |
435 | cumulatedPhysicalStateProbability, doApproximate, |
436 | markovReportItem); |
437 | break; |
438 | case TYPES: |
439 | createTypesFailureAnalysisTable(cumulatedFailureTypeProbabilities, |
440 | cumulatedPhysicalStateProbability, doApproximate, |
441 | markovReportItem); |
442 | break; |
443 | case POINTSOFFAILURE: |
444 | createPointsOfFailureAnalysisTable( |
445 | cumulatedFailureTypeProbabilities, |
446 | cumulatedPhysicalStateProbability, doApproximate, |
447 | markovReportItem); |
448 | break; |
449 | default: |
450 | break; |
451 | } |
452 | } |
453 | |
454 | private void createImpactAnalysisTables( |
455 | double cumulatedPhysicalStateProbability, boolean doApproximate, |
456 | MarkovReportItem markovReportItem) { |
457 | MarkovReportingTable componentsInternalActionFailureProbabilitiesTable = new MarkovReportingTable( |
458 | "Component failure impacts"); |
459 | List<String> componentsInternalActionFailureProbabilitiesTableHeaderRow = new ArrayList<String>( |
460 | 3); |
461 | componentsInternalActionFailureProbabilitiesTableHeaderRow |
462 | .add("Component"); |
463 | componentsInternalActionFailureProbabilitiesTableHeaderRow |
464 | .add("Aggregated Failure Mode Probability"); |
465 | componentsInternalActionFailureProbabilitiesTable |
466 | .setHeaderRow(componentsInternalActionFailureProbabilitiesTableHeaderRow); |
467 | // componentsServiceFailureProbabilities |
468 | MarkovReportingTable componentsServiceFailureProbabilitiesTable = new MarkovReportingTable( |
469 | "Component service failure impacts"); |
470 | List<String> componentsServiceFailureProbabilitiesTableHeaderRow = new ArrayList<String>( |
471 | 3); |
472 | componentsServiceFailureProbabilitiesTableHeaderRow.add("Component"); |
473 | componentsServiceFailureProbabilitiesTableHeaderRow.add("Interface"); |
474 | componentsServiceFailureProbabilitiesTableHeaderRow |
475 | .add("Aggregated Failure Mode Probability"); |
476 | componentsServiceFailureProbabilitiesTable |
477 | .setHeaderRow(componentsServiceFailureProbabilitiesTableHeaderRow); |
478 | // componentsServiceOperationFailureProbabilities |
479 | MarkovReportingTable componentsServiceOperationFailureProbabilitiesTable = new MarkovReportingTable( |
480 | "Component operation failure impacts"); |
481 | List<String> componentsServiceOperationFailureProbabilitiesTableHeaderRow = new ArrayList<String>( |
482 | 4); |
483 | componentsServiceOperationFailureProbabilitiesTableHeaderRow |
484 | .add("Component"); |
485 | componentsServiceOperationFailureProbabilitiesTableHeaderRow |
486 | .add("Interface"); |
487 | componentsServiceOperationFailureProbabilitiesTableHeaderRow |
488 | .add("Signature"); |
489 | componentsServiceOperationFailureProbabilitiesTableHeaderRow |
490 | .add("Aggregated Failure Mode Probability"); |
491 | componentsServiceOperationFailureProbabilitiesTable |
492 | .setHeaderRow(componentsServiceOperationFailureProbabilitiesTableHeaderRow); |
493 | // externalServiceFailureProbabilities |
494 | MarkovReportingTable externalServiceFailureProbabilitiesTable = new MarkovReportingTable( |
495 | "External service failure impacts"); |
496 | List<String> externalServiceFailureProbabilitiesTableHeaderRow = new ArrayList<String>( |
497 | 4); |
498 | externalServiceFailureProbabilitiesTableHeaderRow |
499 | .add("System-required Role"); |
500 | externalServiceFailureProbabilitiesTableHeaderRow.add("Interface"); |
501 | externalServiceFailureProbabilitiesTableHeaderRow |
502 | .add("Aggregated Failure Mode Probability"); |
503 | externalServiceFailureProbabilitiesTable |
504 | .setHeaderRow(externalServiceFailureProbabilitiesTableHeaderRow); |
505 | // externalServiceOperationFailureProbabilities |
506 | MarkovReportingTable externalServiceOperationFailureProbabilitiesTable = new MarkovReportingTable( |
507 | "External operation failure impacts"); |
508 | List<String> externalServiceOperationFailureProbabilitiesTableHeaderRow = new ArrayList<String>( |
509 | 4); |
510 | externalServiceOperationFailureProbabilitiesTableHeaderRow |
511 | .add("System-required Role"); |
512 | externalServiceOperationFailureProbabilitiesTableHeaderRow |
513 | .add("Interface"); |
514 | externalServiceOperationFailureProbabilitiesTableHeaderRow |
515 | .add("Signature"); |
516 | externalServiceOperationFailureProbabilitiesTableHeaderRow |
517 | .add("Aggregated Failure Mode Probability"); |
518 | externalServiceOperationFailureProbabilitiesTable |
519 | .setHeaderRow(externalServiceOperationFailureProbabilitiesTableHeaderRow); |
520 | |
521 | /* |
522 | * Create a table row for each failure probability aggregation, and add |
523 | * this row to the according impact analysis table. |
524 | */ |
525 | for (ImpactAnalysisFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
526 | double failureProbability = aggregation.getFailureProbability(); |
527 | if (!(failureProbability > 0.0)) { |
528 | continue; |
529 | } |
530 | switch (aggregation.getType()) { |
531 | case COMPONENTS_INTERNAL_ACTIONS: |
532 | List<String> componentsInternalActionFailureProbabilitiesTableRow = new ArrayList<String>( |
533 | componentsInternalActionFailureProbabilitiesTableHeaderRow |
534 | .size()); // create new row |
535 | for (String entityNamePart : aggregation.getEntityNameParts()) { // add |
536 | // name |
537 | // parts |
538 | // to |
539 | // row; |
540 | // one |
541 | // column |
542 | // per |
543 | // name |
544 | // part |
545 | componentsInternalActionFailureProbabilitiesTableRow |
546 | .add(entityNamePart); |
547 | } |
548 | componentsInternalActionFailureProbabilitiesTableRow |
549 | .add(doApproximate ? getFormattedProbabilityAsString( |
550 | failureProbability, failureProbability + 1 |
551 | - cumulatedPhysicalStateProbability) |
552 | : getFormattedProbabilityAsString(failureProbability)); // also |
553 | // add |
554 | // failure |
555 | // probability |
556 | // to |
557 | // this |
558 | // row |
559 | componentsInternalActionFailureProbabilitiesTable |
560 | .addRow(componentsInternalActionFailureProbabilitiesTableRow); // insert |
561 | // row |
562 | // into |
563 | // table |
564 | break; |
565 | case COMPONENTS_SERVICES: |
566 | List<String> componentsServicesFailureProbabilitiesTableRow = new ArrayList<String>( |
567 | componentsServiceFailureProbabilitiesTableHeaderRow |
568 | .size()); // create new row |
569 | for (String entityNamePart : aggregation.getEntityNameParts()) { // add |
570 | // name |
571 | // parts |
572 | // to |
573 | // row; |
574 | // one |
575 | // column |
576 | // per |
577 | // name |
578 | // part |
579 | componentsServicesFailureProbabilitiesTableRow |
580 | .add(entityNamePart); |
581 | } |
582 | componentsServicesFailureProbabilitiesTableRow |
583 | .add(doApproximate ? getFormattedProbabilityAsString( |
584 | failureProbability, failureProbability + 1 |
585 | - cumulatedPhysicalStateProbability) |
586 | : getFormattedProbabilityAsString(failureProbability)); // also |
587 | // add |
588 | // failure |
589 | // probability |
590 | // to |
591 | // this |
592 | // row |
593 | componentsServiceFailureProbabilitiesTable |
594 | .addRow(componentsServicesFailureProbabilitiesTableRow); // insert |
595 | // row |
596 | // into |
597 | // table |
598 | break; |
599 | case COMPONENTS_SERVICE_OPERATIONS: |
600 | List<String> componentsServiceOperationFailureProbabilitiesTableRow = new ArrayList<String>( |
601 | componentsServiceOperationFailureProbabilitiesTableHeaderRow |
602 | .size()); // create new row |
603 | for (String entityNamePart : aggregation.getEntityNameParts()) { // add |
604 | // name |
605 | // parts |
606 | // to |
607 | // row; |
608 | // one |
609 | // column |
610 | // per |
611 | // name |
612 | // part |
613 | componentsServiceOperationFailureProbabilitiesTableRow |
614 | .add(entityNamePart); |
615 | } |
616 | componentsServiceOperationFailureProbabilitiesTableRow |
617 | .add(doApproximate ? getFormattedProbabilityAsString( |
618 | failureProbability, failureProbability + 1 |
619 | - cumulatedPhysicalStateProbability) |
620 | : getFormattedProbabilityAsString(failureProbability)); // also |
621 | // add |
622 | // failure |
623 | // probability |
624 | // to |
625 | // this |
626 | // row |
627 | componentsServiceOperationFailureProbabilitiesTable |
628 | .addRow(componentsServiceOperationFailureProbabilitiesTableRow); // insert |
629 | // row |
630 | // into |
631 | // table |
632 | break; |
633 | case EXTERNAL_SERVICES: |
634 | List<String> externalServiceFailureProbabilitiesTableRow = new ArrayList<String>( |
635 | externalServiceFailureProbabilitiesTableHeaderRow |
636 | .size()); // create new row |
637 | for (String entityNamePart : aggregation.getEntityNameParts()) { // add |
638 | // name |
639 | // parts |
640 | // to |
641 | // row; |
642 | // one |
643 | // column |
644 | // per |
645 | // name |
646 | // part |
647 | externalServiceFailureProbabilitiesTableRow |
648 | .add(entityNamePart); |
649 | } |
650 | externalServiceFailureProbabilitiesTableRow |
651 | .add(doApproximate ? getFormattedProbabilityAsString( |
652 | failureProbability, failureProbability + 1 |
653 | - cumulatedPhysicalStateProbability) |
654 | : getFormattedProbabilityAsString(failureProbability)); // also |
655 | // add |
656 | // failure |
657 | // probability |
658 | // to |
659 | // this |
660 | // row |
661 | externalServiceFailureProbabilitiesTable |
662 | .addRow(externalServiceFailureProbabilitiesTableRow); // insert |
663 | // row |
664 | // into |
665 | // table |
666 | break; |
667 | case EXTERNAL_SERVICE_OPERATIONS: |
668 | List<String> externalServiceOperationFailureProbabilitiesTableRow = new ArrayList<String>( |
669 | externalServiceFailureProbabilitiesTableHeaderRow |
670 | .size()); // create new row |
671 | for (String entityNamePart : aggregation.getEntityNameParts()) { // add |
672 | // name |
673 | // parts |
674 | // to |
675 | // row; |
676 | // one |
677 | // column |
678 | // per |
679 | // name |
680 | // part |
681 | externalServiceOperationFailureProbabilitiesTableRow |
682 | .add(entityNamePart); |
683 | } |
684 | externalServiceOperationFailureProbabilitiesTableRow |
685 | .add(doApproximate ? getFormattedProbabilityAsString( |
686 | failureProbability, failureProbability + 1 |
687 | - cumulatedPhysicalStateProbability) |
688 | : getFormattedProbabilityAsString(failureProbability)); // also |
689 | // add |
690 | // failure |
691 | // probability |
692 | // to |
693 | // this |
694 | // row |
695 | externalServiceOperationFailureProbabilitiesTable |
696 | .addRow(externalServiceOperationFailureProbabilitiesTableRow); // insert |
697 | // row |
698 | // into |
699 | // table |
700 | break; |
701 | default: |
702 | break; |
703 | } |
704 | } |
705 | |
706 | /* |
707 | * Finally, add the tables to our report item if they contain at least |
708 | * one row (per table). |
709 | */ |
710 | if (componentsInternalActionFailureProbabilitiesTable.getRows().size() > 0) { |
711 | markovReportItem |
712 | .addImpactAnalysisTable(componentsInternalActionFailureProbabilitiesTable); |
713 | } |
714 | if (componentsServiceFailureProbabilitiesTable.getRows().size() > 0) { |
715 | markovReportItem |
716 | .addImpactAnalysisTable(componentsServiceFailureProbabilitiesTable); |
717 | } |
718 | if (componentsServiceOperationFailureProbabilitiesTable.getRows() |
719 | .size() > 0) { |
720 | markovReportItem |
721 | .addImpactAnalysisTable(componentsServiceOperationFailureProbabilitiesTable); |
722 | } |
723 | if (externalServiceFailureProbabilitiesTable.getRows().size() > 0) { |
724 | markovReportItem |
725 | .addImpactAnalysisTable(externalServiceFailureProbabilitiesTable); |
726 | } |
727 | if (externalServiceOperationFailureProbabilitiesTable.getRows().size() > 0) { |
728 | markovReportItem |
729 | .addImpactAnalysisTable(externalServiceOperationFailureProbabilitiesTable); |
730 | } |
731 | } |
732 | |
733 | /* |
734 | * Consider all Markov transformation results: For each such result we will |
735 | * calculate the probabilities of interest, and then enclose them in a |
736 | * MarkovResultItem for further processing. |
737 | */ |
738 | private void createMarkovReportItems() { |
739 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities = null; |
740 | double cumulatedPhysicalStateProbability = 0; |
741 | boolean doApproximate = false; |
742 | double cumulatedSuccessProbability = -1.0; // error value |
743 | |
744 | MarkovEvaluationType mode = MarkovEvaluationType.valueOf(configuration |
745 | .getMarkovEvaluationMode()); |
746 | |
747 | /* |
748 | * Create table-style output format. |
749 | */ |
750 | UsageScenario scenario = null; |
751 | MarkovReportItem markovReportItem = null; |
752 | for (MarkovTransformationResult markovResult : markovResults) { |
753 | scenario = markovResult.getScenario(); |
754 | cumulatedFailureTypeProbabilities = markovResult |
755 | .getCumulatedFailureTypeProbabilities(); |
756 | cumulatedPhysicalStateProbability = markovResult |
757 | .getCumulatedPhysicalStateProbability(); |
758 | cumulatedSuccessProbability = markovResult.getSuccessProbability(); |
759 | doApproximate = markovResult.isDoApproximate(); |
760 | |
761 | /* |
762 | * Create a new Markov report item using the data of this scenario. |
763 | */ |
764 | if (doApproximate) { |
765 | markovReportItem = new MarkovReportItem(scenario |
766 | .getEntityName(), scenario.getId(), |
767 | getFormattedProbabilityAsString( |
768 | cumulatedSuccessProbability, |
769 | cumulatedSuccessProbability + 1 |
770 | - cumulatedPhysicalStateProbability)); |
771 | } else { |
772 | markovReportItem = new MarkovReportItem( |
773 | scenario.getEntityName(), |
774 | scenario.getId(), |
775 | getFormattedProbabilityAsString(cumulatedSuccessProbability)); |
776 | } |
777 | |
778 | /* |
779 | * Create failure mode tables first: Create a table row for each |
780 | * failure probability aggregation, and add this row to the |
781 | * according impact analysis table. |
782 | */ |
783 | createFailureAnalysisTables(cumulatedFailureTypeProbabilities, |
784 | cumulatedPhysicalStateProbability, doApproximate, |
785 | markovReportItem, mode); |
786 | |
787 | /* |
788 | * Calculate accumulated failure probabilities if our configuration |
789 | * is set accordingly. Otherwise, we are done at this point. |
790 | */ |
791 | if (mode == MarkovEvaluationType.POINTSOFFAILURE) { |
792 | failureProbabilityAggregations = new ArrayList<ImpactAnalysisFailureProbabilityAggregation>(); // do |
793 | // not |
794 | // put |
795 | // this |
796 | // line |
797 | // into |
798 | // constructor |
799 | |
800 | calculateComponentsInternalActionFailureProbabilities(cumulatedFailureTypeProbabilities); |
801 | calculateComponentsServiceFailureProbabilities(cumulatedFailureTypeProbabilities); |
802 | calculateComponentsServiceOperationFailureProbabilities(cumulatedFailureTypeProbabilities); |
803 | calculateExternalServiceFailureProbabilities(cumulatedFailureTypeProbabilities); |
804 | calculateExternalServiceOperationFailureProbabilities(cumulatedFailureTypeProbabilities); |
805 | |
806 | /* |
807 | * Now, create impact analysis tables. Insert calculated failure |
808 | * probabilities into report. |
809 | */ |
810 | createImpactAnalysisTables(cumulatedPhysicalStateProbability, |
811 | doApproximate, markovReportItem); |
812 | } |
813 | |
814 | /* |
815 | * Add this report item to our list of report items. |
816 | */ |
817 | markovReportItems.add(markovReportItem); |
818 | } |
819 | } |
820 | |
821 | private void createPointsOfFailureAnalysisTable( |
822 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities, |
823 | double cumulatedPhysicalStateProbability, boolean doApproximate, |
824 | MarkovReportItem markovReportItem) { |
825 | /* |
826 | * System-internal entities. |
827 | */ |
828 | MarkovReportingTable internalSoftwareFailuresTable = new MarkovReportingTable( |
829 | "System-internal software-induced failure modes"); |
830 | List<String> internalSoftwareFailuresTableHeaderRow = new ArrayList<String>( |
831 | 6); |
832 | internalSoftwareFailuresTableHeaderRow.add("Component"); |
833 | internalSoftwareFailuresTableHeaderRow.add("Interface"); |
834 | internalSoftwareFailuresTableHeaderRow.add("Signature"); |
835 | internalSoftwareFailuresTableHeaderRow.add("Internal Action"); |
836 | internalSoftwareFailuresTableHeaderRow.add("Failure Type"); |
837 | internalSoftwareFailuresTableHeaderRow.add("Failure Mode Probability"); |
838 | internalSoftwareFailuresTable |
839 | .setHeaderRow(internalSoftwareFailuresTableHeaderRow); |
840 | List<String> internalSoftwareFailuresTableRow; |
841 | |
842 | MarkovReportingTable internalHardwareFailuresTable = new MarkovReportingTable( |
843 | "System-internal hardware-induced failure modes"); |
844 | List<String> internalHardwareFailuresTableHeaderRow = new ArrayList<String>( |
845 | 3); |
846 | internalHardwareFailuresTableHeaderRow.add("Resource Container"); |
847 | internalHardwareFailuresTableHeaderRow.add("Resource Type"); |
848 | internalHardwareFailuresTableHeaderRow.add("Failure Mode Probablity"); |
849 | internalHardwareFailuresTable |
850 | .setHeaderRow(internalHardwareFailuresTableHeaderRow); |
851 | List<String> internalHardwareFailuresTableRow; |
852 | |
853 | MarkovReportingTable internalNetworkFailuresTable = new MarkovReportingTable( |
854 | "System-internal network-induced failure modes"); |
855 | List<String> internalNetworkFailuresTableHeaderRow = new ArrayList<String>( |
856 | 3); |
857 | internalNetworkFailuresTableHeaderRow.add("Communication Link"); |
858 | internalNetworkFailuresTableHeaderRow |
859 | .add("Communication Resource Type"); |
860 | internalNetworkFailuresTableHeaderRow.add("Failure Mode Probablity"); |
861 | internalNetworkFailuresTable |
862 | .setHeaderRow(internalNetworkFailuresTableHeaderRow); |
863 | List<String> internalNetworkFailuresTableRow; |
864 | |
865 | /* |
866 | * System-external entities. |
867 | */ |
868 | MarkovReportingTable externalSoftwareFailuresTable = new MarkovReportingTable( |
869 | "System-external software-induced failure modes"); |
870 | List<String> externalSoftwareFailuresTableHeaderRow = new ArrayList<String>( |
871 | 4); |
872 | externalSoftwareFailuresTableHeaderRow.add("System-required Role"); |
873 | externalSoftwareFailuresTableHeaderRow.add("Signature"); |
874 | externalSoftwareFailuresTableHeaderRow.add("Failure Type"); |
875 | externalSoftwareFailuresTableHeaderRow.add("Failure Mode Probability"); |
876 | externalSoftwareFailuresTable |
877 | .setHeaderRow(externalSoftwareFailuresTableHeaderRow); |
878 | List<String> externalSoftwareFailuresTableRow; |
879 | |
880 | MarkovReportingTable externalHardwareFailuresTable = new MarkovReportingTable( |
881 | "System-external hardware-induced failure modes"); |
882 | List<String> externalHardwareFailuresTableHeaderRow = new ArrayList<String>( |
883 | 4); |
884 | externalHardwareFailuresTableHeaderRow.add("System-required Role"); |
885 | externalHardwareFailuresTableHeaderRow.add("Signature"); |
886 | externalHardwareFailuresTableHeaderRow |
887 | .add("Communication Resource Type"); |
888 | externalHardwareFailuresTableHeaderRow.add("Failure Mode Probablity"); |
889 | externalHardwareFailuresTable |
890 | .setHeaderRow(externalHardwareFailuresTableHeaderRow); |
891 | List<String> externalHardwareFailuresTableRow; |
892 | |
893 | MarkovReportingTable externalNetworkFailuresTable = new MarkovReportingTable( |
894 | "System-external network-induced failure modes"); |
895 | List<String> externalNetworkFailuresTableHeaderRow = new ArrayList<String>( |
896 | 4); |
897 | externalNetworkFailuresTableHeaderRow.add("System-required Role"); |
898 | externalNetworkFailuresTableHeaderRow.add("Signature"); |
899 | externalNetworkFailuresTableHeaderRow |
900 | .add("Communication Resource Type"); |
901 | externalNetworkFailuresTableHeaderRow.add("Failure Mode Probablity"); |
902 | externalNetworkFailuresTable |
903 | .setHeaderRow(externalNetworkFailuresTableHeaderRow); |
904 | List<String> externalNetworkFailuresTableRow; |
905 | |
906 | TreeSet<MarkovFailureType> failureTypesSorted = getFailureTypesSorted(cumulatedFailureTypeProbabilities); |
907 | for (MarkovFailureType failureType : failureTypesSorted) { |
908 | double failureProbability = getFailureTypeProbability(failureType, |
909 | cumulatedFailureTypeProbabilities); |
910 | if (!(failureProbability > 0.0)) { |
911 | continue; |
912 | } |
913 | if (failureType.isSystemExternal()) { // external |
914 | if (failureType instanceof MarkovSoftwareInducedFailureType) { |
915 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) failureType; |
916 | |
917 | externalSoftwareFailuresTableRow = new ArrayList<String>( |
918 | externalSoftwareFailuresTableHeaderRow.size()); |
919 | externalSoftwareFailuresTableRow |
920 | .add(softwareInducedFailureType.getRoleName()); |
921 | externalSoftwareFailuresTableRow |
922 | .add(softwareInducedFailureType.getSignatureName()); |
923 | externalSoftwareFailuresTableRow |
924 | .add(softwareInducedFailureType |
925 | .getSoftwareFailureName()); |
926 | externalSoftwareFailuresTableRow |
927 | .add(doApproximate ? getFormattedProbabilityAsString( |
928 | getFailureTypeProbability( |
929 | softwareInducedFailureType, |
930 | cumulatedFailureTypeProbabilities), |
931 | /* |
932 | * getFailureTypeProbability( |
933 | * softwareInducedFailureType, |
934 | * cumulatedFailureTypeProbabilities) |
935 | */ |
936 | failureProbability + 1 |
937 | - cumulatedPhysicalStateProbability) |
938 | : getFormattedProbabilityAsString(/* |
939 | * getFailureTypeProbability( |
940 | * softwareInducedFailureType |
941 | * , |
942 | * cumulatedFailureTypeProbabilities |
943 | * ) |
944 | */ |
945 | failureProbability)); |
946 | externalSoftwareFailuresTable |
947 | .addRow(externalSoftwareFailuresTableRow); |
948 | } else if (failureType instanceof MarkovHardwareInducedFailureType) { |
949 | MarkovHardwareInducedFailureType hardwareInducedFailureType = (MarkovHardwareInducedFailureType) failureType; |
950 | externalHardwareFailuresTableRow = new ArrayList<String>( |
951 | externalHardwareFailuresTableHeaderRow.size()); |
952 | externalHardwareFailuresTableRow |
953 | .add(hardwareInducedFailureType.getRoleName()); |
954 | externalHardwareFailuresTableRow |
955 | .add(hardwareInducedFailureType.getSignatureName()); |
956 | externalHardwareFailuresTableRow |
957 | .add(hardwareInducedFailureType |
958 | .getResourceTypeName()); |
959 | externalHardwareFailuresTableRow |
960 | .add(doApproximate ? getFormattedProbabilityAsString( |
961 | /* |
962 | * getFailureTypeProbability( |
963 | * hardwareInducedFailureType, |
964 | * cumulatedFailureTypeProbabilities) |
965 | */ |
966 | failureProbability, |
967 | /* |
968 | * getFailureTypeProbability( |
969 | * hardwareInducedFailureType, |
970 | * cumulatedFailureTypeProbabilities) |
971 | */ |
972 | failureProbability + 1 |
973 | - cumulatedPhysicalStateProbability) |
974 | : getFormattedProbabilityAsString(/* |
975 | * getFailureTypeProbability( |
976 | * hardwareInducedFailureType |
977 | * , |
978 | * cumulatedFailureTypeProbabilities |
979 | * ) |
980 | */ |
981 | failureProbability)); |
982 | externalHardwareFailuresTable |
983 | .addRow(externalHardwareFailuresTableRow); |
984 | } else if (failureType instanceof MarkovNetworkInducedFailureType) { |
985 | MarkovNetworkInducedFailureType networkInducedFailureType = (MarkovNetworkInducedFailureType) failureType; |
986 | externalNetworkFailuresTableRow = new ArrayList<String>( |
987 | externalNetworkFailuresTableHeaderRow.size()); |
988 | externalNetworkFailuresTableRow |
989 | .add(networkInducedFailureType.getRoleName()); |
990 | externalNetworkFailuresTableRow |
991 | .add(networkInducedFailureType.getSignatureName()); |
992 | externalNetworkFailuresTableRow |
993 | .add(networkInducedFailureType |
994 | .getCommLinkResourceTypeName()); |
995 | externalNetworkFailuresTableRow |
996 | .add(doApproximate ? getFormattedProbabilityAsString( |
997 | /* |
998 | * getFailureTypeProbability( |
999 | * networkInducedFailureType, |
1000 | * cumulatedFailureTypeProbabilities) |
1001 | */ |
1002 | failureProbability, |
1003 | /* |
1004 | * getFailureTypeProbability( |
1005 | * networkInducedFailureType, |
1006 | * cumulatedFailureTypeProbabilities) |
1007 | */ |
1008 | failureProbability + 1 |
1009 | - cumulatedPhysicalStateProbability) |
1010 | : getFormattedProbabilityAsString(/* |
1011 | * getFailureTypeProbability( |
1012 | * networkInducedFailureType |
1013 | * , |
1014 | * cumulatedFailureTypeProbabilities |
1015 | * ) |
1016 | */ |
1017 | failureProbability)); |
1018 | externalNetworkFailuresTable |
1019 | .addRow(externalNetworkFailuresTableRow); |
1020 | } |
1021 | } else { // internal |
1022 | if (failureType instanceof MarkovSoftwareInducedFailureType) { |
1023 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) failureType; |
1024 | internalSoftwareFailuresTableRow = new ArrayList<String>( |
1025 | internalSoftwareFailuresTableHeaderRow.size()); |
1026 | internalSoftwareFailuresTableRow |
1027 | .add(softwareInducedFailureType.getComponentName()); |
1028 | internalSoftwareFailuresTableRow |
1029 | .add(softwareInducedFailureType.getInterfaceName()); |
1030 | internalSoftwareFailuresTableRow |
1031 | .add(softwareInducedFailureType.getSignatureName()); |
1032 | internalSoftwareFailuresTableRow |
1033 | .add(softwareInducedFailureType |
1034 | .getInternalActionName()); |
1035 | internalSoftwareFailuresTableRow |
1036 | .add(softwareInducedFailureType |
1037 | .getSoftwareFailureName()); |
1038 | internalSoftwareFailuresTableRow |
1039 | .add(doApproximate ? getFormattedProbabilityAsString( |
1040 | /* |
1041 | * getFailureTypeProbability( |
1042 | * softwareInducedFailureType, |
1043 | * cumulatedFailureTypeProbabilities) |
1044 | */ |
1045 | failureProbability, |
1046 | /* |
1047 | * getFailureTypeProbability( |
1048 | * softwareInducedFailureType, |
1049 | * cumulatedFailureTypeProbabilities) |
1050 | */ |
1051 | failureProbability + 1 |
1052 | - cumulatedPhysicalStateProbability) |
1053 | : getFormattedProbabilityAsString(/* |
1054 | * getFailureTypeProbability( |
1055 | * softwareInducedFailureType |
1056 | * , |
1057 | * cumulatedFailureTypeProbabilities |
1058 | * ) |
1059 | */ |
1060 | failureProbability)); |
1061 | internalSoftwareFailuresTable |
1062 | .addRow(internalSoftwareFailuresTableRow); |
1063 | } else if (failureType instanceof MarkovHardwareInducedFailureType) { |
1064 | MarkovHardwareInducedFailureType hardwareInducedFailureType = (MarkovHardwareInducedFailureType) failureType; |
1065 | internalHardwareFailuresTableRow = new ArrayList<String>( |
1066 | internalHardwareFailuresTableHeaderRow.size()); |
1067 | internalHardwareFailuresTableRow |
1068 | .add(hardwareInducedFailureType |
1069 | .getResourceContainerName()); |
1070 | internalHardwareFailuresTableRow |
1071 | .add(hardwareInducedFailureType |
1072 | .getResourceTypeName()); |
1073 | internalHardwareFailuresTableRow |
1074 | .add(doApproximate ? getFormattedProbabilityAsString( |
1075 | /* |
1076 | * getFailureTypeProbability( |
1077 | * hardwareInducedFailureType, |
1078 | * cumulatedFailureTypeProbabilities) |
1079 | */ |
1080 | failureProbability, |
1081 | /* |
1082 | * getFailureTypeProbability( |
1083 | * hardwareInducedFailureType, |
1084 | * cumulatedFailureTypeProbabilities) |
1085 | */ |
1086 | failureProbability + 1 |
1087 | - cumulatedPhysicalStateProbability) |
1088 | : getFormattedProbabilityAsString(/* |
1089 | * getFailureTypeProbability( |
1090 | * hardwareInducedFailureType |
1091 | * , |
1092 | * cumulatedFailureTypeProbabilities |
1093 | * ) |
1094 | */ |
1095 | failureProbability)); |
1096 | internalHardwareFailuresTable |
1097 | .addRow(internalHardwareFailuresTableRow); |
1098 | } else if (failureType instanceof MarkovNetworkInducedFailureType) { |
1099 | MarkovNetworkInducedFailureType networkInducedFailureType = (MarkovNetworkInducedFailureType) failureType; |
1100 | internalNetworkFailuresTableRow = new ArrayList<String>( |
1101 | internalNetworkFailuresTableHeaderRow.size()); |
1102 | internalNetworkFailuresTableRow |
1103 | .add(networkInducedFailureType |
1104 | .getLinkingResourceName()); |
1105 | internalNetworkFailuresTableRow |
1106 | .add(networkInducedFailureType |
1107 | .getCommLinkResourceTypeName()); |
1108 | internalNetworkFailuresTableRow |
1109 | .add(doApproximate ? getFormattedProbabilityAsString( |
1110 | /* |
1111 | * getFailureTypeProbability( |
1112 | * networkInducedFailureType, |
1113 | * cumulatedFailureTypeProbabilities) |
1114 | */ |
1115 | failureProbability, |
1116 | /* |
1117 | * getFailureTypeProbability( |
1118 | * networkInducedFailureType, |
1119 | * cumulatedFailureTypeProbabilities) |
1120 | */ |
1121 | failureProbability + 1 |
1122 | - cumulatedPhysicalStateProbability) |
1123 | : getFormattedProbabilityAsString(/* |
1124 | * getFailureTypeProbability( |
1125 | * networkInducedFailureType |
1126 | * , |
1127 | * cumulatedFailureTypeProbabilities |
1128 | * ) |
1129 | */ |
1130 | failureProbability)); |
1131 | internalNetworkFailuresTable |
1132 | .addRow(internalNetworkFailuresTableRow); |
1133 | } |
1134 | } |
1135 | } |
1136 | |
1137 | /* |
1138 | * Finally, add the generated failure mode tables to our report item if |
1139 | * they contain at least one row (per table). |
1140 | */ |
1141 | if (internalSoftwareFailuresTable.getRows().size() > 0) { |
1142 | markovReportItem.addFailureModeTable(internalSoftwareFailuresTable); |
1143 | } |
1144 | if (internalHardwareFailuresTable.getRows().size() > 0) { |
1145 | markovReportItem.addFailureModeTable(internalHardwareFailuresTable); |
1146 | } |
1147 | if (internalNetworkFailuresTable.getRows().size() > 0) { |
1148 | markovReportItem.addFailureModeTable(internalNetworkFailuresTable); |
1149 | } |
1150 | if (externalSoftwareFailuresTable.getRows().size() > 0) { |
1151 | markovReportItem.addFailureModeTable(externalSoftwareFailuresTable); |
1152 | } |
1153 | if (externalHardwareFailuresTable.getRows().size() > 0) { |
1154 | markovReportItem.addFailureModeTable(externalHardwareFailuresTable); |
1155 | } |
1156 | if (externalNetworkFailuresTable.getRows().size() > 0) { |
1157 | markovReportItem.addFailureModeTable(externalNetworkFailuresTable); |
1158 | } |
1159 | } |
1160 | |
1161 | private void createTypesFailureAnalysisTable( |
1162 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities, |
1163 | double cumulatedPhysicalStateProbability, boolean doApproximate, |
1164 | MarkovReportItem markovReportItem) { |
1165 | double failureProbability; |
1166 | // create tables |
1167 | MarkovReportingTable softwareInducedFailuresTable = new MarkovReportingTable( |
1168 | "Software-induced failure modes"); |
1169 | List<String> softwareInducedFailuresTableHeaderRow = new ArrayList<String>( |
1170 | 2); |
1171 | softwareInducedFailuresTableHeaderRow.add("Failure Type"); |
1172 | softwareInducedFailuresTableHeaderRow.add("Failure Mode Probability"); |
1173 | softwareInducedFailuresTable |
1174 | .setHeaderRow(softwareInducedFailuresTableHeaderRow); |
1175 | |
1176 | MarkovReportingTable hardwareInducedFailuresTable = new MarkovReportingTable( |
1177 | "Hardware-induced failure modes"); |
1178 | List<String> hardwareInducedFailuresTableHeaderRow = new ArrayList<String>( |
1179 | 2); |
1180 | hardwareInducedFailuresTableHeaderRow.add("Resource Type"); |
1181 | hardwareInducedFailuresTableHeaderRow.add("Failure Mode Probability"); |
1182 | hardwareInducedFailuresTable |
1183 | .setHeaderRow(hardwareInducedFailuresTableHeaderRow); |
1184 | |
1185 | MarkovReportingTable networkInducedFailuresTable = new MarkovReportingTable( |
1186 | "Network-induced failure modes"); |
1187 | List<String> networkInducedFailuresTableHeaderRow = new ArrayList<String>( |
1188 | 2); |
1189 | networkInducedFailuresTableHeaderRow.add("Communication Resource Type"); |
1190 | networkInducedFailuresTableHeaderRow.add("Failure Mode Probability"); |
1191 | networkInducedFailuresTable |
1192 | .setHeaderRow(networkInducedFailuresTableHeaderRow); |
1193 | |
1194 | // determine failure probabilities |
1195 | List<TypesFailureProbabilityAggregation> failureProbabilityAggregations = new ArrayList<TypesFailureProbabilityAggregation>(); |
1196 | for (MarkovFailureType type : cumulatedFailureTypeProbabilities |
1197 | .keySet()) { |
1198 | if (!type.isSystemExternal()) { // only consider internal failures |
1199 | if (type instanceof MarkovSoftwareInducedFailureType) { // only |
1200 | // consider |
1201 | // software-induced |
1202 | // failures |
1203 | MarkovSoftwareInducedFailureType softwareInducedFailureType = (MarkovSoftwareInducedFailureType) type; |
1204 | boolean foundEntry = false; |
1205 | for (TypesFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
1206 | if (aggregation.compareTo( |
1207 | FailureAnalysisFailureType.SOFTWARE_INDUCED, |
1208 | softwareInducedFailureType |
1209 | .getSoftwareFailureName())) { // see if |
1210 | // there |
1211 | // exists |
1212 | // already |
1213 | // a |
1214 | // fitting |
1215 | // aggregation |
1216 | // to |
1217 | // which |
1218 | // can |
1219 | // add |
1220 | // this |
1221 | // type's |
1222 | // failure |
1223 | // probability |
1224 | // to |
1225 | // yes, we found such an entry, so add up the |
1226 | // probabilities |
1227 | aggregation |
1228 | .addToFailureProbability(cumulatedFailureTypeProbabilities |
1229 | .get(softwareInducedFailureType)); |
1230 | foundEntry = true; |
1231 | break; |
1232 | } // else continue with next |
1233 | } |
1234 | // we have not found a fitting entry previously, so we will |
1235 | // create a new one |
1236 | if (!foundEntry) { |
1237 | failureProbabilityAggregations |
1238 | .add(new TypesFailureProbabilityAggregation( |
1239 | FailureAnalysisFailureType.SOFTWARE_INDUCED, |
1240 | softwareInducedFailureType |
1241 | .getSoftwareFailureName(), |
1242 | cumulatedFailureTypeProbabilities |
1243 | .get(softwareInducedFailureType))); |
1244 | } |
1245 | } else if (type instanceof MarkovHardwareInducedFailureType) { // only |
1246 | // consider |
1247 | // hardware-induced |
1248 | // failures |
1249 | MarkovHardwareInducedFailureType hardwareInducedFailureType = (MarkovHardwareInducedFailureType) type; |
1250 | boolean foundEntry = false; |
1251 | for (TypesFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
1252 | if (aggregation.compareTo( |
1253 | FailureAnalysisFailureType.HARDWARE_INDUCED, |
1254 | hardwareInducedFailureType |
1255 | .getResourceTypeName())) { // see if |
1256 | // there |
1257 | // exists |
1258 | // already a |
1259 | // fitting |
1260 | // aggregation |
1261 | // to which |
1262 | // can add |
1263 | // this |
1264 | // type's |
1265 | // failure |
1266 | // probability |
1267 | // to |
1268 | // yes, we found such an entry, so add up the |
1269 | // probabilities |
1270 | aggregation |
1271 | .addToFailureProbability(cumulatedFailureTypeProbabilities |
1272 | .get(hardwareInducedFailureType)); |
1273 | foundEntry = true; |
1274 | break; |
1275 | } // else continue with next |
1276 | } |
1277 | if (!foundEntry) { |
1278 | // we have not found a fitting entry previously, so we |
1279 | // will create a new one |
1280 | failureProbabilityAggregations |
1281 | .add(new TypesFailureProbabilityAggregation( |
1282 | FailureAnalysisFailureType.HARDWARE_INDUCED, |
1283 | hardwareInducedFailureType |
1284 | .getResourceTypeName(), |
1285 | cumulatedFailureTypeProbabilities |
1286 | .get(hardwareInducedFailureType))); |
1287 | } |
1288 | } else if (type instanceof MarkovNetworkInducedFailureType) { // only |
1289 | // consider |
1290 | // network-induced |
1291 | // failures |
1292 | MarkovNetworkInducedFailureType networkInducedFailureType = (MarkovNetworkInducedFailureType) type; |
1293 | boolean foundEntry = false; |
1294 | for (TypesFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
1295 | if (aggregation.compareTo( |
1296 | FailureAnalysisFailureType.NETWORK_INDUCED, |
1297 | networkInducedFailureType |
1298 | .getCommLinkResourceTypeName())) { // see |
1299 | // if |
1300 | // there |
1301 | // exists |
1302 | // already |
1303 | // a |
1304 | // fitting |
1305 | // aggregation |
1306 | // to |
1307 | // which |
1308 | // can |
1309 | // add |
1310 | // this |
1311 | // type's |
1312 | // failure |
1313 | // probability |
1314 | // to |
1315 | // yes, we found such an entry, so add up the |
1316 | // probabilities |
1317 | aggregation |
1318 | .addToFailureProbability(cumulatedFailureTypeProbabilities |
1319 | .get(networkInducedFailureType)); |
1320 | foundEntry = true; |
1321 | break; |
1322 | } // else continue with next |
1323 | } |
1324 | if (!foundEntry) { |
1325 | // we have not found a fitting entry previously, so we |
1326 | // will create a new one |
1327 | failureProbabilityAggregations |
1328 | .add(new TypesFailureProbabilityAggregation( |
1329 | FailureAnalysisFailureType.NETWORK_INDUCED, |
1330 | networkInducedFailureType |
1331 | .getCommLinkResourceTypeName(), |
1332 | cumulatedFailureTypeProbabilities |
1333 | .get(networkInducedFailureType))); |
1334 | } |
1335 | } |
1336 | } |
1337 | } |
1338 | |
1339 | // now create rows of table |
1340 | List<String> softwareInducedFailuresTableRow; |
1341 | List<String> hardwareInducedFailuresTableRow; |
1342 | List<String> networkInducedFailuresTableRow; |
1343 | for (TypesFailureProbabilityAggregation aggregation : failureProbabilityAggregations) { |
1344 | failureProbability = aggregation.getFailureProbability(); |
1345 | if (!(failureProbability > 0.0)) { |
1346 | continue; |
1347 | } |
1348 | switch (aggregation.getType()) { |
1349 | case SOFTWARE_INDUCED: |
1350 | softwareInducedFailuresTableRow = new ArrayList<String>(2); |
1351 | softwareInducedFailuresTableRow.add(aggregation |
1352 | .getTypeIdentifier()); |
1353 | softwareInducedFailuresTableRow |
1354 | .add(String |
1355 | .valueOf(doApproximate ? getFormattedProbabilityAsString( |
1356 | failureProbability, |
1357 | failureProbability |
1358 | + 1 |
1359 | - cumulatedPhysicalStateProbability) |
1360 | : getFormattedProbabilityAsString(failureProbability))); |
1361 | softwareInducedFailuresTable |
1362 | .addRow(softwareInducedFailuresTableRow); |
1363 | break; |
1364 | case HARDWARE_INDUCED: |
1365 | hardwareInducedFailuresTableRow = new ArrayList<String>(2); |
1366 | hardwareInducedFailuresTableRow.add(aggregation |
1367 | .getTypeIdentifier()); |
1368 | hardwareInducedFailuresTableRow |
1369 | .add(String |
1370 | .valueOf(doApproximate ? getFormattedProbabilityAsString( |
1371 | failureProbability, |
1372 | failureProbability |
1373 | + 1 |
1374 | - cumulatedPhysicalStateProbability) |
1375 | : getFormattedProbabilityAsString(failureProbability))); |
1376 | hardwareInducedFailuresTable |
1377 | .addRow(hardwareInducedFailuresTableRow); |
1378 | break; |
1379 | case NETWORK_INDUCED: |
1380 | networkInducedFailuresTableRow = new ArrayList<String>(2); |
1381 | networkInducedFailuresTableRow.add(aggregation |
1382 | .getTypeIdentifier()); |
1383 | networkInducedFailuresTableRow |
1384 | .add(String |
1385 | .valueOf(doApproximate ? getFormattedProbabilityAsString( |
1386 | failureProbability, |
1387 | failureProbability |
1388 | + 1 |
1389 | - cumulatedPhysicalStateProbability) |
1390 | : getFormattedProbabilityAsString(failureProbability))); |
1391 | networkInducedFailuresTable |
1392 | .addRow(networkInducedFailuresTableRow); |
1393 | break; |
1394 | default: |
1395 | break; |
1396 | } |
1397 | } |
1398 | |
1399 | // finally, add tables to report item if they contain at least one row |
1400 | // (per table) |
1401 | if (softwareInducedFailuresTable.getRows().size() > 0) { |
1402 | markovReportItem.addFailureModeTable(softwareInducedFailuresTable); |
1403 | } |
1404 | if (hardwareInducedFailuresTable.getRows().size() > 0) { |
1405 | markovReportItem.addFailureModeTable(hardwareInducedFailuresTable); |
1406 | } |
1407 | if (networkInducedFailuresTable.getRows().size() > 0) { |
1408 | markovReportItem.addFailureModeTable(networkInducedFailuresTable); |
1409 | } |
1410 | } |
1411 | |
1412 | /** |
1413 | * Retrieves the failure probability of the given failure type. |
1414 | * |
1415 | * @param failureType |
1416 | * the given failure type |
1417 | * @return the failure probability |
1418 | */ |
1419 | private double getFailureTypeProbability( |
1420 | final MarkovFailureType failureType, |
1421 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
1422 | Double failureTypeProbability = cumulatedFailureTypeProbabilities |
1423 | .get(failureType); |
1424 | return (failureTypeProbability == null) ? 0.0 : failureTypeProbability; |
1425 | } |
1426 | |
1427 | /** |
1428 | * Sorts the failure types alphabetically by name. |
1429 | * |
1430 | * @return the sorted list of failure types |
1431 | */ |
1432 | private TreeSet<MarkovFailureType> getFailureTypesSorted( |
1433 | Map<MarkovFailureType, Double> cumulatedFailureTypeProbabilities) { |
1434 | TreeSet<MarkovFailureType> result = new TreeSet<MarkovFailureType>(); |
1435 | for (MarkovFailureType failureType : cumulatedFailureTypeProbabilities |
1436 | .keySet()) { |
1437 | result.add(failureType); |
1438 | } |
1439 | return result; |
1440 | } |
1441 | |
1442 | private String getFormattedProbabilityAsString(double probability) { |
1443 | return String.format("%1$.11f", probability); |
1444 | } |
1445 | |
1446 | private String getFormattedProbabilityAsString(double lowerBound, |
1447 | double upperBound) { |
1448 | MarkovResultApproximation approximation = new MarkovResultApproximation( |
1449 | lowerBound, upperBound); |
1450 | int places = approximation.getAccuracy() + 1; |
1451 | return String.format("%1$." + places + "f - %2$." + places + "f", |
1452 | approximation.getAdjustedLowerBound(), approximation |
1453 | .getAdjustedUpperBound()); |
1454 | } |
1455 | |
1456 | /** |
1457 | * Returns a list of Markov report items that were generated from the Markov |
1458 | * transformation results. |
1459 | * |
1460 | * @return a list of Markov report items |
1461 | */ |
1462 | public List<MarkovReportItem> getMarkovReportItems() { |
1463 | return markovReportItems; |
1464 | } |
1465 | } |