1 | package de.uka.ipd.sdq.prototype.framework; |
2 | |
3 | import de.uka.ipd.sdq.prototype.framework.utils.RunProperties; |
4 | import de.uka.ipd.sdq.sensorframework.entities.Experiment; |
5 | import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun; |
6 | import de.uka.ipd.sdq.simucomframework.variables.StackContext; |
7 | |
8 | public abstract class AbstractOpenScenarioThread extends AbstractScenarioThread { |
9 | |
10 | private RunProperties runProps; |
11 | private String interarrivalTime; |
12 | |
13 | public AbstractOpenScenarioThread(Experiment exp, |
14 | ExperimentRun expRun, |
15 | String scenarioName, RunProperties runProps, |
16 | String interarrivalTimeInSec) { |
17 | super(exp, expRun, scenarioName, runProps); |
18 | this.runProps = runProps; |
19 | this.interarrivalTime = interarrivalTimeInSec; |
20 | |
21 | } |
22 | |
23 | @Override |
24 | protected void runAndMeasureUsageScenarioIteration() { |
25 | |
26 | new Thread() { |
27 | public void run() { |
28 | if (logger.isDebugEnabled()) { |
29 | logger.debug("New Thread: Open Scenario (" + scenarioName + "), interarrival time: " + interarrivalTime); |
30 | } |
31 | |
32 | logger.debug("Starting my scenario"); |
33 | long start = System.nanoTime(); |
34 | logger.debug("New Thread: Open Scenario (" + scenarioName + "), inner thread"); |
35 | |
36 | getScenarioRunner(runProps).run(); |
37 | |
38 | takeScenarioMeasurement(start); |
39 | logger.debug("Finished my scenario"); |
40 | |
41 | } |
42 | }.start(); |
43 | |
44 | try { |
45 | |
46 | Double interarrivalTime = StackContext.evaluateStatic(this.interarrivalTime, Double.class) * 1000.0; |
47 | Thread.sleep(interarrivalTime.longValue()); |
48 | |
49 | } catch (InterruptedException e) { |
50 | e.printStackTrace(); |
51 | } |
52 | |
53 | } |
54 | |
55 | } |
56 | |