private void notifyListeners(List<SampleListener> listeners, SampleResult result) { SampleEvent event = new SampleEvent(result, threadGroup.getName(), threadVars); notifier.notifyListeners(event, listeners); }
@Override /** * Get current thread group using sampler's context */ public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterContext context; if (currentSampler != null) { context = currentSampler.getThreadContext(); } else { context = JMeterContextService.getContext(); } return context.getThreadGroup().getName(); }
protected void stopTest() { if (stopTries > 30) { throw new IllegalStateException("More than 30 retries - stopping with exception"); } if (lastStopTry == time) { return; } log.info("No further RPS schedule, asking threads to stop..."); lastStopTry = time; stopTries++; if (stopTries > 10) { log.info("Tries more than 10, stopping engine NOW!"); StandardJMeterEngine.stopEngineNow(); } else if (stopTries > 5) { log.info("Tries more than 5, shutting down engine!"); StandardJMeterEngine.stopEngine(); } else if (stopTries > 3) { AbstractThreadGroup threadGroup = JMeterContextService.getContext().getThreadGroup(); log.info("Tries more than 3, hard stopping threads of Thread Group : {}", threadGroup.getName()); threadGroup.tellThreadsToStop(); } else { AbstractThreadGroup threadGroup = JMeterContextService.getContext().getThreadGroup(); log.info("Stopping gracefuly threads of Thread Group : {}", threadGroup.getName()); threadGroup.stop(); } }
JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);
boolean onErrorStopThread = group.getOnErrorStopThread(); boolean onErrorStartNextLoop = group.getOnErrorStartNextLoop(); String groupName = group.getName(); log.info("Starting {} threads for group {}.", numThreads, groupName); if (onErrorStopTest) { group.start(groupCount, notifier, threadGroupTree, this); } catch (JMeterStopTestException ex) { // NOSONAR Reported by log JMeterUtils.reportErrorToUser("Error occurred starting thread group :" + group.getName()+ ", error message:"+ex.getMessage() +", \r\nsee log file for more details", ex); return; // no point continuing
/** {@inheritDoc} */ @Override public void initialize() { Controller c = getSamplerController(); JMeterProperty property = c.getProperty(TestElement.NAME); property.setObjectValue(getName()); // Copy our name into that of the controller property.setRunningVersion(property.isRunningVersion());// otherwise name reverts c.initialize(); }
/** * Create additional SampleEvent in NON Parent Mode */ protected void notifyListeners() { // TODO could these be done earlier (or just once?) JMeterContext threadContext = getThreadContext(); JMeterVariables threadVars = threadContext.getVariables(); SamplePackage pack = (SamplePackage) threadVars.getObject(JMeterThread.PACKAGE_OBJECT); if (pack == null) { // If child of TransactionController is a ThroughputController and TPC does // not sample its children, then we will have this // TODO Should this be at warn level ? log.warn("Could not fetch SamplePackage"); } else { SampleEvent event = new SampleEvent(res, threadContext.getThreadGroup().getName(),threadVars, true); // We must set res to null now, before sending the event for the transaction, // so that we can ignore that event in our sampleOccured method res = null; lnf.notifyListeners(event, pack.getSampleListeners()); } }
AbstractThreadGroup group = setupIter.next(); groupCount++; String groupName = group.getName(); log.info("Starting setUp ThreadGroup: {} : {} ", groupCount, groupName); startThreadGroup(group, groupCount, setupSearcher, testLevelElements, notifier); String groupName = group.getName(); log.info("Starting ThreadGroup: {} : {}", groupCount, groupName); startThreadGroup(group, groupCount, searcher, testLevelElements, notifier); AbstractThreadGroup group = postIter.next(); groupCount++; String groupName = group.getName(); log.info("Starting tearDown ThreadGroup: {} : {}", groupCount, groupName); startThreadGroup(group, groupCount, postSearcher, testLevelElements, notifier);