1 | package de.uka.ipd.sdq.simucomframework.exceptions; |
2 | |
3 | import de.uka.ipd.sdq.reliability.core.FailureStatistics; |
4 | import de.uka.ipd.sdq.reliability.core.MarkovFailureType; |
5 | |
6 | /** |
7 | * Represents a failure-on-demand occurrence during the simulation. |
8 | * |
9 | * This mechanism is used in the simulation to indicate that a failure-on-demand |
10 | * has occurred during service execution. The executing SimProcess (an |
11 | * OpenWorkloadUser, ClosedWorkloadUser or ForkedBehaviourProcess) cancels its |
12 | * associated control and data flow. The central FailureStatistics object is |
13 | * updated to log the failure-on-demand occurrence. |
14 | * |
15 | * @author brosch |
16 | * |
17 | */ |
18 | public class FailureException extends RuntimeException { |
19 | private static final long serialVersionUID = -6074335938145682592L; |
20 | |
21 | /** |
22 | * Indicates a failure-on-demand occurrence of the given failure type. |
23 | * |
24 | * @param failureType |
25 | * the failure type identification. |
26 | */ |
27 | public static void raise(final MarkovFailureType failureType) { |
28 | FailureStatistics.getInstance() |
29 | .increaseTotalFailureCounter(failureType); |
30 | throw new FailureException(failureType); |
31 | } |
32 | |
33 | /** |
34 | * The failure type. |
35 | */ |
36 | private MarkovFailureType failureType; |
37 | |
38 | /** |
39 | * A private constructor prevents the direct creation of an exception and |
40 | * enforces using the raise()-method instead. |
41 | * |
42 | * @param failureType |
43 | * the failure type identification |
44 | */ |
45 | private FailureException(final MarkovFailureType failureType) { |
46 | this.failureType = failureType; |
47 | } |
48 | |
49 | /** |
50 | * Retrieves the failure type identification. |
51 | * |
52 | * @return the failure type identification |
53 | */ |
54 | public MarkovFailureType getFailureType() { |
55 | return failureType; |
56 | } |
57 | } |