Class AbstractMinMulticastFlowControl

java.lang.Object
io.aeron.driver.AbstractMinMulticastFlowControl
All Implemented Interfaces:
FlowControl, AutoCloseable
Direct Known Subclasses:
MinMulticastFlowControl, TaggedMulticastFlowControl

public abstract class AbstractMinMulticastFlowControl extends Object implements FlowControl
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 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:
      initialize in interface FlowControl
      Parameters:
      context - to allow access to media driver configuration
      countersManager - to use for any counters in use by the strategy
      udpChannel - 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:
      close in interface AutoCloseable
      Specified by:
      close in interface FlowControl
    • 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:
      onSetup in interface FlowControl
      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:
      onIdle in interface FlowControl
      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 the groupMinSize() threshold?
      Specified by:
      hasRequiredReceivers in interface FlowControl
      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:
      maxRetransmissionLength in interface FlowControl
      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.