EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.simucomframework.usage]

COVERAGE SUMMARY FOR SOURCE FILE [OpenWorkload.java]

nameclass, %method, %block, %line, %
OpenWorkload.java0%   (0/1)0%   (0/6)0%   (0/91)0%   (0/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class OpenWorkload0%   (0/1)0%   (0/6)0%   (0/91)0%   (0/31)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/3)
OpenWorkload (SimuComModel, IUserFactory, String, String): void 0%   (0/1)0%   (0/14)0%   (0/5)
generateUser (): IUser 0%   (0/1)0%   (0/13)0%   (0/4)
internalLifeCycle (): void 0%   (0/1)0%   (0/33)0%   (0/11)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
waitForNextUser (): void 0%   (0/1)0%   (0/22)0%   (0/6)

1package de.uka.ipd.sdq.simucomframework.usage;
2 
3import org.apache.log4j.Logger;
4 
5import de.uka.ipd.sdq.reliability.core.FailureStatistics;
6import de.uka.ipd.sdq.scheduler.IActiveResource;
7import de.uka.ipd.sdq.simucomframework.Context;
8import de.uka.ipd.sdq.simucomframework.SimuComSimProcess;
9import de.uka.ipd.sdq.simucomframework.model.SimuComModel;
10 
11/**
12 * Implementation of the workload driver interface for open workloads
13 * 
14 * @author Steffen Becker
15 * 
16 */
17public class OpenWorkload extends SimuComSimProcess implements IWorkloadDriver {
18 
19        private String interArrivalTime;
20        private IUserFactory userFactory;
21        private String usageScenarioId;
22 
23        private static Logger logger = Logger.getLogger(OpenWorkload.class
24                        .getName());
25 
26        /**
27         * Counter for usage scenario runs.
28         */
29 
30        /**
31         * Constructor of the open workload driver
32         * 
33         * @param model
34         *            The simulation model this driver belongs to
35         * @param userFactory
36         *            The factory which is used to bread the users
37         * @param interArrivalTime
38         *            The time to wait between leaving a new user to its fate
39         */
40        public OpenWorkload(SimuComModel model, IUserFactory userFactory,
41                        String interArrivalTime, String usageScenarioId) {
42                super(model, "OpenWorkloadUserMaturationChamber");
43                this.interArrivalTime = interArrivalTime;
44                this.userFactory = userFactory;
45                this.usageScenarioId = usageScenarioId;
46        }
47 
48        public void run() {
49                this.scheduleAt(0);
50        }
51 
52        @Override
53        protected void internalLifeCycle() {
54                FailureStatistics.getInstance().reset();
55 
56                // As long as the simulation is running, new OpenWorkloadUsers are
57                // generated and started:
58                while (getModel().getSimulationControl().isRunning()) {
59                        
60                        try {
61                                // Generate and execute the new user:
62                                generateUser();
63        
64                                // Wait for inter-arrival time:
65                                waitForNextUser();
66                                
67                                // Count the new user:
68                                if (this.getModel().getConfig().getSimulateFailures()) {
69                                        FailureStatistics.getInstance().increaseRunCount();
70                                        FailureStatistics.getInstance().printRunCount(logger);
71                                }
72                        }
73                        catch (OutOfMemoryError e) {
74                                // the system is overloaded. stop simulation
75                                logger.info("Stopping simulation run due to memory constraints.");
76                                getModel().getSimulationControl().stop();
77                        }
78                }
79 
80                // Print failure statistics:
81                // if (this.getModel().getConfig().getSimulateFailures()) {
82                //         FailureStatistics.getInstance().printFailureStatistics(logger);
83                // }
84        }
85 
86        private void waitForNextUser() {
87                double interArrivalTimeSample = (Double) Context.evaluateStatic(
88                                interArrivalTime, Double.class);
89                logger.debug("Waiting for " + interArrivalTimeSample
90                                + " before spawing the next user");
91                this.hold(interArrivalTimeSample);
92        }
93 
94        private IUser generateUser() {
95                logger.debug("Spawning New User...");
96                IUser user = userFactory.createUser(usageScenarioId);
97                user.startUserLife();
98                return user;
99        }
100 
101}

[all classes][de.uka.ipd.sdq.simucomframework.usage]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov