Class AtomixLogStorageReader
- All Implemented Interfaces:
LogStorageReader,Closeable,AutoCloseable,Iterator<org.agrona.DirectBuffer>
LogStorageReader over a RaftLogReader. Each ApplicationEntry
is considered a block (as per the log storage definition).
The implementation does look-ahead by one entry. This is necessary because we usually want to
seek to the entry which contains the given position, and in order to know that it does we need to
read it, and only then return it via the next next() call. It is also safe as we read
only committed entries, which may be compacted but remain valid.
Note that due to the look-ahead, calling hasNext() may result in doing some I/O and
mutating the state of the reader.
The reader currently simply returns the block as is without copying it - this is safe at the
moment because the serialization in the underlying RaftLog
already copies the data from disk. When switching to zero-copy, however, because of the
look-ahead, this reader will have to copy the block. At that point, we may want to look into
doing more than a single-step look-ahead (either here or in the LogStreamReader).
-
Constructor Details
-
AtomixLogStorageReader
-
-
Method Details
-
seek
public void seek(long position) - Specified by:
seekin interfaceLogStorageReader
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceLogStorageReader
-
hasNext
public boolean hasNext() -
next
public org.agrona.DirectBuffer next()
-