Package io.aeron.driver.media
Class SendChannelEndpoint
java.lang.Object
io.aeron.driver.media.UdpChannelTransport
io.aeron.driver.media.SendChannelEndpoint
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
DebugSendChannelEndpoint
Aggregator of multiple
NetworkPublication
s onto a single transport channel for the
sending of data and setup frames plus the receiving of status and NAK frames.-
Field Summary
Fields inherited from class io.aeron.driver.media.UdpChannelTransport
connectAddress, context, errorHandler, isClosed, receiveDatagramChannel, selectionKey, sendDatagramChannel, udpChannel
-
Constructor Summary
ConstructorsConstructorDescriptionSendChannelEndpoint
(UdpChannel udpChannel, AtomicCounter statusIndicator, MediaDriver.Context context) Construct the sender end for data streams. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDestination
(ChannelUri channelUri, InetSocketAddress address, long registrationId) Add a destination for an MDC channel.void
allocateDestinationsCounterForMdc
(MutableDirectBuffer tempBuffer, CountersManager countersManager, long registrationId, String originalUriString) Allocate a destinations counter if the channel uses multiple destinations.void
checkForReResolution
(long nowNs, DriverConductorProxy conductorProxy) Check sockets may need to be re-resolved due to no activity.void
Close the counters used to indicate channel status.void
decRef()
Decrement the reference count to the channel.void
incRef()
Increment the reference count to the channel.void
Indicate that the channel as active after successfully opening it.void
localSocketAddressIndicator
(AtomicCounter counter) Set a channel binding status counter.boolean
matchesTag
(UdpChannel udpChannel) Does the channel have a matching tag?void
onError
(ErrorFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback back handler for received error messages.void
onNakMessage
(NakFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress) Callback back handler for received NAK messages.void
onResponseSetup
(ResponseSetupFlyweight msg, UnsafeBuffer unsafeBuffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback to handle a received Response Setup frame.void
onRttMeasurement
(RttMeasurementFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress) Callback back handler for received RTT Measurement messages.void
onStatusMessage
(StatusMessageFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback back handler for received status messages.void
openChannel
(DriverConductorProxy conductorProxy) Open the underlying sockets for the channel.The original URI String used when a subscription was added.void
registerForSend
(NetworkPublication publication) Called from theSender
to add information to the control packet dispatcher.void
removeDestination
(long destinationRegistrationId) Remove a destination from an MDC channel.void
removeDestination
(ChannelUri channelUri, InetSocketAddress address) Remove a destination from an MDC channel.void
resolutionChange
(String endpoint, InetSocketAddress newAddress) Update the endpoint for the channel on address change.int
send
(ByteBuffer buffer) Send contents of aByteBuffer
to connected address.int
send
(ByteBuffer buffer, InetSocketAddress endpointAddress) Send contents of aByteBuffer
to connected address.boolean
Called by to determine if the channel endpoint should be closed.int
Counter id of the channel status indicator counter.void
unregisterForSend
(NetworkPublication publication) Called from theSender
to remove information from the control packet dispatcher.void
Validate that the channel allows manual control for destinations.Methods inherited from class io.aeron.driver.media.UdpChannelTransport
bindAddressAndPort, close, isClosed, isMulticast, isValidFrame, multicastTtl, onSendError, openDatagramChannel, receive, receiveDatagramChannel, receiveHook, registerForRead, resendHook, sendError, sendHook, socketRcvbufLength, socketSndbufLength, udpChannel, updateEndpoint
-
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
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
Open the underlying sockets for the channel.- Parameters:
conductorProxy
- for notifying potential channel errors.
-
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
Called from theSender
to add information to the control packet dispatcher.- Parameters:
publication
- to add to the dispatcher
-
unregisterForSend
Called from theSender
to remove information from the control packet dispatcher.- Parameters:
publication
- to remove
-
send
Send contents of aByteBuffer
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
Send contents of aByteBuffer
to connected address. This is used on the sender side for performance over send(ByteBuffer, SocketAddress).- Parameters:
buffer
- to sendendpointAddress
- to send data to.- Returns:
- number of bytes sent
-
checkForReResolution
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
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
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
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
Does the channel have a matching tag?- Parameters:
udpChannel
- with tag to match against.- Returns:
- true if the channel matches on tag identity.
-