Package io.pravega.client.stream.impl
Class SegmentSelector
- java.lang.Object
-
- io.pravega.client.stream.impl.SegmentSelector
-
public class SegmentSelector extends java.lang.Object
A class that determines to which segment an event associated with a routing key will go. This is invoked on every writeEvent call to decide how to send a particular segment. It is acceptable for it to cache the current set of segments for a stream, as it will be queried again if a segment has been sealed.
-
-
Constructor Summary
Constructors Constructor Description SegmentSelector(Stream stream, Controller controller, SegmentOutputStreamFactory outputStreamFactory, EventWriterConfig config, DelegationTokenProvider tokenProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Segment
getSegmentForEvent(java.lang.String routingKey)
SegmentOutputStream
getSegmentOutputStreamForKey(java.lang.String routingKey)
Selects which segment an event should be written to.java.util.List<Segment>
getSegments()
java.util.Map<Segment,SegmentOutputStream>
getWriters()
boolean
isStreamSealed()
A flag that is used to determine if the stream has been sealed.java.util.List<PendingEvent>
refreshSegmentEventWriters(java.util.function.Consumer<Segment> segmentSealedCallBack)
Refresh the latest list of segments in the given stream.java.util.List<PendingEvent>
refreshSegmentEventWritersUponSealed(Segment sealedSegment, java.util.function.Consumer<Segment> segmentSealedCallback)
Refresh segment writers corresponding to the successors of the sealed segment and return inflight event list of the sealed segment.
-
-
-
Constructor Detail
-
SegmentSelector
@ConstructorProperties({"stream","controller","outputStreamFactory","config","tokenProvider"}) public SegmentSelector(Stream stream, Controller controller, SegmentOutputStreamFactory outputStreamFactory, EventWriterConfig config, DelegationTokenProvider tokenProvider)
-
-
Method Detail
-
getSegmentOutputStreamForKey
public SegmentOutputStream getSegmentOutputStreamForKey(java.lang.String routingKey)
Selects which segment an event should be written to.- Parameters:
routingKey
- The key that should be used to select from the segment that the event should go to.- Returns:
- The SegmentOutputStream for the segment that has been selected or null if
refreshSegmentEventWriters(Consumer)
needs to be called.
-
getSegmentForEvent
public Segment getSegmentForEvent(java.lang.String routingKey)
-
refreshSegmentEventWritersUponSealed
public java.util.List<PendingEvent> refreshSegmentEventWritersUponSealed(Segment sealedSegment, java.util.function.Consumer<Segment> segmentSealedCallback)
Refresh segment writers corresponding to the successors of the sealed segment and return inflight event list of the sealed segment. The segment writer for sealed segment is not removed.- Parameters:
sealedSegment
- The sealed segment.segmentSealedCallback
- Sealed segment callback.- Returns:
- List of pending events.
-
refreshSegmentEventWriters
public java.util.List<PendingEvent> refreshSegmentEventWriters(java.util.function.Consumer<Segment> segmentSealedCallBack)
Refresh the latest list of segments in the given stream.- Parameters:
segmentSealedCallBack
- Method to be executed on receiving SegmentSealed from SSS.- Returns:
- A list of events that were sent to old segments and never acked. These should be re-sent.
-
getSegments
public java.util.List<Segment> getSegments()
-
getWriters
public java.util.Map<Segment,SegmentOutputStream> getWriters()
-
isStreamSealed
public boolean isStreamSealed()
A flag that is used to determine if the stream has been sealed. Note: This flag only returns true if the seal has been detected as a result of callingrefreshSegmentEventWritersUponSealed(io.pravega.client.segment.impl.Segment, java.util.function.Consumer<io.pravega.client.segment.impl.Segment>)
.- Returns:
- Whether the stream seal has been detected for this stream.
-
-