Package io.aeron.driver
Class NetworkPublication
java.lang.Object
io.aeron.driver.NetworkPublication
- All Implemented Interfaces:
DriverManagedResource
,RetransmitSender
,Subscribable
public final class NetworkPublication
extends Object
implements RetransmitSender, DriverManagedResource, Subscribable
Publication to be sent to connected subscribers.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubscriber
(SubscriptionLink subscriptionLink, ReadablePosition position, long nowNs) Add a subscriber and its position used for tracking consumption.channel()
Channel URI string for this publication.void
close()
Close resources that are not external.boolean
free()
Free external resources such as files.boolean
Has resource reached end of its life and should be reclaimed?void
onError
(ErrorFlyweight msg, InetSocketAddress srcAddress, long destinationRegistrationId, DriverConductorProxy conductorProxy) Process an error message from a receiver.void
onNak
(int termId, int termOffset, int length) Process a NAK message so a retransmit can occur.void
onRttMeasurement
(RttMeasurementFlyweight msg, InetSocketAddress srcAddress) Process RTT (Round Trip Timing) message from a receiver.void
onStatusMessage
(StatusMessageFlyweight msg, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Process a status message to track connectivity and apply flow control.void
onTimeEvent
(long timeNs, long timeMs, DriverConductor conductor) Inform resource of timeNs passing and pass it DriverConductor to inform of any state transitions.void
removeSubscriber
(SubscriptionLink subscriptionLink, ReadablePosition position) Remove a subscriber and its position used for tracking consumption.void
resend
(int termId, int termOffset, int length) Called when a frame should be sent to request the retransmission of data.long
Get the response correlation id for the publication.int
Session id allocated to this stream.int
streamId()
Stream id within the channel.long
Registration ID that is in use by the subscribable.long
Time of the last status message a from a receiver.void
triggerSendSetupFrame
(StatusMessageFlyweight msg, InetSocketAddress srcAddress) Trigger the sending of a SETUP frame so a connection can be established.
-
Method Details
-
free
public boolean free()Free external resources such as files. If successful then return true.- Specified by:
free
in interfaceDriverManagedResource
- Returns:
- true if successful and false if it should be attempted again later.
-
close
public void close()Close resources that are not external. This will not callDriverManagedResource.free()
. That will need to be called separately at the appropriate time.- Specified by:
close
in interfaceDriverManagedResource
-
timeOfLastStatusMessageNs
public long timeOfLastStatusMessageNs()Time of the last status message a from a receiver.- Returns:
- this of the last status message a from a receiver.
-
channel
Channel URI string for this publication.- Returns:
- channel URI string for this publication.
-
sessionId
public int sessionId()Session id allocated to this stream.- Returns:
- session id allocated to this stream.
-
streamId
public int streamId()Stream id within the channel.- Returns:
- stream id within the channel.
-
triggerSendSetupFrame
Trigger the sending of a SETUP frame so a connection can be established.- Parameters:
msg
- that triggers the SETUP.srcAddress
- of the source that triggers the SETUP.
-
subscribableRegistrationId
public long subscribableRegistrationId()Registration ID that is in use by the subscribable.- Specified by:
subscribableRegistrationId
in interfaceSubscribable
- Returns:
- registration ID for subscribable.
-
addSubscriber
Add a subscriber and its position used for tracking consumption.- Specified by:
addSubscriber
in interfaceSubscribable
- Parameters:
subscriptionLink
- for identifying the subscriber.position
- for tracking the subscriber.nowNs
- for the current time.
-
removeSubscriber
Remove a subscriber and its position used for tracking consumption.Note: The
Subscribable
is responsible for callingReadablePosition.close()
on removed positions.- Specified by:
removeSubscriber
in interfaceSubscribable
- Parameters:
subscriptionLink
- for identifying the subscriber.position
- for tracking the subscriber.
-
onNak
public void onNak(int termId, int termOffset, int length) Process a NAK message so a retransmit can occur.- Parameters:
termId
- in which the loss occurred.termOffset
- at which the loss begins.length
- of the loss.
-
onStatusMessage
public void onStatusMessage(StatusMessageFlyweight msg, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Process a status message to track connectivity and apply flow control.- Parameters:
msg
- flyweight over the network packet.srcAddress
- that the setup message has come from.conductorProxy
- to send messages back to the conductor.
-
onError
public void onError(ErrorFlyweight msg, InetSocketAddress srcAddress, long destinationRegistrationId, DriverConductorProxy conductorProxy) Process an error message from a receiver.- Parameters:
msg
- flyweight over the network packet.srcAddress
- that the setup message has come from.destinationRegistrationId
- registrationId of the relevant MDC destination orAeron.NULL_VALUE
conductorProxy
- to send messages back to the conductor.
-
onRttMeasurement
Process RTT (Round Trip Timing) message from a receiver.- Parameters:
msg
- flyweight over the network packet.srcAddress
- that the RTT message has come from.
-
resend
public void resend(int termId, int termOffset, int length) Called when a frame should be sent to request the retransmission of data.- Specified by:
resend
in interfaceRetransmitSender
- Parameters:
termId
- containing the data to NAK.termOffset
- of the data to NAK.length
- of the data to NAK.
-
onTimeEvent
Inform resource of timeNs passing and pass it DriverConductor to inform of any state transitions.- Specified by:
onTimeEvent
in interfaceDriverManagedResource
- Parameters:
timeNs
- now in nanoseconds.timeMs
- now in milliseconds for epoch.conductor
- to inform of any state transitions.
-
hasReachedEndOfLife
public boolean hasReachedEndOfLife()Has resource reached end of its life and should be reclaimed?- Specified by:
hasReachedEndOfLife
in interfaceDriverManagedResource
- Returns:
- whether resource has reached end of life or not.
-
responseCorrelationId
public long responseCorrelationId()Get the response correlation id for the publication.- Returns:
- the response correlation id for the publication.
-