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
NetworkPublications 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, receiveDatagramChannel, sendDatagramChannel, udpChannel -
Constructor Summary
ConstructorsConstructorDescriptionSendChannelEndpoint(UdpChannel udpChannel, AtomicCounter statusIndicator, MediaDriver.Context context) Construct the sender end for data streams. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDestination(ChannelUri channelUri, InetSocketAddress address, long registrationId) Add a destination for an MDC channel.voidallocateDestinationsCounterForMdc(MutableDirectBuffer tempBuffer, CountersManager countersManager, long registrationId, String originalUriString) Allocate a destinations counter if the channel uses multiple destinations.voidcheckForReResolution(long nowNs, DriverConductorProxy conductorProxy) Check sockets may need to be re-resolved due to no activity.voidclose()voiddecRef()Decrement the reference count to the channel.voidincRef()Increment the reference count to the channel.voidIndicate that the channel as active after successfully opening it.voidlocalSocketAddressIndicator(AtomicCounter counter) Set a channel binding status counter.booleanmatchesTag(UdpChannel udpChannel) Does the channel have a matching tag?voidonError(ErrorFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback back handler for received error messages.voidonNakMessage(NakFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress) Callback back handler for received NAK messages.voidonResponseSetup(ResponseSetupFlyweight msg, UnsafeBuffer unsafeBuffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback to handle a received Response Setup frame.voidonRttMeasurement(RttMeasurementFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress) Callback back handler for received RTT Measurement messages.voidonStatusMessage(StatusMessageFlyweight msg, UnsafeBuffer buffer, int length, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Callback back handler for received status messages.voidOpen the underlying sockets for the channel.The original URI String used when a subscription was added.voidregisterForSend(NetworkPublication publication) Called from theSenderto add information to the control packet dispatcher.voidremoveDestination(long destinationRegistrationId) Remove a destination from an MDC channel.voidremoveDestination(ChannelUri channelUri, InetSocketAddress address) Remove a destination from an MDC channel.voidresolutionChange(String endpoint, InetSocketAddress newAddress) Update the endpoint for the channel on address change.intsend(ByteBuffer buffer) Send contents of aByteBufferto connected address.intsend(ByteBuffer buffer, InetSocketAddress endpointAddress) Send contents of aByteBufferto connected address.booleanCalled by to determine if the channel endpoint should be closed.intCounter id of the channel status indicator counter.voidunregisterForSend(NetworkPublication publication) Called from theSenderto remove information from the control packet dispatcher.voidValidate that the channel allows manual control for destinations.Methods inherited from class io.aeron.driver.media.UdpChannelTransport
bindAddressAndPort, isMulticast, isValidFrame, multicastTtl, onSendError, openDatagramChannel, receive, receiveDatagramChannel, receiveHook, 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
public void openChannel()Open the underlying sockets for the channel. -
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. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classUdpChannelTransport
-
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 theSenderto add information to the control packet dispatcher.- Parameters:
publication- to add to the dispatcher
-
unregisterForSend
Called from theSenderto remove information from the control packet dispatcher.- Parameters:
publication- to remove
-
send
Send contents of aByteBufferto 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 aByteBufferto 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
ControlProtocolExceptionwill 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.
-