| 1 | package de.uka.ipd.sdq.simucomframework.resources; |
| 2 | |
| 3 | import de.uka.ipd.sdq.reliability.core.FailureStatistics; |
| 4 | import de.uka.ipd.sdq.scheduler.SchedulerModel; |
| 5 | import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEventDelegator; |
| 6 | |
| 7 | /** |
| 8 | * This event indicates a timeout of a process waiting at a passive resource. |
| 9 | * |
| 10 | * @author brosch |
| 11 | * |
| 12 | */ |
| 13 | public class PassiveResourceTimeoutEvent extends AbstractSimEventDelegator<SimpleWaitingProcess> { |
| 14 | |
| 15 | /** |
| 16 | * The waiting process. |
| 17 | */ |
| 18 | private SimpleWaitingProcess process; |
| 19 | |
| 20 | /** |
| 21 | * The resource. |
| 22 | */ |
| 23 | private SimSimpleFairPassiveResource resource; |
| 24 | |
| 25 | /** |
| 26 | * Creates a new timeout event. |
| 27 | * |
| 28 | * @param model |
| 29 | * the SimuCom model |
| 30 | * @param resource |
| 31 | * the involved passive resource |
| 32 | * @param process |
| 33 | * the waiting process |
| 34 | */ |
| 35 | public PassiveResourceTimeoutEvent(final SchedulerModel model, |
| 36 | final SimSimpleFairPassiveResource resource, |
| 37 | final SimpleWaitingProcess process) { |
| 38 | super(model, resource.getName()); |
| 39 | this.resource = resource; |
| 40 | this.process = process; |
| 41 | } |
| 42 | |
| 43 | private static int count = 0; |
| 44 | |
| 45 | /* |
| 46 | * (non-Javadoc) |
| 47 | * |
| 48 | * @see |
| 49 | * de.uka.ipd.sdq.simucomframework.abstractSimEngine.SimEvent#eventRoutine |
| 50 | * (de.uka.ipd.sdq.simucomframework.abstractSimEngine.IEntityDelegate) |
| 51 | */ |
| 52 | public void eventRoutine(SimpleWaitingProcess who) { |
| 53 | |
| 54 | // Check if the process is still waiting: |
| 55 | if (!resource.isWaiting(process)) { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | // Trigger a timeout of the waiting process: |
| 60 | resource.remove(process); |
| 61 | process.getProcess().timeout( |
| 62 | FailureStatistics.getInstance().getResourceTimeoutFailureType( |
| 63 | resource.getAssemblyContextID(), |
| 64 | resource.getPassiveResourceID()).getId()); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Retrieves the waiting process. |
| 69 | * |
| 70 | * @return the waiting process |
| 71 | */ |
| 72 | public SimpleWaitingProcess getProcess() { |
| 73 | return process; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Retrieves the passive resource. |
| 78 | * |
| 79 | * @return the passive resource |
| 80 | */ |
| 81 | public SimSimpleFairPassiveResource getResource() { |
| 82 | return resource; |
| 83 | } |
| 84 | |
| 85 | } |