Lines 21-26
Link Here
|
21 |
import java.io.Serializable; |
21 |
import java.io.Serializable; |
22 |
|
22 |
|
23 |
import org.apache.jmeter.samplers.SampleEvent; |
23 |
import org.apache.jmeter.samplers.SampleEvent; |
|
|
24 |
import org.apache.jmeter.samplers.SampleListener; |
24 |
import org.apache.jmeter.samplers.SampleResult; |
25 |
import org.apache.jmeter.samplers.SampleResult; |
25 |
import org.apache.jmeter.samplers.Sampler; |
26 |
import org.apache.jmeter.samplers.Sampler; |
26 |
import org.apache.jmeter.threads.JMeterContext; |
27 |
import org.apache.jmeter.threads.JMeterContext; |
Lines 35-41
Link Here
|
35 |
* Transaction Controller to measure transaction times |
36 |
* Transaction Controller to measure transaction times |
36 |
* |
37 |
* |
37 |
*/ |
38 |
*/ |
38 |
public class TransactionController extends GenericController implements Controller, Serializable { |
39 |
public class TransactionController extends GenericController implements SampleListener, Controller, Serializable { |
39 |
protected static final Logger log = LoggingManager.getLoggerForClass(); |
40 |
protected static final Logger log = LoggingManager.getLoggerForClass(); |
40 |
|
41 |
|
41 |
transient private String threadName; |
42 |
transient private String threadName; |
Lines 75-85
Link Here
|
75 |
log_debug("+++++++++++++++++++++++++++++"); |
76 |
log_debug("+++++++++++++++++++++++++++++"); |
76 |
calls = 0; |
77 |
calls = 0; |
77 |
res = new SampleResult(); |
78 |
res = new SampleResult(); |
|
|
79 |
res.setSampleLabel(getName()); |
80 |
// Assume success |
81 |
res.setSuccessful(true); |
78 |
res.sampleStart(); |
82 |
res.sampleStart(); |
79 |
} |
83 |
} |
80 |
|
84 |
|
81 |
calls++; |
|
|
82 |
|
83 |
returnValue = super.next(); |
85 |
returnValue = super.next(); |
84 |
|
86 |
|
85 |
if (returnValue == null) // Must be the end of the controller |
87 |
if (returnValue == null) // Must be the end of the controller |
Lines 89-99
Link Here
|
89 |
log_debug("already called"); |
91 |
log_debug("already called"); |
90 |
} else { |
92 |
} else { |
91 |
res.sampleEnd(); |
93 |
res.sampleEnd(); |
92 |
res.setSuccessful(true); |
94 |
res.setResponseMessage("Number of samples in transaction : " + calls); |
93 |
res.setSampleLabel(getName()); |
95 |
if(res.isSuccessful()) { |
94 |
res.setResponseCodeOK(); |
96 |
res.setResponseCodeOK(); |
95 |
res.setResponseMessage("Called: " + calls); |
97 |
} |
96 |
res.setThreadName(threadName); |
|
|
97 |
|
98 |
|
98 |
// TODO could these be done earlier (or just once?) |
99 |
// TODO could these be done earlier (or just once?) |
99 |
JMeterContext threadContext = getThreadContext(); |
100 |
JMeterContext threadContext = getThreadContext(); |
Lines 103-114
Link Here
|
103 |
if (pack == null) { |
104 |
if (pack == null) { |
104 |
log.warn("Could not fetch SamplePackage"); |
105 |
log.warn("Could not fetch SamplePackage"); |
105 |
} else { |
106 |
} else { |
106 |
lnf.notifyListeners(new SampleEvent(res, getName()), pack.getSampleListeners()); |
107 |
SampleEvent event = new SampleEvent(res, getName()); |
|
|
108 |
// We must set res to null now, before sending the event for the transaction, |
109 |
// so that we can ignore that event in our sampleOccured method |
110 |
res = null; |
111 |
lnf.notifyListeners(event, pack.getSampleListeners()); |
107 |
} |
112 |
} |
108 |
res = null; |
|
|
109 |
} |
113 |
} |
110 |
} |
114 |
} |
|
|
115 |
else { |
116 |
// We have sampled one of our children |
117 |
calls++; |
118 |
} |
111 |
|
119 |
|
112 |
return returnValue; |
120 |
return returnValue; |
113 |
} |
121 |
} |
|
|
122 |
|
123 |
public void sampleOccurred(SampleEvent se) { |
124 |
// Check if we have are still sampling our children |
125 |
if(res != null) { |
126 |
SampleResult sampleResult = se.getResult(); |
127 |
res.setThreadName(sampleResult.getThreadName()); |
128 |
res.setBytes(res.getBytes() + sampleResult.getBytes()); |
129 |
if(!sampleResult.isSuccessful()) { |
130 |
res.setSuccessful(false); |
131 |
} |
132 |
res.addSubResult(sampleResult); |
133 |
} |
134 |
} |
135 |
|
136 |
public void sampleStarted(SampleEvent e) { |
137 |
} |
138 |
|
139 |
public void sampleStopped(SampleEvent e) { |
140 |
} |
114 |
} |
141 |
} |