Class Workload.Builder

java.lang.Object
org.acemq.workloads.Workload.Builder
Enclosing class:
Workload

public static final class Workload.Builder extends Object
Builds a Workload.
  • Method Details

    • topology

      public Workload.Builder topology(Consumer<TopologySpec> spec)
      Parameters:
      spec - what the messages travel through
      Returns:
      this builder
    • publishers

      public Workload.Builder publishers(Consumer<PublisherSpec> spec)
      Parameters:
      spec - how the load is offered
      Returns:
      this builder
    • consumers

      public Workload.Builder consumers(Consumer<ConsumerSpec> spec)
      Parameters:
      spec - how the load is consumed
      Returns:
      this builder
    • warmup

      public Workload.Builder warmup(Duration warmup)
      Parameters:
      warmup - how long to run before measuring anything
      Returns:
      this builder
    • runFor

      public Workload.Builder runFor(Duration duration)
      Parameters:
      duration - how long the measured window lasts
      Returns:
      this builder
    • runUntilStopped

      public Workload.Builder runUntilStopped()
      Measure until something stops the run.

      For a workload that exists to occupy a broker rather than to answer a question with a number — a generator kept beside a cluster somebody else is experimenting on, a queue that must have consumers on it for as long as the experiment lasts. Such a run has no natural length, and making it guess one is how it ends early: an experiment that outlasts the guess spends its last minutes against a broker nobody is using, which is the condition the workload was there to prevent.

      It still measures everything it otherwise would, and the report still describes the window that happened rather than the one that was asked for. Stopping is the only way it ends — RunHandle.stop(), or SIGTERM on the command line.

      Returns:
      this builder
    • expect

      public Workload.Builder expect(Rule objective)
      Parameters:
      objective - something the result has to satisfy, from Objective
      Returns:
      this builder
    • rule

      public Workload.Builder rule(Rule rule)
      Parameters:
      rule - an extra check to run against the report
      Returns:
      this builder
    • withoutDefaultRules

      public Workload.Builder withoutDefaultRules()
      Runs without the default rules.

      Worth thinking twice about. The defaults are mostly validity checks, and removing them does not make a run better — it makes a run that silently failed to offer its load look like a successful one.

      Returns:
      this builder
    • management

      public Workload.Builder management(String url, String user, String password)
      The management API, for queue depth and topology facts the AMQP connection cannot see.

      Optional. Without it the report simply omits the queue depth, which is one fewer way to tell a queue that is still draining from messages that were lost.

      Parameters:
      url - the management URL, for example http://localhost:15672
      user - a broker user with the monitoring tag
      password - its password
      Returns:
      this builder
    • build

      public Workload build()
      Returns:
      the workload
    • run

      public WorkloadReport run(String brokerUrl)
      Parameters:
      brokerUrl - an AMQP URL
      Returns:
      the report, building and running in one step