Skip to content

Federation ​

DSM federation connects collections across independent DSM runtimes. It is useful when two clusters need selected coordination state to converge without pretending they are one membership domain.

What Federation Provides ​

TypeRole
FederationBridgeBinds a local collection to a remote FederationTarget and routes by collection consistency tier.
FederationTargetRemote (clusterId, serviceId, locator) destination.
FederationRelayTransport SPI used by the bridge. Custom production transports implement this boundary.
FederationDigestRegister digest used to detect divergence without transferring every visible entry.
InMemoryFederationRelayIn-process baseline relay for tests and embedded examples. It is not a production network transport.
InMemoryFederationBridgeBaseline bridge implementation for register, lease, and CRDT federation semantics.

Scope And Limitations ​

Federation is not multi-region clustering by another name. It does not merge membership domains, transfer lease ownership across clusters, or provide a production gRPC/HTTP relay out of the box.

Collection tierFederation behaviorRepair behavior
RegisterBootstrap visible local state, then forward live puts and removes.Periodic digest-based anti-entropy repairs dropped mutations.
LeaseForward LeaseSnapshot changes for read-only remote observation.No cross-cluster acquire, renew, transfer, bootstrap repair, or ownership transfer.
CRDTForward committed StateDelta values.Relies on CRDT convergence and idempotency; no federation anti-entropy sweep.

The current relay baseline is in-memory and in-process. A production deployment must implement FederationRelay over a real transport and carry the same semantics explicitly.

Register Repair Loop ​

Register federation uses bootstrap-then-forward semantics, then closes relay gaps with a sweeper.

Federation register repair loop

Dropped puts and same-key updates are repaired by digest divergence. Dropped removes are repaired by re-bootstrap when the remote digest still contains stale entries after merge.

Relay Health ​

Federation status is driven by relay health:

Relay stateBinding statusRuntime behavior
HEALTHYHEALTHYLive forwarding and repair continue.
DEGRADEDDEGRADEDStatus exposes risk; transport may still succeed.
FAILEDDISCONNECTEDForwarding is suspended; disconnected bindings are skipped by repair.
recoveredSYNCING then HEALTHYRegister bindings trigger immediate catch-up bootstrap.

Use RelayHealthMonitor.noop() only for tests or deployments that deliberately do not track relay health.

Minimal Shape ​

java
DsmRuntime runtimeA = /* cluster-a runtime */;
DsmRuntime runtimeB = /* cluster-b runtime */;

CollectionSpec<MyEntry> spec = CollectionSpecBuilder.<MyEntry>register(
        "shared", "gateway", "entries")
    .schemaId("entries/v1")
    .codec(new MyEntryCodec())
    .build();

runtimeA.register(spec);
runtimeB.register(spec);
runtimeA.start();
runtimeB.start();

InMemoryFederationRelay relay = new InMemoryFederationRelay();
relay.registerRuntime(runtimeA);
relay.registerRuntime(runtimeB);

InMemoryFederationBridge bridge = new InMemoryFederationBridge(
    runtimeA,
    relay,
    RelayHealthMonitor.noop());

bridge.federateCollection(
    spec.locator(),
    new FederationBridge.FederationTarget("cluster-b", "gateway-service", spec.locator()));

Production Checklist ​

  • Implement FederationRelay over a real transport before using federation across processes or regions.
  • Preserve tier-specific semantics. Do not let a remote cluster acquire or renew federated leases.
  • Emit DsmMetrics.recordFederationRepair(locator, target, outcome) and alert on sustained failed or bootstrap_fallback outcomes.
  • Treat register anti-entropy as state repair, not historical event replay.
  • Test slow relay behavior; bridge flushing must not block local change-stream enqueueing.

Test Evidence ​

  • InMemoryFederationBridgeTest covers bootstrap, live put/remove forwarding, relay failure/recovery, register repair outcomes, non-blocking flush behavior, lease observation, and CRDT delta convergence.
  • FederationIntegrationTest covers bidirectional register convergence across two independent runtimes using the in-memory relay baseline.