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

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

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

JMeterContextService.getThreadCounts介绍

暂无

代码示例

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

/**
 * @return finished threads
 */
public int getFinishedThreads() {
  return JMeterContextService.getThreadCounts().finishedThreads;
}

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

/**
 * @return started threads
 */
public int getStartedThreads() {
  return JMeterContextService.getThreadCounts().startedThreads;
}

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

/**
 * Add a {@link SampleResult} to be used in the statistics
 * @param result {@link SampleResult} not used
 */
public synchronized void add(SampleResult result) {
  usersStats.addValue(JMeterContextService.getThreadCounts().activeThreads);
}

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

sb.append(')');
if ("+".equals(type)) {
  ThreadCounts tc = JMeterContextService.getThreadCounts();
  sb.append(" Active: ");
  sb.append(tc.activeThreads);

代码示例来源:origin: NovatecConsulting/JMeter-InfluxDB-Writer

@Override
public void teardownTest(BackendListenerContext context) throws Exception {
  LOGGER.info("Shutting down influxDB scheduler...");
  scheduler.shutdown();
  addVirtualUsersMetrics(0, 0, 0, 0, JMeterContextService.getThreadCounts().finishedThreads);
  Point endPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
      .tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build();
  exportFileWriter.append(endPoint.lineProtocol());
  exportFileWriter.newLine();
  
  try {
    scheduler.awaitTermination(30, TimeUnit.SECONDS);
    LOGGER.info("influxDB scheduler terminated!");
  } catch (InterruptedException e) {
    LOGGER.error("Error waiting for end of scheduler");
  }
  samplersToFilter.clear();
  exportFileWriter.close();
  super.teardownTest(context);
}

代码示例来源:origin: NovatecConsulting/JMeter-InfluxDB-Writer

/**
 * Periodically writes virtual users metrics to influxDB.
 */
public void run() {
  try {
    ThreadCounts tc = JMeterContextService.getThreadCounts();
    addVirtualUsersMetrics(getUserMetrics().getMinActiveThreads(), getUserMetrics().getMeanActiveThreads(), getUserMetrics().getMaxActiveThreads(), tc.startedThreads, tc.finishedThreads);
  } catch (Exception e) {
    LOGGER.error("Failed writing to influx", e);
  }
}

代码示例来源:origin: NovatecConsulting/JMeter-InfluxDB-Writer

/**
 * Periodically writes virtual users metrics to influxDB.
 */
public void run() {
  try {
    ThreadCounts tc = JMeterContextService.getThreadCounts();
    addVirtualUsersMetrics(getUserMetrics().getMinActiveThreads(), getUserMetrics().getMeanActiveThreads(), getUserMetrics().getMaxActiveThreads(), tc.startedThreads, tc.finishedThreads);
  } catch (Exception e) {
    LOGGER.error("Failed writing to influx", e);
  }
}

代码示例来源:origin: NovatecConsulting/JMeter-InfluxDB-Writer

@Override
public void teardownTest(BackendListenerContext context) throws Exception {
  LOGGER.info("Shutting down influxDB scheduler...");
  scheduler.shutdown();
  addVirtualUsersMetrics(0,0,0,0,JMeterContextService.getThreadCounts().finishedThreads);
  influxDB.write(
      influxDBConfig.getInfluxDatabase(),
      influxDBConfig.getInfluxRetentionPolicy(),
      Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
          .tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED)
          .tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName)
          .tag(TestStartEndMeasurement.Tags.RUN_ID, runId)
          .tag(TestStartEndMeasurement.Tags.TEST_NAME, testName)
          .addField(TestStartEndMeasurement.Fields.PLACEHOLDER,"1")
          .build());
  influxDB.disableBatch();
  try {
    scheduler.awaitTermination(30, TimeUnit.SECONDS);
    LOGGER.info("influxDB scheduler terminated!");
  } catch (InterruptedException e) {
    LOGGER.error("Error waiting for end of scheduler");
  }
  samplersToFilter.clear();
  super.teardownTest(context);
}

相关文章