Class SendChannelEndpoint

java.lang.Object
io.aeron.driver.media.UdpChannelTransport
io.aeron.driver.media.SendChannelEndpoint
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
DebugSendChannelEndpoint

public class SendChannelEndpoint extends UdpChannelTransport
Aggregator of multiple NetworkPublications onto a single transport channel for the sending of data and setup frames plus the receiving of status and NAK frames.
  • Constructor Details

    • SendChannelEndpoint

      public SendChannelEndpoint(UdpChannel udpChannel, AtomicCounter statusIndicator, MediaDriver.Context context)
      Construct the sender end for data streams.
      Parameters:
      udpChannel - configuration for the media.
      statusIndicator - to indicate the status of the channel endpoint.
      context - for configuration.
  • Method Details

    • localSocketAddressIndicator

      public void localSocketAddressIndicator(AtomicCounter counter)
      Set a channel binding status counter.
      Parameters:
      counter - to be set.
    • decRef

      public void decRef()
      Decrement the reference count to the channel.
    • incRef

      public void incRef()
      Increment the reference count to the channel.
    • openChannel

      public void openChannel(DriverConductorProxy conductorProxy)
      Open the underlying sockets for the channel.
      Parameters:
      conductorProxy - for notifying potential channel errors.
    • originalUriString

      public String originalUriString()
      The original URI String used when a subscription was added.
      Returns:
      the original URI String used when a subscription was added.
    • statusIndicatorCounterId

      public int statusIndicatorCounterId()
      Counter id of the channel status indicator counter.
      Returns:
      id of the channel status indicator counter.
    • indicateActive

      public void indicateActive()
      Indicate that the channel as active after successfully opening it.
    • closeIndicators

      public void closeIndicators()
      Close the counters used to indicate channel status.
    • shouldBeClosed

      public boolean shouldBeClosed()
      Called by to determine if the channel endpoint should be closed.
      Returns:
      true if ready to be closed.
    • registerForSend

      public void registerForSend(NetworkPublication publication)
      Called from the Sender to add information to the control packet dispatcher.
      Parameters:
      publication - to add to the dispatcher
    • unregisterForSend

      public void unregisterForSend(NetworkPublication publication)
      Called from the Sender to remove information from the control packet dispatcher.
      Parameters:
      publication - to remove
    • send

      public int send(ByteBuffer buffer)
      Send contents of a ByteBuffer to connected address. This is used on the sender side for performance over send(ByteBuffer, SocketAddress).
      Parameters:
      buffer - to send
      Returns:
      number of bytes sent
    • send

      public int send(ByteBuffer buffer, InetSocketAddress endpointAddress)
      Send contents of a ByteBuffer to connected address. This is used on the sender side for performance over send(ByteBuffer, SocketAddress).
      Parameters:
      buffer - to send
      endpointAddress - to send data to.
      Returns:
      number of bytes sent
    • checkForReResolution

      public void checkForReResolution(long nowNs, DriverConductorProxy conductorProxy)
      Check sockets may need to be re-resolved due to no activity.
      Parameters:
      nowNs - to test against for activity.
      conductorProxy - to notify of any addresses which may need to be re-resolved.
    • onStatusMessage

      public void onStatusMessage(StatusMessageFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy)
      Callback back handler for received status messages.
      Parameters:
      msg - flyweight over the status message.
      buffer - containing the message.
      length - of the message.
      srcAddress - of the message.
      conductorProxy - to send messages back to the conductor.
    • onError

      public void onError(ErrorFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy)
      Callback back handler for received error messages.
      Parameters:
      msg - flyweight over the status message.
      buffer - containing the message.
      length - of the message.
      srcAddress - of the message.
      conductorProxy - to send messages back to the conductor.
    • onNakMessage

      public void onNakMessage(NakFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress)
      Callback back handler for received NAK messages.
      Parameters:
      msg - flyweight over the NAK message.
      buffer - containing the message.
      length - of the message.
      srcAddress - of the message.
    • onRttMeasurement

      public void onRttMeasurement(RttMeasurementFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress)
      Callback back handler for received RTT Measurement messages.
      Parameters:
      msg - flyweight over the RTT message.
      buffer - containing the message.
      length - of the message.
      srcAddress - of the message.
    • onResponseSetup

      public void onResponseSetup(ResponseSetupFlyweight msg, UnsafeBuffer unsafeBuffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy)
      Callback to handle a received Response Setup frame.
      Parameters:
      msg - of the Response Setup frame.
      unsafeBuffer - containing the Response Setup frame.
      length - of the Response Setup frame.
      srcAddress - the message came from.
      conductorProxy - to send messages back to the conductor.
    • validateAllowsManualControl

      public void validateAllowsManualControl()
      Validate that the channel allows manual control for destinations.

      If not then a ControlProtocolException will be thrown.

    • addDestination

      public void addDestination(ChannelUri channelUri, InetSocketAddress address, long registrationId)
      Add a destination for an MDC channel.
      Parameters:
      channelUri - for the destination to be added.
      address - of the destination to be added.
      registrationId - of the destination.
    • removeDestination

      public void removeDestination(ChannelUri channelUri, InetSocketAddress address)
      Remove a destination from an MDC channel.
      Parameters:
      channelUri - for the destination to be removed.
      address - of the destination to be removed.
    • removeDestination

      public void removeDestination(long destinationRegistrationId)
      Remove a destination from an MDC channel.
      Parameters:
      destinationRegistrationId - the registration id of the destination.
    • resolutionChange

      public void resolutionChange(String endpoint, InetSocketAddress newAddress)
      Update the endpoint for the channel on address change.
      Parameters:
      endpoint - associated with the address.
      newAddress - for the endpoint.
    • allocateDestinationsCounterForMdc

      public void allocateDestinationsCounterForMdc(MutableDirectBuffer tempBuffer, CountersManager countersManager, long registrationId, String originalUriString)
      Allocate a destinations counter if the channel uses multiple destinations.
      Parameters:
      tempBuffer - to use for metadata formatting.
      countersManager - for the driver.
      registrationId - of the endpoint.
      originalUriString - of the channel.
    • matchesTag

      public boolean matchesTag(UdpChannel udpChannel)
      Does the channel have a matching tag?
      Parameters:
      udpChannel - with tag to match against.
      Returns:
      true if the channel matches on tag identity.