类 Locust

java.lang.Object
com.github.myzhan.locust4j.Locust

public class Locust extends Object
Locust class exposes all the APIs of locust4j. Use Locust.getInstance() to get a Locust singleton.
作者:
myzhan
  • 方法详细资料

    • getInstance

      public static Locust getInstance()
      Get the locust singleton.
      返回:
      a Locust singleton
      从以下版本开始:
      1.0.0
    • setMasterHost

      public void setMasterHost(String masterHost)
      Set the master host.
      参数:
      masterHost - the master host
      从以下版本开始:
      1.0.0
    • setMasterPort

      public void setMasterPort(int masterPort)
      Set the master port.
      参数:
      masterPort - the master port
      从以下版本开始:
      1.0.0
    • setMaxRPS

      public void setMaxRPS(long maxRPS)
      Limit max PRS that locust4j can generator.
      参数:
      maxRPS - max rps
      从以下版本开始:
      1.0.0
    • getRateLimiter

      public AbstractRateLimiter getRateLimiter()
      Get the rate limiter
      返回:
      rateLimiter
      从以下版本开始:
      1.0.3
    • setRateLimiter

      public void setRateLimiter(AbstractRateLimiter rateLimiter)
      Set the rate limiter
      参数:
      rateLimiter - builtin or custom rate limiter
      从以下版本开始:
      1.0.3
    • isRateLimitEnabled

      public boolean isRateLimitEnabled()
      Return rateLimitEnabled
      返回:
      is rate limiter enabled?
      从以下版本开始:
      1.0.3
    • isVerbose

      public boolean isVerbose()
      已过时。
      Since 1.0.8, we use slf4j as a logging facade without a particular logging framework.
      返回:
      is it verbose?
      从以下版本开始:
      1.0.2
    • setVerbose

      public void setVerbose(boolean v)
      已过时。
      Since 1.0.8, we use slf4j as a logging facade without a particular logging framework.
      Print out the internal log of locust4j, or not.
      参数:
      v - set true to print out
      从以下版本开始:
      1.0.2
    • setRunner

      protected void setRunner(Runner runner)
    • getRunner

      protected Runner getRunner()
    • run

      public void run(AbstractTask... tasks)
      Add tasks to Runner, connect to master and wait for messages of master.
      参数:
      tasks - test tasks
      从以下版本开始:
      1.0.0
    • run

      public void run(List<AbstractTask> tasks)
      Add tasks to Runner, connect to master and wait for messages of master.
      参数:
      tasks - test tasks
      从以下版本开始:
      1.0.0
    • dryRun

      public void dryRun(AbstractTask... tasks)
      Run tasks without connecting to master.
      参数:
      tasks - test tasks
      从以下版本开始:
      1.0.0
    • dryRun

      public void dryRun(List<AbstractTask> tasks)
      Run tasks without connecting to master.
      参数:
      tasks - test tasks
      从以下版本开始:
      1.0.0
    • stop

      public void stop()
      Stop locust
      从以下版本开始:
      1.0.7
    • recordSuccess

      public void recordSuccess(String requestType, String name, long responseTime, long contentLength)
      Add a successful record, locust4j will collect it, calculate things like RPS, and report to master.
      参数:
      requestType - locust use request type to classify test results
      name - like request type, used by locust to classify test results
      responseTime - how long does it take for a single test scenario, in millis
      contentLength - content length in bytes
      从以下版本开始:
      1.0.0
    • recordFailure

      public void recordFailure(String requestType, String name, long responseTime, String error)
      Add a failed record, locust4j will collect it, and report to master.
      参数:
      requestType - locust use request type to classify test results
      name - like request type, used by locust to classify test results
      responseTime - how long does it take for a single test scenario, in millis
      error - error message
      从以下版本开始:
      1.0.0
    • getRemoteParam

      public Object getRemoteParam(String key)
      Get remote params sent by the master, which will be set before spawning begins. But Locust has not documentations about the data protocol. It may change and this method will return null with the same key.
      参数:
      key - remote param key
      返回:
      remote param value
      从以下版本开始:
      1.0.11