Class RecoveryAttemptRegistry
RecoverAfter
recovery primitive. When a response's recoverAfter is configured with an
idempotencyHeader, the failure window is keyed per (expectationId, header-value)
so that each distinct idempotency key gets its own independent 1..K window, while requests
sharing a key share one counter (model a single logical retry sequence).
The default (no idempotency header) recovery path does NOT touch this registry — it counts off the expectation's own match count, so it adds zero new state and zero overhead. This registry is only used on the explicit keyed path.
Bounded against memory exhaustion. Idempotency-key values are client-supplied
(typically fresh UUIDs), so an unbounded map would grow without limit and exhaust the heap. The
registry is therefore a thread-safe bounded registry — a synchronized access-ordered
LinkedHashMap that evicts the least-recently-used key once MAX_SIZE (10,000)
keys are held, mirroring DnsIntentRegistry. A cold evicted key
simply restarts its failure window at attempt 1 on its next request, which matches
reset() semantics. nextAttempt(java.lang.String, java.lang.String) remains an atomic per-key increment, safe under
concurrent requests.
v1 is node-local (clustering is deferred — like ScenarioManager, the registry can
later move behind the StateBackend SPI). State is cleared on server reset (see
HttpState.reset()).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RecoveryAttemptRegistryintnextAttempt(String expectationId, String key) Record and return the 1-based attempt number for the given(expectationId, key)pair.voidreset()Clear all attempt state.
-
Constructor Details
-
RecoveryAttemptRegistry
public RecoveryAttemptRegistry()
-
-
Method Details
-
getInstance
-
nextAttempt
Record and return the 1-based attempt number for the given(expectationId, key)pair. The first call for a pair returns1, the next2, and so on. If the pair was evicted because the registry was over capacity, counting restarts from1.- Parameters:
expectationId- the matched expectation's id (namespaces the counter so distinct expectations sharing an idempotency-key value do not collide)key- the idempotency-key value from the request header- Returns:
- the 1-based attempt count for this pair
-
reset
public void reset()Clear all attempt state. Called on server reset and for test isolation.
-