public void run() {
try {
initRun();
while (running) {
Sampler sam;
while (running && (sam = controller.next()) != null) {
try {
threadContext.setCurrentSampler(sam);
// Check if we are running a transaction
TransactionSampler transactionSampler = null;
if(sam instanceof TransactionSampler) {
transactionSampler = (TransactionSampler) sam;
}
// Find the package for the transaction
SamplePackage transactionPack = null;
if(transactionSampler != null) {
transactionPack = compiler.configureTransactionSampler(transactionSampler);
// Check if the transaction is done
if(transactionSampler.isTransactionDone()) {
// Get the transaction sample result
SampleResult transactionResult = transactionSampler.getTransactionResult();
transactionResult.setThreadName(threadName);
transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());
// Check assertions for the transaction sample
checkAssertions(transactionPack.getAssertions(), transactionResult);
// Notify listeners with the transaction sample result
notifyListeners(transactionPack.getSampleListeners(), transactionResult);
compiler.done(transactionPack);
// Transaction is done, we do not have a sampler to sample
sam = null;
}
else {
// It is the sub sampler of the transaction that will be sampled
sam = transactionSampler.getSubSampler();
}
}
// Check if we have a sampler to sample
if(sam != null) {
// Get the sampler ready to sample
SamplePackage pack = compiler.configureSampler(sam);
// Hack: save the package for any transaction controllers
threadVars.putObject(PACKAGE_OBJECT, pack);
delay(pack.getTimers());
Sampler sampler = pack.getSampler();
sampler.setThreadContext(threadContext);
sampler.setThreadName(threadName);
TestBeanHelper.prepare(sampler);
// Perform the actual sample
SampleResult result = sampler.sample(null);
// TODO: remove this useless Entry parameter
// If we got any results, then perform processing on the result
if (result != null) {
result.setGroupThreads(threadGroup.getNumberOfThreads());