SubscriptionRuntime
Runs the subscriptions of one subscription group over the partitions this node owns (–§3).
Which partitions those are is decided outside, by the partition leases (me.ahoo.wow.runtime.cluster.PartitionOwnership): passed to start, then moved one at a time with startPartition and stopPartition as the node acquires and hands off partitions. For each partition the runtime reads the log once and fans the entries out to every subscription (PartitionRunner); each subscription keeps its own checkpoint per partition, runs one aggregate's entries in version order and different aggregates in parallel, and parks an aggregate whose handler keeps failing (SubscriptionWorker).
Duplicates are possible above a checkpoint (an entry handled but not yet saved when the node stopped or crashed), never below it, so handlers are idempotent by (ref, version).
It takes part in waits: a subscription signals, through signals, the wait an entry carries when the wait's next hop is that subscription; and as the SubscriptionDirectory of its group it tells a wait which subscriptions there are, of what kind, and whether one has handled a stream.
The same runtime reads another context's published topic instead of the log (me.ahoo.wow.runtime.source.TopicSubscriptions): its partitions are leased the same way, its entries fanned out through one shared tail per partition, its checkpoints (the offset after the last record completed) kept in the same store, and its parked aggregates in the same ledger, each with the offset to re-scan from.
Constructors
The runtime of a context's own log; the internal constructor takes any source, a topic's among them.
Properties
Functions
Registers subscription. On a running runtime it starts at once in every partition: it catches up from its checkpoint (or as Subscription.startFrom says) on its own read, then joins the shared tail.
Whether subscription's filter takes streams of type: its context, and its aggregates when it names any.
Whether subscription is past stream for good (SubscriptionProgress.hasHandled).
The kind of subscription in context, or null when it is not known.
The partitions this runtime's subscriptions have paused on a systemic failure, each a subscription in a partition this node runs; empty while the runtime is stopped.
Where each subscription stands in each partition this runtime runs here (SubscriptionProgress.positions).
How far subscription has come over all partitions of its source (SubscriptionProgress.progress).
Handles subscription's parked aggregate ref again from its parked version, then resolves its ledger entry; the aggregate's new entries are handled after it, in version order (see SubscriptionWorker.retry).
Whether the runtime runs subscription in ref's partition here now: retry and skip act on the aggregate at once. Otherwise its owner is another node, which takes an operator's request from the ledger.
Resolves subscription's parked aggregate ref without handling what was skipped; its new entries are handled from now on.
Starts reading partitions, each subscription from its checkpoint; more can be started later.
Starts reading partition on the running runtime, each subscription from its checkpoint: the node has just acquired it. Nothing happens when it is read already; a start of it already running is waited for.
Stops reading, waits at most SubscriptionOptions.stopTimeout for the entries in flight, abandons the rest, and saves every checkpoint. An abandoned entry is above the saved checkpoint and is handled after a restart. The partitions stopping on their own (stopPartition) end before the run does: no checkpoint is saved after it.
Stops reading partition as stop does for all of them: waits at most SubscriptionOptions.stopTimeout for its entries in flight and saves its checkpoints, so the node can hand the partition off. The other partitions keep running. Nothing happens when it is not read; a start of it running is waited for first, a stop of it under way waited for instead.
The partitions this runtime's subscriptions throttle on backpressure, each a subscription in a partition this node runs; empty while the runtime is stopped.