use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.
the class GenericController method nextIsAController.
/**
* Called by {@link #next()} if the element is a Controller, and returns the
* next sampler from the controller. If this is <code>null</code>, then
* updates the current pointer and makes recursive call to {@link #next()}.
*
* @param controller the current <em>next</em> element
* @return the next sampler
* @throws NextIsNullException when the end of the list has already been reached
*/
protected Sampler nextIsAController(Controller controller) throws NextIsNullException {
Sampler sampler = controller.next();
if (sampler == null) {
currentReturnedNull(controller);
sampler = next();
}
return sampler;
}
use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.
the class GenericController method next.
/**
* <p>
* Determines the next sampler to be processed.
* </p>
*
* <p>
* If {@link #isDone()} is <code>true</code>, returns null.
* </p>
*
* <p>
* Gets the list element using current pointer.
* If this is <code>null</code>, calls {@link #nextIsNull()}.
* </p>
*
* <p>
* If the list element is a {@link Sampler}, calls {@link #nextIsASampler(Sampler)},
* otherwise calls {@link #nextIsAController(Controller)}
* </p>
*
* <p>
* If any of the called methods throws {@link NextIsNullException}, returns <code>null</code>,
* otherwise the value obtained above is returned.
* </p>
*
* @return the next sampler or <code>null</code>
*/
@Override
public Sampler next() {
fireIterEvents();
log.debug("Calling next on: {}", GenericController.class);
if (isDone()) {
return null;
}
Sampler returnValue = null;
try {
TestElement currentElement = getCurrentElement();
setCurrentElement(currentElement);
if (currentElement == null) {
returnValue = nextIsNull();
} else {
if (currentElement instanceof Sampler) {
returnValue = nextIsASampler((Sampler) currentElement);
} else {
// must be a controller
returnValue = nextIsAController((Controller) currentElement);
}
}
} catch (NextIsNullException e) {
// NOOP
}
return returnValue;
}
use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.
the class TransactionController method triggerEndOfLoop.
/**
* @see org.apache.jmeter.control.GenericController#triggerEndOfLoop()
*/
@Override
public void triggerEndOfLoop() {
if (!isGenerateParentSample()) {
if (res != null) {
res.setIdleTime(pauseTime + res.getIdleTime());
res.sampleEnd();
res.setSuccessful(TRUE.equals(JMeterContextService.getContext().getVariables().get(JMeterThread.LAST_SAMPLE_OK)));
res.setResponseMessage(TransactionController.NUMBER_OF_SAMPLES_IN_TRANSACTION_PREFIX + calls + ", number of failing samples : " + noFailingSamples);
notifyListeners();
}
} else {
Sampler subSampler = transactionSampler.getSubSampler();
// update them with SubSamplerResult
if (subSampler instanceof TransactionSampler) {
TransactionSampler tc = (TransactionSampler) subSampler;
transactionSampler.addSubSamplerResult(tc.getTransactionResult());
}
transactionSampler.setTransactionDone();
// This transaction is done
transactionSampler = null;
}
super.triggerEndOfLoop();
}
use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.
the class CompoundVariable method execute.
public String execute() {
if (isDynamic || permanentResults == null) {
JMeterContext context = JMeterContextService.getContext();
SampleResult previousResult = context.getPreviousResult();
Sampler currentSampler = context.getCurrentSampler();
return execute(previousResult, currentSampler);
}
// $NON-NLS-1$
return permanentResults;
}
use of org.apache.jmeter.samplers.Sampler in project jmeter by apache.
the class AddThinkTimeBetweenEachStep method addThinkTimeToChildren.
/**
* Add Think Time to children of parentNode
* @param guiPackage {@link GuiPackage}
* @param parentNode Parent node of elements on which we add think times
* @throws IllegalUserActionException
*/
private void addThinkTimeToChildren(GuiPackage guiPackage, JMeterTreeNode parentNode) throws IllegalUserActionException {
guiPackage.updateCurrentNode();
boolean insertThinkTime = false;
try {
int index = 0;
while (true) {
if (index == parentNode.getChildCount()) {
index++;
break;
}
JMeterTreeNode childNode = (JMeterTreeNode) parentNode.getChildAt(index);
Object userObject = childNode.getUserObject();
if (userObject instanceof Sampler || userObject instanceof Controller) {
insertThinkTime = true;
}
if (insertThinkTime) {
JMeterTreeNode[] nodes = createThinkTime(guiPackage, parentNode);
if (nodes.length != 2) {
throw new IllegalArgumentException("Invalid Think Time, expected 2 nodes, got:" + nodes.length);
}
index++;
addNodesToTreeHierachically(guiPackage, parentNode, nodes, index);
insertThinkTime = false;
}
index++;
}
} catch (Exception ex) {
throw new IllegalUserActionException("Cannot add think times", ex);
}
}
Aggregations