Package io.aeron.driver
Class PublicationImage
java.lang.Object
io.aeron.driver.PublicationImage
- All Implemented Interfaces:
DriverManagedResource
,LossHandler
,Subscribable
public final class PublicationImage
extends Object
implements LossHandler, DriverManagedResource, Subscribable
State maintained for active sessionIds within a channel for receiver processing.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubscriber
(SubscriptionLink subscriptionLink, ReadablePosition subscriberPosition, long nowNs) Add a subscriber and its position used for tracking consumption.channel()
Get the string representation of the channel URI.void
close()
Close resources that are not external.long
The correlation id assigned by the driver when created.boolean
free()
Free external resources such as files.boolean
Has resource reached end of its life and should be reclaimed?void
onGapDetected
(int termId, int termOffset, int length) Called from theLossDetector
when gap is detected by theDriverConductor
thread.void
onTimeEvent
(long timeNs, long timesMs, DriverConductor conductor) Inform resource of timeNs passing and pass it DriverConductor to inform of any state transitions.void
removeSubscriber
(SubscriptionLink subscriptionLink, ReadablePosition subscriberPosition) Remove a subscriber and its position used for tracking consumption.int
The session id of the channel from a publisher.int
streamId()
The stream id of this image within a channel.long
Registration ID that is in use by the subscribable.toString()
-
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
-
correlationId
public long correlationId()The correlation id assigned by the driver when created.- Returns:
- the correlation id assigned by the driver when created.
-
sessionId
public int sessionId()The session id of the channel from a publisher.- Returns:
- session id of the channel from a publisher.
-
streamId
public int streamId()The stream id of this image within a channel.- Returns:
- stream id of this image within a channel.
-
channel
Get the string representation of the channel URI.- Returns:
- the string representation of the channel URI.
-
subscribableRegistrationId
public long subscribableRegistrationId()Registration ID that is in use by the subscribable.- Specified by:
subscribableRegistrationId
in interfaceSubscribable
- Returns:
- registration ID for subscribable.
-
addSubscriber
public void addSubscriber(SubscriptionLink subscriptionLink, ReadablePosition subscriberPosition, long nowNs) Add a subscriber and its position used for tracking consumption.- Specified by:
addSubscriber
in interfaceSubscribable
- Parameters:
subscriptionLink
- for identifying the subscriber.subscriberPosition
- for tracking the subscriber.nowNs
- for the current time.
-
removeSubscriber
public void removeSubscriber(SubscriptionLink subscriptionLink, ReadablePosition subscriberPosition) 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.subscriberPosition
- for tracking the subscriber.
-
onGapDetected
public void onGapDetected(int termId, int termOffset, int length) Called from theLossDetector
when gap is detected by theDriverConductor
thread.Called when a gap in the message stream has been detected.
- Specified by:
onGapDetected
in interfaceLossHandler
- Parameters:
termId
- for the gaptermOffset
- for the beginning of the gaplength
- of the gap
-
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.timesMs
- 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.
-
toString
-