One replica of a co-located application — the kind of producer nothing elects. One runs per node, the topology's <applications> section names it, and LeadershipChanged already picks the replica that submits: this one publishes only while its own node leads. What that takes is behind it — the cluster session over the node's own aeron:ipc, the queue it follows, the leader gate, confirmed ingress across a failover, and the fences that say it may no longer act.
More...
|
| | Application (ApplicationOptions options) |
| | A replica configured by options ; nothing is connected until Start.
|
| |
| void | Start (Aeron aeron) |
| | Opens the cluster session on this node and starts following its queue; the gate stays shut until caught up.
|
| |
| int | DoWork () |
| | One duty-cycle iteration: the cluster session and the queue, then the gate over what they left. Nothing once fenced.
|
| |
| Publish | Publish (int payloadId, IDirectBuffer payload, int length) |
| | Submits one payload of this application's own to its own group, stamped with its sourceId and belonging to no connection.
|
| |
| Publish | Publish (int payloadId, ReadOnlySpan< byte > payload) |
| | The same from a span, copied once into a buffer this replica owns.
|
| |
| Publish | Publish (ushort groupMask, int payloadId, IDirectBuffer payload, int length) |
| | The same to the groups groupMask names as well as its own.
|
| |
| Publish | Publish (ushort groupMask, int payloadId, ReadOnlySpan< byte > payload) |
| | The same from a span, copied once into a buffer this replica owns.
|
| |
| Publish | Reply (ReplyAddress request, int payloadId, IDirectBuffer payload, int length) |
| | The same on behalf of the producer that asked for it: a reply carries the requester's sourceId, connectionId and groupMask, which is how the gateway that took the request routes the answer back out of it, and how every group that saw the request sees the answer. Keep the ReplyAddress (Payload.ReplyAddress) rather than the request itself — a Payload is valid only during its callback, and a reply is usually dispatched later.
|
| |
| Publish | Reply (ReplyAddress request, int payloadId, ReadOnlySpan< byte > payload) |
| | The same from a span, copied once into a buffer this replica owns.
|
| |
| void | Dispose () |
| | Closes the cluster session and the queue. The Aeron client is the caller's and is left open.
|
| |
| void | KeepAlive () |
| | Tells the cluster this instance is alive. DoWork already does it once a cycle, and a snapshot round once per record; call this as well from inside an IApplicationListener callback that spins, since DoWork cannot run again until that callback returns, and the cluster drops a session that goes quiet for sequencer.sessionTimeoutMs. Self-throttling, so a call per spin costs nothing.
|
| |
One replica of a co-located application — the kind of producer nothing elects. One runs per node, the topology's <applications> section names it, and LeadershipChanged already picks the replica that submits: this one publishes only while its own node leads. What that takes is behind it — the cluster session over the node's own aeron:ipc, the queue it follows, the leader gate, confirmed ingress across a failover, and the fences that say it may no longer act.
Off the cluster (ApplicationOptions.OffCluster), on a gateway host, it is the one instance rather than one of three: its gate opens once caught up, whoever leads, and it submits over UDP, never over a member's aeron:ipc. Nothing stops a second instance publishing too; an application that needs a standby off the cluster is a Gateway.
What is left to the consumer is its own work: the payloads it reads, the state it keeps, the payloads it submits. Every replica reads the same ordered stream and so holds the same state, which is what makes OutstandingWork<TKey,TWork> — fed that same stream — the way work survives the gate closing under it.
Snapshots (doc/snapshot.md §4): given an ISnapshotListener and a topology row with snapshot="true", every replica serializes its state at each round's cut into its own directory, and the one whose gate is open then submits the round's SnapshotEnd. A replica whose snapshot differs from the one sequenced is fenced with ClusterError.SnapshotDiverged. On start, a replica given a listener restores the newest snapshot of its own that the log confirms and resumes after its cut, or replays from clusterSeqNo 1 without one; one it cannot restore is fenced with ClusterError.SnapshotUnrestorable.
Single-threaded: every member belongs to the caller's one duty-cycle thread, which calls DoWork each iteration. Application.java and app/Application.hpp are its twins; keep the three in step.