1 | package de.uka.ipd.sdq.simucomframework.usage; |
2 | |
3 | import de.uka.ipd.sdq.reliability.core.FailureStatistics; |
4 | |
5 | /** |
6 | * Class used for executing a closed workload. The class creates as many |
7 | * users as specified and executes them simultaniously |
8 | * @author Steffen Becker |
9 | * |
10 | */ |
11 | public class ClosedWorkload implements IWorkloadDriver { |
12 | |
13 | private int population; |
14 | private IUserFactory userFactory; |
15 | private String usageScenarioId; |
16 | |
17 | /** |
18 | * Constructor of the closed workload driver |
19 | * @param userFactory Factory used to create the users |
20 | * @param population Number of users in the system |
21 | */ |
22 | public ClosedWorkload(IUserFactory userFactory, int population, String usageScenarioId) |
23 | { |
24 | this.population = population; |
25 | this.userFactory = userFactory; |
26 | this.usageScenarioId = usageScenarioId; |
27 | } |
28 | |
29 | /* (non-Javadoc) |
30 | * @see de.uka.ipd.sdq.simucomframework.usage.IWorkloadDriver#run() |
31 | */ |
32 | public void run() { |
33 | FailureStatistics.getInstance().reset(); |
34 | for (int i=0; i<population; i++) { |
35 | IUser user = userFactory.createUser(usageScenarioId); |
36 | user.startUserLife(); |
37 | } |
38 | } |
39 | } |