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 TypeMethodDescriptionvoidaddSubscriber(SubscriptionLink subscriptionLink, ReadablePosition position, long nowNs) Add a subscriber and its position used for tracking consumption.channel()Channel URI string for this publication.voidclose()Close resources that are not external.booleanfree()Free external resources such as files.booleanHas resource reached end of its life and should be reclaimed?voidonError(ErrorFlyweight msg, InetSocketAddress srcAddress, long destinationRegistrationId, DriverConductorProxy conductorProxy) Process an error message from a receiver.voidonNak(int termId, int termOffset, int length) Process a NAK message so a retransmit can occur.voidonRttMeasurement(RttMeasurementFlyweight msg, InetSocketAddress srcAddress) Process RTT (Round Trip Timing) message from a receiver.voidonStatusMessage(StatusMessageFlyweight msg, InetSocketAddress srcAddress, DriverConductorProxy conductorProxy) Process a status message to track connectivity and apply flow control.voidonTimeEvent(long timeNs, long timeMs, DriverConductor conductor) Inform resource of timeNs passing and pass it DriverConductor to inform of any state transitions.voidremoveSubscriber(SubscriptionLink subscriptionLink, ReadablePosition position) Remove a subscriber and its position used for tracking consumption.voidresend(int termId, int termOffset, int length) Called when a frame should be sent to request the retransmission of data.longGet the response correlation id for the publication.intSession id allocated to this stream.intstreamId()Stream id within the channel.longRegistration ID that is in use by the subscribable.longTime of the last status message a from a receiver.voidtriggerSendSetupFrame(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:
freein 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:
closein 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:
subscribableRegistrationIdin interfaceSubscribable- Returns:
- registration ID for subscribable.
-
addSubscriber
Add a subscriber and its position used for tracking consumption.- Specified by:
addSubscriberin 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
Subscribableis responsible for callingReadablePosition.close()on removed positions.- Specified by:
removeSubscriberin 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_VALUEconductorProxy- 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:
resendin 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:
onTimeEventin 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:
hasReachedEndOfLifein 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.
-