seqeron 0.18.0
Loading...
Searching...
No Matches
Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender Class Referencesealed

The cluster session a producer submits on, with the method names and semantics of ClusterStreamSender.java and sequencer/client/ClusterStreamSender.hpp. Small, because Aeron.NET's AeronCluster already is the cluster protocol the C++ class implements by hand; this adds only ConnectColocated, a Send that spins through back-pressure and elections, and a self-throttling KeepAlive. More...

Inheritance diagram for Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender:
Collaboration diagram for Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender:

Public Member Functions

 ClusterStreamSender ()
 A sender with no session; ConnectColocated or Connect opens one.
 
 ClusterStreamSender (IIdleStrategy idle)
 The same, waiting on idle wherever it blocks: the Send spin and a session's connect.
 
void Connect (Aeron aeron, string egressChannel, string ingressEndpoints, IEgressListener appListener=null)
 Connects a client co-located with no member: UDP ingress against the whole endpoint set.
 
void ConnectColocated (Aeron aeron, int memberId, long ipcConnectTimeoutMs, string egressChannel, string ingressEndpoints, IEgressListener appListener=null)
 Connects a client sharing a cluster member's Aeron directory: that member's aeron:ipc first, within the short ipcConnectTimeoutMs since a follower never answers there, then UDP. If leadership later moves away, PollEgress reconnects over UDP, a step per call; moving back is not chased.
 
bool Reconnect ()
 Replaces a lost session with a new one, opened as the first was but one step per call, so the caller's duty cycle never waits on an unreachable cluster. What the old one had not committed is not carried over: the caller's tracker decides what to do about it.
 
void SetIngressHold (IIngressTracker hold)
 Hears every NewLeader, and gives up a send that met one while it holds.
 
bool Send (IDirectBuffer frame, int length)
 Offers one pre-encoded frame to cluster ingress, spinning until it lands. CLOSED is not terminal: once it sees the leader's egress end, AeronCluster closes the ingress publication and waits for a NewLeader, which PollEgress installs — hence the spin polls. A leader that dies ends no egress, so its publication takes frames until the NewLeader, which discards what it has not sent: a frame that lands can still be lost, and only the queue confirms it (doc/fault-tolerance.md §1.2). Bounded, since losing quorum would otherwise stop the caller's duty cycle. No keep-alive from in here: it would offer on the same stuck publication.
 
void KeepAlive ()
 Sends a keep-alive if the interval has elapsed; call it every duty-cycle iteration.
 
int PollEgress ()
 Drains cluster egress, then applies any reconnect it called for, outside the poll.
 
void Dispose ()
 Closes the session, and any attempt to replace it. The Aeron client is the caller's and is left open.
 

Properties

bool IsReconnecting [get]
 Whether Reconnect has an attempt under way, which only further calls advance.
 
bool IsConnected [get]
 Whether a session is open, or one whose leader moved away is being replaced.
 
bool IsSessionLost [get]
 True once the cluster has closed this session, as opposed to never having opened one. Latched until Reconnect opens another.
 
long ClusterSessionId [get]
 This process's cluster session id, or -1 with no session. Stamped into a frame's advisory field.
 
long LeadershipTermId [get]
 AeronCluster moves its stamp only inside PollEgress, which Send polls between failed offers.
 
- Properties inherited from Org.Limitless.Seqeron.Sequencer.Client.IIngressSender

Detailed Description

The cluster session a producer submits on, with the method names and semantics of ClusterStreamSender.java and sequencer/client/ClusterStreamSender.hpp. Small, because Aeron.NET's AeronCluster already is the cluster protocol the C++ class implements by hand; this adds only ConnectColocated, a Send that spins through back-pressure and elections, and a self-throttling KeepAlive.

As in Java, when leadership moves off the co-located member this reconnects (a new cluster session id) where C++ swaps the publication, because AeronCluster owns its publication.

Every timeout Java sets is set here explicitly: Aeron.NET's defaults are Aeron's, and its new-leader timeout is shorter than an election.

Not thread-safe: every method belongs to the caller's one duty-cycle thread.

Constructor & Destructor Documentation

◆ ClusterStreamSender() [1/2]

Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.ClusterStreamSender ( )
inline

A sender with no session; ConnectColocated or Connect opens one.

◆ ClusterStreamSender() [2/2]

Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.ClusterStreamSender ( IIdleStrategy  idle)
inline

The same, waiting on idle wherever it blocks: the Send spin and a session's connect.

Parameters
idlewhat to wait on, or null for a yielding send spin and AeronCluster's own connect wait

Member Function Documentation

◆ Connect()

void Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.Connect ( Aeron  aeron,
string  egressChannel,
string  ingressEndpoints,
IEgressListener  appListener = null 
)
inline

Connects a client co-located with no member: UDP ingress against the whole endpoint set.

Parameters
aeronthe caller's client, left open by Dispose
egressChannelthis client's own egress endpoint; two media drivers on one host cannot both bind a port (doc/ops.md, "Ports")
ingressEndpointsthe members to reach, PortLayout.IngressEndpoints() for the default set
appListenersees every egress event, or null; a gateway's cluster-session fence

◆ ConnectColocated()

void Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.ConnectColocated ( Aeron  aeron,
int  memberId,
long  ipcConnectTimeoutMs,
string  egressChannel,
string  ingressEndpoints,
IEgressListener  appListener = null 
)
inline

Connects a client sharing a cluster member's Aeron directory: that member's aeron:ipc first, within the short ipcConnectTimeoutMs since a follower never answers there, then UDP. If leadership later moves away, PollEgress reconnects over UDP, a step per call; moving back is not chased.

Parameters
aeronthe caller's client, on the member's media driver
memberIdthe co-located member
ipcConnectTimeoutMshow long the member's IPC ingress may take to answer
egressChannelthis client's own egress endpoint
ingressEndpointsthe members to reach over UDP
appListenersees every egress event, or null

◆ Dispose()

void Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.Dispose ( )
inline

Closes the session, and any attempt to replace it. The Aeron client is the caller's and is left open.

◆ KeepAlive()

void Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.KeepAlive ( )
inline

Sends a keep-alive if the interval has elapsed; call it every duty-cycle iteration.

◆ PollEgress()

int Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.PollEgress ( )
inline

Drains cluster egress, then applies any reconnect it called for, outside the poll.

Returns
fragments read

◆ Reconnect()

bool Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.Reconnect ( )
inline

Replaces a lost session with a new one, opened as the first was but one step per call, so the caller's duty cycle never waits on an unreachable cluster. What the old one had not committed is not carried over: the caller's tracker decides what to do about it.

Returns
whether a session opened; until then IsReconnecting says whether to call again, and a failed attempt is logged and ends, for the caller to begin another later

◆ Send()

bool Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.Send ( IDirectBuffer  frame,
int  length 
)
inline

Offers one pre-encoded frame to cluster ingress, spinning until it lands. CLOSED is not terminal: once it sees the leader's egress end, AeronCluster closes the ingress publication and waits for a NewLeader, which PollEgress installs — hence the spin polls. A leader that dies ends no egress, so its publication takes frames until the NewLeader, which discards what it has not sent: a frame that lands can still be lost, and only the queue confirms it (doc/fault-tolerance.md §1.2). Bounded, since losing quorum would otherwise stop the caller's duty cycle. No keep-alive from in here: it would offer on the same stuck publication.

Parameters
framethe frame, from offset 0
lengthits length in bytes
Returns
false when there is no session left to take it, or when a NewLeader arrived mid-spin while the IIngressTracker holds: nothing was placed, and the frame goes again once it releases

Implements Org.Limitless.Seqeron.Sequencer.Client.IIngressSender.

◆ SetIngressHold()

void Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.SetIngressHold ( IIngressTracker  hold)
inline

Hears every NewLeader, and gives up a send that met one while it holds.

Parameters
holdthe tracker, normally the producer's PendingSends

Property Documentation

◆ ClusterSessionId

long Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.ClusterSessionId
get

This process's cluster session id, or -1 with no session. Stamped into a frame's advisory field.

Implements Org.Limitless.Seqeron.Sequencer.Client.IIngressSender.

◆ IsConnected

bool Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.IsConnected
get

Whether a session is open, or one whose leader moved away is being replaced.

◆ IsReconnecting

bool Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.IsReconnecting
get

Whether Reconnect has an attempt under way, which only further calls advance.

◆ IsSessionLost

bool Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.IsSessionLost
get

True once the cluster has closed this session, as opposed to never having opened one. Latched until Reconnect opens another.

◆ LeadershipTermId

long Org.Limitless.Seqeron.Sequencer.Client.ClusterStreamSender.LeadershipTermId
get

AeronCluster moves its stamp only inside PollEgress, which Send polls between failed offers.

Implements Org.Limitless.Seqeron.Sequencer.Client.IIngressSender.


The documentation for this class was generated from the following file: