use of org.apache.jmeter.control.Controller in project jmeter by apache.
the class ChangeParent method doAction.
@Override
public void doAction(ActionEvent e) {
String name = ((Component) e.getSource()).getName();
GuiPackage guiPackage = GuiPackage.getInstance();
JMeterTreeNode currentNode = guiPackage.getTreeListener().getCurrentNode();
if (!(currentNode.getUserObject() instanceof Controller)) {
Toolkit.getDefaultToolkit().beep();
return;
}
try {
guiPackage.updateCurrentNode();
TestElement controller = guiPackage.createTestElement(name);
changeParent(controller, guiPackage, currentNode);
} catch (Exception err) {
Toolkit.getDefaultToolkit().beep();
log.error("Failed to change parent", err);
}
}
use of org.apache.jmeter.control.Controller in project jmeter by apache.
the class TestCompiler method saveTransactionControllerConfigs.
private void saveTransactionControllerConfigs(TransactionController tc) {
List<ConfigTestElement> configs = new LinkedList<>();
List<Controller> controllers = new LinkedList<>();
List<SampleListener> listeners = new LinkedList<>();
List<Timer> timers = new LinkedList<>();
List<Assertion> assertions = new LinkedList<>();
LinkedList<PostProcessor> posts = new LinkedList<>();
LinkedList<PreProcessor> pres = new LinkedList<>();
for (int i = stack.size(); i > 0; i--) {
addDirectParentControllers(controllers, stack.get(i - 1));
for (Object item : testTree.list(stack.subList(0, i))) {
if (item instanceof SampleListener) {
listeners.add((SampleListener) item);
}
if (item instanceof Assertion) {
assertions.add((Assertion) item);
}
}
}
SamplePackage pack = new SamplePackage(configs, listeners, timers, assertions, posts, pres, controllers);
pack.setSampler(new TransactionSampler(tc, tc.getName()));
pack.setRunningVersion(true);
transactionControllerConfigMap.put(tc, pack);
}
use of org.apache.jmeter.control.Controller in project jmeter by apache.
the class TestCompiler method subtractNode.
/** {@inheritDoc} */
@Override
public void subtractNode() {
if (log.isDebugEnabled()) {
log.debug("Subtracting node, stack size = {}", stack.size());
}
TestElement child = stack.getLast();
trackIterationListeners(stack);
if (child instanceof Sampler) {
saveSamplerConfigs((Sampler) child);
} else if (child instanceof TransactionController) {
saveTransactionControllerConfigs((TransactionController) child);
}
stack.removeLast();
if (!stack.isEmpty()) {
TestElement parent = stack.getLast();
boolean duplicate = false;
// Bug 53750: this condition used to be in ObjectPair#addTestElements()
if (parent instanceof Controller && (child instanceof Sampler || child instanceof Controller)) {
if (parent instanceof TestCompilerHelper) {
TestCompilerHelper te = (TestCompilerHelper) parent;
duplicate = !te.addTestElementOnce(child);
} else {
// this is only possible for 3rd party controllers by default
ObjectPair pair = new ObjectPair(child, parent);
synchronized (PAIRING) {
// Called from multiple threads
if (!PAIRING.contains(pair)) {
parent.addTestElement(child);
PAIRING.add(pair);
} else {
duplicate = true;
}
}
}
}
if (duplicate) {
if (log.isWarnEnabled()) {
log.warn("Unexpected duplicate for {} and {}", parent.getClass(), child.getClass());
}
}
}
}
use of org.apache.jmeter.control.Controller in project jmeter by apache.
the class JMeterThread method triggerEndOfLoopOnParentControllers.
/**
* Trigger end of loop on parent controllers up to Thread Group
* @param sam Sampler Base sampler
* @param threadContext
*/
private void triggerEndOfLoopOnParentControllers(Sampler sam, JMeterContext threadContext) {
TransactionSampler transactionSampler = null;
if (sam instanceof TransactionSampler) {
transactionSampler = (TransactionSampler) sam;
}
Sampler realSampler = findRealSampler(sam);
if (realSampler == null) {
throw new IllegalStateException("Got null subSampler calling findRealSampler for:" + (sam != null ? sam.getName() : "null") + ", sam:" + sam);
}
// Find parent controllers of current sampler
FindTestElementsUpToRootTraverser pathToRootTraverser = new FindTestElementsUpToRootTraverser(realSampler);
testTree.traverse(pathToRootTraverser);
// Trigger end of loop condition on all parent controllers of current sampler
List<Controller> controllersToReinit = pathToRootTraverser.getControllersToRoot();
for (Controller parentController : controllersToReinit) {
if (parentController instanceof AbstractThreadGroup) {
AbstractThreadGroup tg = (AbstractThreadGroup) parentController;
tg.startNextLoop();
} else {
parentController.triggerEndOfLoop();
}
}
// then we still need to report the Transaction in error (and create the sample result)
if (transactionSampler != null) {
SamplePackage transactionPack = compiler.configureTransactionSampler(transactionSampler);
doEndTransactionSampler(transactionSampler, null, transactionPack, threadContext);
}
}
use of org.apache.jmeter.control.Controller in project jmeter by apache.
the class AbstractThreadGroup method initialize.
/** {@inheritDoc} */
@Override
public void initialize() {
Controller c = getSamplerController();
JMeterProperty property = c.getProperty(TestElement.NAME);
// Copy our name into that of the controller
property.setObjectValue(getName());
// otherwise name reverts
property.setRunningVersion(property.isRunningVersion());
c.initialize();
}
Aggregations