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 Details

    • free

      public boolean free()
      Free external resources such as files. If successful then return true.
      Specified by:
      free in interface DriverManagedResource
      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 call DriverManagedResource.free(). That will need to be called separately at the appropriate time.
      Specified by:
      close in interface DriverManagedResource
    • 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

      public String 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

      public void triggerSendSetupFrame(StatusMessageFlyweight msg, InetSocketAddress srcAddress)
      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 interface Subscribable
      Returns:
      registration ID for subscribable.
    • addSubscriber

      public void addSubscriber(SubscriptionLink subscriptionLink, ReadablePosition position, long nowNs)
      Add a subscriber and its position used for tracking consumption.
      Specified by:
      addSubscriber in interface Subscribable
      Parameters:
      subscriptionLink - for identifying the subscriber.
      position - for tracking the subscriber.
      nowNs - for the current time.
    • removeSubscriber

      public void removeSubscriber(SubscriptionLink subscriptionLink, ReadablePosition position)
      Remove a subscriber and its position used for tracking consumption.

      Note: The Subscribable is responsible for calling ReadablePosition.close() on removed positions.

      Specified by:
      removeSubscriber in interface Subscribable
      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 or Aeron.NULL_VALUE
      conductorProxy - to send messages back to the conductor.
    • onRttMeasurement

      public void onRttMeasurement(RttMeasurementFlyweight msg, InetSocketAddress srcAddress)
      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 interface RetransmitSender
      Parameters:
      termId - containing the data to NAK.
      termOffset - of the data to NAK.
      length - of the data to NAK.
    • onTimeEvent

      public void onTimeEvent(long timeNs, long timeMs, DriverConductor conductor)
      Inform resource of timeNs passing and pass it DriverConductor to inform of any state transitions.
      Specified by:
      onTimeEvent in interface DriverManagedResource
      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 interface DriverManagedResource
      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.