Interface StreamReplicator.Reader

All Superinterfaces:
AutoCloseable, Closeable, Replicator.Accessor, Replicator.Reader
Enclosing interface:
StreamReplicator

public static interface StreamReplicator.Reader extends Replicator.Reader
Interface called by any group member for reading committed messages. Readers don't track which messages are applied — applications are responsible for tracking the highest applied position. When an application restarts, it must open the reader at an appropriate position.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    read(byte[] buf)
    Blocks until log messages are available, never reading past a commit position or term.
    int
    read(byte[] buf, int offset, int length)
    Blocks until log messages are available, never reading past a commit position or term.
    default void
    readFully(byte[] buf, int offset, int length)
    Blocks until the buffer is fully read with messages, never reading past a commit position or term.
    int
    tryRead(byte[] buf, int offset, int length)
    Reads whatever log data is available, never higher than a commit position, never higher than a term, and never blocking.
  • Method Details

    • read

      default int read(byte[] buf) throws IOException
      Blocks until log messages are available, never reading past a commit position or term.
      Returns:
      amount of bytes read, or EOF (-1) if the term end has been reached
      Throws:
      InvalidReadException - if log was deleted (position is too low)
      IOException
    • read

      int read(byte[] buf, int offset, int length) throws IOException
      Blocks until log messages are available, never reading past a commit position or term.
      Returns:
      amount of bytes read, or EOF (-1) if the term end has been reached
      Throws:
      InvalidReadException - if log was deleted (position is too low)
      IOException
    • readFully

      default void readFully(byte[] buf, int offset, int length) throws IOException
      Blocks until the buffer is fully read with messages, never reading past a commit position or term.
      Throws:
      InvalidReadException - if log was deleted (position is too low)
      EOFException - if the term end has been reached too soon
      IOException
    • tryRead

      int tryRead(byte[] buf, int offset, int length) throws IOException
      Reads whatever log data is available, never higher than a commit position, never higher than a term, and never blocking.
      Returns:
      amount of bytes read, or EOF (-1) if the term end has been reached
      Throws:
      InvalidReadException - if log data was deleted (position is too low)
      IOException