A producer's ingress frames that its own queue has not yet shown, which of them a leader change or a closed session lost, and their resend ahead of anything new.
More...
|
| | PendingSends (int capacity) |
| | A tracker holding nothing, for one producer's own sends.
|
| |
| void | Track (IDirectBuffer frame, int length, long clusterSessionId, long leadershipTermId) |
| | A frame the sender placed, read straight after its Send returned true.
|
| |
| void | OnLeadershipChanged (long leadershipTermId) |
| | From the stream client's leadership callback: closes the count on every earlier term.
|
| |
| void | OnNewLeader (long leadershipTermId) |
| | From the sender, which calls it on every NewLeader.
|
| |
| int | ResendMissing (IIngressSender sender) |
| | Resends the missing frames oldest first, each going back to the end of the ring as pending under the term and session it now carries. Stops at the first send that fails, so a later call picks up where this left off. Call it every duty cycle: it is also where this learns which session the sender holds.
|
| |
| void | OnSequenced (SequencedEvent sequencedEvent) |
| | Every frame off the queue, in order. Only this producer's own frames and sessions change anything.
|
| |
| int | DiscardUnconfirmed () |
| | Forgets every pending frame, for a producer that knows none of them will be sequenced. Any that are still arrive and match nothing.
|
| |
| int | Missing () |
| | Pending frames a leader change or a closed session has lost, oldest first at the front.
|
| |
| bool | IsClosed (long clusterSessionId) |
| | Whether the queue has shown clusterSessionId , the sender's own, closed.
|
| |
A producer's ingress frames that its own queue has not yet shown, which of them a leader change or a closed session lost, and their resend ahead of anything new.
Why a count is enough. A leader drops ingress stamped with any term but its own, and every election discards the ingress the old leader had not read. So a frame stamped term T is either on the queue before the first LeadershipChanged with a term above T, or lost, and the lost ones are the newest frames stamped T. Once that boundary has passed, every frame still pending with a term below it is Missing. The same holds when the same member wins the new term.
A closed session is a boundary too. The cluster appends nothing from a session once it begins to close it, and its close is in the log after everything it did append, so a frame not on the queue before that session's SessionClosed never will be: it is missing too. A session whose open never committed has no close, but was lost to an election, which the term bounds. Until one of the two shows, a frame on a session the sender no longer submits on is unsettled, and holds.
Resent in order, never twice. A committed frame is never missing, so nothing is duplicated. From a newer term's first sign — the sender's NewLeader or the queue's LeadershipChanged, whichever comes first — until every older frame is seen or resent, IsHolding: send nothing new, and give this to the sender with SetIngressHold, so a send already spinning through the election is given up rather than landing ahead of the resend. It holds the same way while the oldest frame is lost with its session, or unsettled. ResendMissing does the resend, never onto a session the queue has shown closed. Given to an IngressPublisher, this is tracked and gated on without the producer handling a frame.
Own frames are matched by session, not sourceId: a gateway pair shares its sourceId, and cluster session ids are never reused. Each frame records the session it went out on, so a replacement session still matches its earlier frames. An own frame must equal the oldest pending copy; anything else latches IsFaulted, because the order the count relies on no longer holds — most often the sequencer rejected a frame (S-7), so check §9.2 before sending. Tracking into a full ring latches it too: an untracked send breaks the count.
Limits: it lasts only as long as the process, so a promoted standby starts with nothing pending; it needs the producer to follow its own queue, and to call ResendMissing every duty cycle, which is how it learns the sender's session; loss with neither a leader change nor a session close (an ingress image that drops and rejoins within the session timeout) has no boundary and is not detected. PendingSends.java and sequencer/client/PendingSends.hpp are its twins; keep the three in step.