Interface SegmentOutputStream

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface SegmentOutputStream
    extends java.lang.AutoCloseable
    Defines an OutputStream for a segment. Allows data to be appended to the end of the segment by calling write(PendingEvent)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Flushes and then closes the output stream.
      void flush()
      Block on all writes that have not yet completed.
      void flushAsync()
      This is meant to notify that an asynchronous flush call was called.
      long getLastObservedWriteOffset()
      This returns the write offset of a segment that was most recently observed from an Ack.
      java.lang.String getSegmentName()
      Returns the name of the segment associated to this output stream.
      java.util.List<PendingEvent> getUnackedEventsOnSeal()
      Change the state of SegmentOutputStream to sealed to prevent future writes and return the list of unackedEvents.
      void write​(PendingEvent event)
      Writes the provided data to the SegmentOutputStream.
    • Method Detail

      • getSegmentName

        java.lang.String getSegmentName()
        Returns the name of the segment associated to this output stream.
        Returns:
        The name of the segment associated to this output stream.
      • write

        void write​(PendingEvent event)
        Writes the provided data to the SegmentOutputStream. The associated callback will be invoked when the operation is complete.
        Parameters:
        event - The event to be added to the segment.
      • close

        void close()
            throws SegmentSealedException
        Flushes and then closes the output stream. Frees any resources associated with it.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        SegmentSealedException - If the segment is closed for modifications.
      • flushAsync

        void flushAsync()
        This is meant to notify that an asynchronous flush call was called. Possibly a keep alive response can be triggered.
      • getUnackedEventsOnSeal

        java.util.List<PendingEvent> getUnackedEventsOnSeal()
        Change the state of SegmentOutputStream to sealed to prevent future writes and return the list of unackedEvents. This is invoked by the segmentSealed callback to fetch the unackedEvents to be resent to the right SegmentOutputStreams.
        Returns:
        List of all the events that have been passed to write but have not yet been acknowledged as written. The iteration order in the List is from oldest to newest.
      • getLastObservedWriteOffset

        long getLastObservedWriteOffset()
        This returns the write offset of a segment that was most recently observed from an Ack. This may not be the same as the current write offset. If no acks have been observed on this segment it returns -1.