Class 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.
    • 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()