private EventProducer getEventProducer() { AbstractThreadGroup tg = getThreadContext().getThreadGroup(); Long seed = randomSeed == null || randomSeed == 0 ? null : randomSeed; return groupEvents.computeIfAbsent(tg, x -> new ConstantPoissonProcessGenerator( () -> PreciseThroughputTimer.this.getThroughput() / throughputPeriod, batchSize, batchThreadDelay, this, exactLimit, allowedThroughputSurplus, seed, true)); }
@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(); } }
delay = Math.round(JMeterContextService.getContext().getThreadGroup().getNumberOfThreads() * msPerRequest); break; JMeterContextService.getContext().getThreadGroup(); ThroughputInfo groupInfo = threadGroupsInfoMap.get(group); if (groupInfo == null) {
@Override public void threadStarted() { if(getGroupSize() == 0) { int numThreadsInGroup = JMeterContextService.getContext().getThreadGroup().getNumThreads(); // Unique Barrier creation ensured by synchronized setup this.barrier.setup(numThreadsInGroup); } }
JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);
/** * 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()); } }
break; case CSVDataSetBeanInfo.SHARE_GROUP: alias = fileName+"@"+System.identityHashCode(context.getThreadGroup()); break; case CSVDataSetBeanInfo.SHARE_THREAD:
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); }
/** * Update the worker thread jmeter context with the main thread one * @param isInit if true the context a full copy is done, if false only update is done */ private void syncContext(boolean isInit) { // jmeter context synchronisation JMeterContext current = JMeterContextService.getContext(); JMeterContext ctx = this.getThreadContext(); if (isInit) { current.setCurrentSampler(ctx.getCurrentSampler()); current.setEngine(ctx.getEngine()); current.setRestartNextLoop(ctx.isRestartNextLoop()); current.setSamplingStarted(ctx.isSamplingStarted()); current.setThread(ctx.getThread()); current.setThreadGroup(ctx.getThreadGroup()); current.setThreadNum(ctx.getThreadNum()); } current.setVariables(ctx.getVariables()); current.setPreviousResult(ctx.getPreviousResult()); //current.getSamplerContext().putAll(ctx.getSamplerContext()); } @Override
threadCollector.set(JMeterContextService.getContext().getThreadGroup().getNumberOfThreads());