Package io.aeron.driver
Class AbstractMinMulticastFlowControl
java.lang.Object
io.aeron.driver.AbstractMinMulticastFlowControl
- All Implemented Interfaces:
FlowControl,AutoCloseable
- Direct Known Subclasses:
MinMulticastFlowControl,TaggedMulticastFlowControl
Abstract minimum multicast sender flow control strategy. It supports the concept of only tracking the minimum of a
group of receivers, not all possible receivers. However, it is agnostic of how that group is determined.
Tracking of receivers is done as long as they continue to send Status Messages. Once SMs stop, the receiver tracking for that receiver will time out after a given number of nanoseconds.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMinMulticastFlowControl(boolean isGroupTagAware) Base constructor for use by specialised implementations. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected final intThe minimum group size required for progress.protected final longgroupTag()The tag used to identify members of the group.protected final booleanIndicates if the flow control strategy has a group tag it is aware of for tracking membership.booleanHas the observed receiver count reached thegroupMinSize()threshold?voidinitialize(MediaDriver.Context context, CountersManager countersManager, UdpChannel udpChannel, int streamId, int sessionId, long registrationId, int initialTermId, int termBufferLength) Initialize the flow control strategy for a stream.intmaxRetransmissionLength(int termOffset, int resendLength, int termBufferLength, int mtuLength) The maximum window length allowed to retransmit per NAK.longonIdle(long timeNs, long senderLimit, long senderPosition, boolean isEos) Perform any maintenance needed by the flow control strategy and return current sender limit position.longonSetup(SetupFlyweight flyweight, long senderLimit, long senderPosition, int positionBitsToShift, long timeNs) Update the sender flow control strategy based on an elicited setup message being sent out.protected voidprocessError(ErrorFlyweight error, InetSocketAddress receiverAddress, long timeNs, boolean hasMatchingTag) Process an error frame from a downstream receiver.protected voidprocessSendSetupTrigger(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long timeNs, boolean hasMatchingTag) Process a status message triggering a setup to be sent.protected final longprocessStatusMessage(StatusMessageFlyweight flyweight, long senderLimit, int initialTermId, int positionBitsToShift, long timeNs, boolean matchesTag) Process a received status message.protected final longTimeout after which an inactive receiver will be dropped.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.aeron.driver.FlowControl
onError, onStatusMessage, onTriggerSendSetup
-
Constructor Details
-
AbstractMinMulticastFlowControl
protected AbstractMinMulticastFlowControl(boolean isGroupTagAware) Base constructor for use by specialised implementations.- Parameters:
isGroupTagAware- true if the group tag is used.
-
-
Method Details
-
initialize
public void initialize(MediaDriver.Context context, CountersManager countersManager, UdpChannel udpChannel, int streamId, int sessionId, long registrationId, int initialTermId, int termBufferLength) Initialize the flow control strategy for a stream.- Specified by:
initializein interfaceFlowControl- Parameters:
context- to allow access to media driver configurationcountersManager- to use for any counters in use by the strategyudpChannel- for the stream.streamId- for the stream.sessionId- for the stream.registrationId- for the stream.initialTermId- at which the stream started.termBufferLength- to use as the length of each term buffer.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFlowControl
-
onSetup
public long onSetup(SetupFlyweight flyweight, long senderLimit, long senderPosition, int positionBitsToShift, long timeNs) Update the sender flow control strategy based on an elicited setup message being sent out.- Specified by:
onSetupin interfaceFlowControl- Parameters:
flyweight- over the setup to be sent.senderLimit- for the current sender position.senderPosition- which has been sent.positionBitsToShift- in use for the length of each term buffer.timeNs- current time in nanoseconds.- Returns:
- the new position limit to be employed by the sender.
-
onIdle
public long onIdle(long timeNs, long senderLimit, long senderPosition, boolean isEos) Perform any maintenance needed by the flow control strategy and return current sender limit position.- Specified by:
onIdlein interfaceFlowControl- Parameters:
timeNs- current time in nanoseconds.senderLimit- for the current sender position.senderPosition- which has been sent.isEos- is this end-of-stream for the sender.- Returns:
- the position limit to be employed by the sender.
-
hasRequiredReceivers
public boolean hasRequiredReceivers()Has the observed receiver count reached thegroupMinSize()threshold?- Specified by:
hasRequiredReceiversin interfaceFlowControl- Returns:
- true if the observed receiver count reached the
groupMinSize()threshold?
-
maxRetransmissionLength
public int maxRetransmissionLength(int termOffset, int resendLength, int termBufferLength, int mtuLength) The maximum window length allowed to retransmit per NAK. Will limit it by an estimate of the window limit and to the end of the current term.- Specified by:
maxRetransmissionLengthin interfaceFlowControl- Parameters:
termOffset- of the NAK.resendLength- of the NAK.termBufferLength- of the publication.mtuLength- of the publication.- Returns:
- the maximum window length allowed to retransmit per NAK.
-
processStatusMessage
protected final long processStatusMessage(StatusMessageFlyweight flyweight, long senderLimit, int initialTermId, int positionBitsToShift, long timeNs, boolean matchesTag) Process a received status message.- Parameters:
flyweight- mapped over the status message.senderLimit- the sender is currently limited to for sending.initialTermId- for the publication.positionBitsToShift- when calculating term length with requiring a divide.timeNs- current time.matchesTag- if the status messages comes from a receiver with a tag matching the group.- Returns:
- the new position limit to be employed by the sender.
-
processSendSetupTrigger
protected void processSendSetupTrigger(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long timeNs, boolean hasMatchingTag) Process a status message triggering a setup to be sent.- Parameters:
flyweight- over the status message receiver.receiverAddress- of the receiver.timeNs- current time (in nanoseconds).hasMatchingTag- if the status messages comes from a receiver with a tag matching the group.
-
processError
protected void processError(ErrorFlyweight error, InetSocketAddress receiverAddress, long timeNs, boolean hasMatchingTag) Process an error frame from a downstream receiver.- Parameters:
error- flyweight over the error frame.receiverAddress- of the receiver.timeNs- current time in nanoseconds.hasMatchingTag- if the error message comes from a receiver with a tag matching the group.
-
receiverTimeoutNs
protected final long receiverTimeoutNs()Timeout after which an inactive receiver will be dropped.- Returns:
- timeout after which an inactive receiver will be dropped.
-
hasGroupTag
protected final boolean hasGroupTag()Indicates if the flow control strategy has a group tag it is aware of for tracking membership.- Returns:
- true if the flow control strategy has a group tag it is aware of for tracking membership.
-
groupTag
protected final long groupTag()The tag used to identify members of the group.- Returns:
- tag used to identify members of the group.
-
groupMinSize
protected final int groupMinSize()The minimum group size required for progress.- Returns:
- minimum group size required for progress.
-