Interface StreamReplicator.Reader
- All Superinterfaces:
AutoCloseable
,Closeable
,Replicator.Accessor
,Replicator.Reader
- Enclosing interface:
StreamReplicator
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 TypeMethodDescriptiondefault 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.Methods inherited from interface org.cojen.tupl.repl.Replicator.Accessor
addCommitListener, close, commitPosition, position, term, termEndPosition, termStartPosition, uponCommit, waitForCommit, waitForEndCommit
-
Method Details
-
read
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
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
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 soonIOException
-
tryRead
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
-