Interface FlowControl

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractMinMulticastFlowControl, MaxMulticastFlowControl, MinMulticastFlowControl, PreferredMulticastFlowControl, TaggedMulticastFlowControl, UnicastFlowControl

public interface FlowControl extends AutoCloseable
Strategy for applying flow control to the Sender on each stream.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    calculateRetransmissionLength(int resendLength, int termBufferLength, int termOffset, int retransmitReceiverWindowMultiple)
    Calculates a retransmission length by clamping to a min of resendLength, termBufferLength - termOffset and retransmitReceiverWindowMultiple * ${configured initial window length}.
    void
    boolean
    Has the flow control strategy its required group of receivers to be considered connected? The result of this feeds into the determination of if a publication is connected.
    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.
    int
    maxRetransmissionLength(int termOffset, int resendLength, int termBufferLength, int mtuLength)
    The maximum window length allowed to retransmit per NAK.
    void
    onError(ErrorFlyweight errorFlyweight, InetSocketAddress receiverAddress, long timeNs)
    Update the sender flow control strategy if an error comes from one of the receivers.
    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.
    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.
    long
    onStatusMessage(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long senderLimit, int initialTermId, int positionBitsToShift, long timeNs)
    Update the sender flow control strategy based on a status message from the receiver.
    void
    onTriggerSendSetup(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long timeNs)
    Update the sender flow control strategy based on a Status Message received triggering a setup to be sent.
    static int
    retransmitReceiverWindowMultiple(UdpChannel udpChannel, int defaultRetransmitReceiverWindowMultiple)
    Determines the retransmit receiver window multiple to use.
  • Method Details

    • calculateRetransmissionLength

      static int calculateRetransmissionLength(int resendLength, int termBufferLength, int termOffset, int retransmitReceiverWindowMultiple)
      Calculates a retransmission length by clamping to a min of resendLength, termBufferLength - termOffset and retransmitReceiverWindowMultiple * ${configured initial window length}.
      Parameters:
      resendLength - requested length of a retransmit
      termBufferLength - length of the current term.
      termOffset - offset within the term.
      retransmitReceiverWindowMultiple - multiplier to the receiver window length.
      Returns:
      the clamped retransmit length
    • retransmitReceiverWindowMultiple

      static int retransmitReceiverWindowMultiple(UdpChannel udpChannel, int defaultRetransmitReceiverWindowMultiple)
      Determines the retransmit receiver window multiple to use. If a value is specified in the channel URI, this will be used. Otherwise, the supplied default will be used.
      Parameters:
      udpChannel - for the stream.
      defaultRetransmitReceiverWindowMultiple - window multiple to use when one is not set in the URI.
      Returns:
      receiver window multiple.
    • onStatusMessage

      long onStatusMessage(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long senderLimit, int initialTermId, int positionBitsToShift, long timeNs)
      Update the sender flow control strategy based on a status message from the receiver.
      Parameters:
      flyweight - over the status message received.
      receiverAddress - of the receiver.
      senderLimit - the current sender position limit.
      initialTermId - for the term buffers.
      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.
    • onTriggerSendSetup

      void onTriggerSendSetup(StatusMessageFlyweight flyweight, InetSocketAddress receiverAddress, long timeNs)
      Update the sender flow control strategy based on a Status Message received triggering a setup to be sent.
      Parameters:
      flyweight - over the Status Message received
      receiverAddress - of the receiver.
      timeNs - current time (in nanoseconds).
    • onSetup

      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.
      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.
    • onError

      void onError(ErrorFlyweight errorFlyweight, InetSocketAddress receiverAddress, long timeNs)
      Update the sender flow control strategy if an error comes from one of the receivers.
      Parameters:
      errorFlyweight - over the error received.
      receiverAddress - the address of the receiver.
      timeNs - current time in nanoseconds
    • initialize

      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.
      Parameters:
      context - to allow access to media driver configuration
      countersManager - to use for any counters in use by the strategy
      streamId - for the stream.
      sessionId - for the stream.
      registrationId - for the stream.
      udpChannel - for the stream.
      initialTermId - at which the stream started.
      termBufferLength - to use as the length of each term buffer.
    • onIdle

      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.
      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

      boolean hasRequiredReceivers()
      Has the flow control strategy its required group of receivers to be considered connected? The result of this feeds into the determination of if a publication is connected.
      Returns:
      true if the required group of receivers is connected, otherwise false.
    • maxRetransmissionLength

      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.
      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.
    • close

      void close()
      Specified by:
      close in interface AutoCloseable