org.apache.jmeter.threads.JMeterContext.getThreadGroup()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.apache.jmeter.threads.JMeterContext.getThreadGroup()方法的一些代码示例,展示了JMeterContext.getThreadGroup()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMeterContext.getThreadGroup()方法的具体详情如下:
包路径:org.apache.jmeter.threads.JMeterContext
类名称:JMeterContext
方法名:getThreadGroup

JMeterContext.getThreadGroup介绍

暂无

代码示例

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

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));
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_functions

@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();
}

代码示例来源:origin: undera/jmeter-plugins

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();
  }
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

delay = Math.round(JMeterContextService.getContext().getThreadGroup().getNumberOfThreads() * msPerRequest);
break;
  JMeterContextService.getContext().getThreadGroup();
ThroughputInfo groupInfo = threadGroupsInfoMap.get(group);
if (groupInfo == null) {

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

@Override
public void threadStarted() {
  if(getGroupSize() == 0) {
    int numThreadsInGroup = JMeterContextService.getContext().getThreadGroup().getNumThreads();
    // Unique Barrier creation ensured by synchronized setup
    this.barrier.setup(numThreadsInGroup);
  }
}

代码示例来源:origin: undera/jmeter-plugins

JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

/**
 * 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());
  }
}

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

break;
case CSVDataSetBeanInfo.SHARE_GROUP:
  alias = fileName+"@"+System.identityHashCode(context.getThreadGroup());
  break;
case CSVDataSetBeanInfo.SHARE_THREAD:

代码示例来源:origin: undera/jmeter-plugins

/**
 * 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());
}

代码示例来源:origin: kg.apc/jmeter-plugins-cmn-jmeter

/**
 * 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());
}

代码示例来源:origin: undera/jmeter-plugins

/**
 * 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

代码示例来源:origin: johrstrom/jmeter-prometheus-plugin

threadCollector.set(JMeterContextService.getContext().getThreadGroup().getNumberOfThreads());

相关文章