Class ClusterFanIn

java.lang.Object
org.mockserver.cluster.ClusterFanIn

public class ClusterFanIn extends Object
Opt-in cluster scatter-gather (fan-in) for verify/retrieve.

MockServer's event log is per-node: the shared StateBackend replicates expectations, scenario state, CRUD entities, and blobs across the fleet, but NOT request/response log entries. Behind a load balancer that means a verify() or retrieve(REQUESTS/REQUEST_RESPONSES) on one node sees only the traffic that reached THAT node — a silent correctness trap for the HA feature.

When enabled (clusterVerifyFanIn=true plus a non-empty clusterVerifyFanInPeers list), this coordinator queries each configured peer's LOCAL log via a ClusterFanIn.PeerAccessor and concatenates the results, so the caller can merge them with the local log and evaluate against the fleet-wide total.

Non-recursion: the ClusterFanIn.PeerAccessor issues each peer request with a "local-only" marker so the peer serves from its own log without fanning out again.

Unreachable peers (fail-closed): this coordinator does NOT drop unreachable peers silently. It reports which peers failed via ClusterFanIn.FanInResult.unreachablePeers(); callers treat any unreachable peer as a failure rather than returning a partial (and therefore potentially wrong) verify/retrieve result. This is the safer default: for an atMost/exactly verification, silently missing a peer's traffic could turn a real violation into a false pass.

  • Constructor Details

  • Method Details

    • enabled

      public boolean enabled()
      Fan-in is active only when explicitly enabled AND at least one peer is configured. When enabled with no peers it is a safe no-op (single-node behaviour preserved).
    • peers

      public List<String> peers()
      The configured peer control-plane base URLs (this node excluded), parsed from the comma-separated clusterVerifyFanInPeers property. Blank entries are dropped.
    • fanInRequests

      Query every peer's LOCAL matching requests and concatenate them. The returned list is remote-only (the caller merges with its local log). Unreachable peers are reported (never silently dropped).
    • fanInRequestResponses

      Query every peer's LOCAL matching request-response pairs and concatenate them.