Class LoadScenarioRegistry
A scenario is loaded (registered) here under its name
— the unique registry key — by PUT /mockserver/loadScenario. Loading stores the definition
but does not run anything; an explicit PUT /mockserver/loadScenario/start triggers one or
more registered scenarios to run. This mirrors the saved-chaos-profile library
(ChaosProfileLibrary): a template store, not the active-run store.
Storage: definitions live in the StateBackend's
crudEntities("load-scenarios") key-value store, keyed by scenario name. This gives:
- Survives reset —
HttpState.reset()stops active runs but does not clear the registry, so loaded scenarios outlive a reset and can be re-triggered. - Cluster-correct — when the backend is clustered, loads/deletes replicate across the fleet via the same CRUD-entity replication used by the chaos registries.
- Preloadable — startup preloading writes definitions here so a node can boot with scenarios staged in the LOADED state, ready to trigger.
Each stored value is the scenario's JSON ObjectNode (the same shape accepted by the PUT
endpoint); the registry key (the store key) overrides any name inside the body so the
loaded-under name wins. Loading the same name replaces the prior definition.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCRUD-entity namespace under which loaded scenario definitions are stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all registered scenarios.booleanTrue if a scenario is registered undername.booleanRemoves the registered scenarioname.Optional<com.fasterxml.jackson.databind.node.ObjectNode>Returns the loaded scenario definition forname, orOptional.empty()if no such scenario is registered.list()Returns the names of all registered scenarios, in ascending name order.voidLoads (or replaces) a scenario definition undername.
-
Field Details
-
BACKEND_NAMESPACE
CRUD-entity namespace under which loaded scenario definitions are stored.- See Also:
-
-
Constructor Details
-
LoadScenarioRegistry
-
-
Method Details
-
load
Loads (or replaces) a scenario definition undername. Thedefinitionis the scenario JSON — the same shape accepted byPUT /mockserver/loadScenario. The stored copy'snamefield is normalised tonameso the loaded-under name wins.- Throws:
IllegalArgumentException- if the name is blank or the definition is not a JSON object
-
get
Returns the loaded scenario definition forname, orOptional.empty()if no such scenario is registered. -
list
Returns the names of all registered scenarios, in ascending name order. -
contains
True if a scenario is registered undername. -
delete
Removes the registered scenarioname. Returnstrueif a scenario was present and removed,falseif no such scenario existed. -
clear
public void clear()Removes all registered scenarios.
-