1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package jtr.runners; |
8 |
| |
9 |
| import jtr.config.jms.JMSConfig; |
10 |
| import jtr.jms.JMSHelper; |
11 |
| import org.apache.log4j.Logger; |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| abstract public class AbstractJMSRunner extends AbstractRunnerAncestor implements IRunnerJMS { |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
14
| public void setJmsConfig(JMSConfig jmsConfig) {
|
32 |
14
| this.jmsConfig = jmsConfig;
|
33 |
| } |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
4914
| public JMSConfig getJmsConfig() {
|
41 |
4914
| return jmsConfig;
|
42 |
| } |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| |
55 |
| |
56 |
700
| public final void run() {
|
57 |
700
| logger = Logger.getLogger(this.getClass().getName());
|
58 |
700
| logger.debug("Running client thread...");
|
59 |
700
| for (currentRun = 0; currentRun < getRuns(); currentRun++) {
|
60 |
| |
61 |
4897
| try {
|
62 |
4899
| logger.debug("Starting run " + currentRun + " in epoch " + epoch);
|
63 |
4899
| if (epoch == 0 && currentRun == 0) {
|
64 |
14
| initializeTimers();
|
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
14
| JMSHelper.inject(this, getJmsConfig());
|
70 |
| } |
71 |
4899
| super.doRunTest();
|
72 |
| } catch (Throwable t) { |
73 |
0
| handleFailure(currentRun, t);
|
74 |
| } |
75 |
| |
76 |
4900
| try {
|
77 |
4900
| if (currentRun < getRuns() - 1) {
|
78 |
4200
| logger.debug("Completed, going to bed for a while... [" + getSleepTime() + " mSecs.]");
|
79 |
4200
| Thread.sleep(getSleepTime());
|
80 |
4198
| logger.debug("Awaken");
|
81 |
| |
82 |
4199
| logger.debug("Check for reinitialization");
|
83 |
4195
| if (paramsAssigner.requiresReinitialization()) {
|
84 |
| |
85 |
0
| logger.debug("Reinitialization required...");
|
86 |
0
| paramsAssigner.reAssign(clean());
|
87 |
0
| logger.debug("... reinitialized");
|
88 |
| } else { |
89 |
| |
90 |
4197
| logger.debug("Reinitialization not required");
|
91 |
| } |
92 |
| } |
93 |
| } catch (InterruptedException e) { |
94 |
0
| String msg = "The current test-thread " + Thread.currentThread().getName() + " received an interrupt while sleeping";
|
95 |
0
| logger.warn(msg, e);
|
96 |
| } |
97 |
| } |
98 |
| |
99 |
700
| logger.debug("Completed all the runs [" + getRuns() + "], going back into the pool");
|
100 |
700
| logger.debug("Getting IPoolManager instance...");
|
101 |
700
| pool.getPoolManager().backIntoPool(this);
|
102 |
| } |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| |
108 |
| |
109 |
4899
| public int getCurrentRun() {
|
110 |
4899
| return currentRun;
|
111 |
| } |
112 |
| |
113 |
| private int currentRun; |
114 |
| private JMSConfig jmsConfig; |
115 |
| } |