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

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

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

JMeterContext.isSamplingStarted介绍

暂无

代码示例

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

/**
 * Add a cookie.
 *
 * @param c cookie to be added
 */
public void add(Cookie c) {
  String cv = c.getValue();
  String cn = c.getName();
  removeMatchingCookies(c); // Can't have two matching cookies
  if (DELETE_NULL_COOKIES && (null == cv || cv.length()==0)) {
    if (log.isDebugEnabled()) {
      log.debug("Dropping cookie with null value {}", c.toString());
    }
  } else {
    if (log.isDebugEnabled()) {
      log.debug("Add cookie to store {}", c.toString());
    }
    getCookies().addItem(c);
    if (SAVE_COOKIES)  {
      JMeterContext context = getThreadContext();
      if (context.isSamplingStarted()) {
        context.getVariables().put(COOKIE_NAME_PREFIX+cn, cv);
      }
    }
  }
}

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

/**
 * Executes the function (and caches the value for the duration of the test
 * iteration) if the property is a running version. Otherwise, the raw
 * string representation of the function is provided.
 *
 * @see JMeterProperty#getStringValue()
 */
@Override
public String getStringValue() {
  JMeterContext ctx = JMeterContextService.getContext();// Expensive, so
                              // do
  // once
  if (!isRunningVersion() /*|| !ctx.isSamplingStarted()*/) {
    log.debug("Not running version, return raw function string");
    return function.getRawParameters();
  }
  if(!ctx.isSamplingStarted()) {
    return function.execute();
  }
  log.debug("Running version, executing function");
  int iter = ctx.getVariables() != null ? ctx.getVariables().getIteration() : -1;
  if (iter < testIteration) {
    testIteration = -1;
  }
  if (iter > testIteration || cacheValue == null) {
    testIteration = iter;
    cacheValue = function.execute();
  }
  return cacheValue;
}

代码示例来源: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

相关文章