Record Class ScenarioFile

java.lang.Object
java.lang.Record
org.acemq.workloads.scenario.ScenarioFile

public record ScenarioFile(String name, String description, String broker, String management, List<ScenarioFile.ExchangeJson> exchanges, List<ScenarioFile.QueueJson> queues, List<ScenarioFile.ProducerJson> producers, String warmup, String runFor, Boolean declare, ScenarioFile.SecurityJson security, Map<String,Object> ui) extends Record
A scenario as a file.

This shape is the contract between the designer and everything else: it is what a saved acemq-workload-<name>-<date>.json contains, what the studio sends over its API, and what the command line will read. One shape, so a scenario drawn on a screen runs unchanged in a pipeline — which is the only reason a designer is worth building rather than another form over a YAML file.

Records rather than the builder objects because a file is data. The builder is convenient in Java and hostile to a JSON parser, and a format that mirrors a fluent API is a format nobody can write by hand.

  • Constructor Details

  • Method Details

    • toScenario

      public Scenario toScenario()
      Returns:
      this file as a scenario the engine can run
    • of

      public static ScenarioFile of(Scenario scenario, String broker, String management, Map<String,Object> ui)
      Parameters:
      scenario - a scenario
      broker - the URL it was designed against, or null
      management - its management URL, or null
      ui - whatever the designer wants to remember about layout
      Returns:
      the same scenario as a file
    • of

      public static ScenarioFile of(Scenario scenario, String broker, String management, Map<String,Object> ui, ScenarioFile.SecurityJson security)
      The same, keeping a security block the caller already has.

      A Scenario does not carry one: how to reach a broker is a property of the file and of the run, not of the shape being run. So the four-argument form cannot preserve what it was never given, and silently wrote security: null into every file it produced -- which is fine while nothing saves a file that had one, and stops being fine the moment something does. A queue's broker: survives that round trip; TLS did not, and the asymmetry made the loss look like it could not be happening.

      The password is not part of what survives: ScenarioFile.SecurityJson does not serialise it.

      Parameters:
      scenario - what to write down
      broker - the URL it ran against, or null
      management - the management URL, or null
      ui - whatever the interface wants to remember, or null
      security - the security block to keep, or null when there is none
      Returns:
      the file
    • fileName

      public static String fileName(String name, LocalDate at)
      The file name a saved scenario gets.

      Named for what it is and when it was saved, because the alternative is six files called scenario (3).json.

      Parameters:
      name - the scenario's name
      at - when it was saved
      Returns:
      a file name
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • description

      public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • broker

      public String broker()
      Returns the value of the broker record component.
      Returns:
      the value of the broker record component
    • management

      public String management()
      Returns the value of the management record component.
      Returns:
      the value of the management record component
    • exchanges

      public List<ScenarioFile.ExchangeJson> exchanges()
      Returns the value of the exchanges record component.
      Returns:
      the value of the exchanges record component
    • queues

      public List<ScenarioFile.QueueJson> queues()
      Returns the value of the queues record component.
      Returns:
      the value of the queues record component
    • producers

      public List<ScenarioFile.ProducerJson> producers()
      Returns the value of the producers record component.
      Returns:
      the value of the producers record component
    • warmup

      public String warmup()
      Returns the value of the warmup record component.
      Returns:
      the value of the warmup record component
    • runFor

      public String runFor()
      Returns the value of the runFor record component.
      Returns:
      the value of the runFor record component
    • declare

      public Boolean declare()
      Returns the value of the declare record component.
      Returns:
      the value of the declare record component
    • security

      public ScenarioFile.SecurityJson security()
      Returns the value of the security record component.
      Returns:
      the value of the security record component
    • ui

      public Map<String,Object> ui()
      Returns the value of the ui record component.
      Returns:
      the value of the ui record component