Class TranslogReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Comparable<BaseTranslogReader>

    public class TranslogReader
    extends BaseTranslogReader
    implements java.io.Closeable
    an immutable translog filereader
    • Field Detail

      • length

        protected final long length
      • closed

        protected final java.util.concurrent.atomic.AtomicBoolean closed
    • Method Detail

      • open

        public static TranslogReader open​(java.nio.channels.FileChannel channel,
                                          java.nio.file.Path path,
                                          org.elasticsearch.index.translog.Checkpoint checkpoint,
                                          java.lang.String translogUUID)
                                   throws java.io.IOException
        Given a file channel, opens a TranslogReader, taking care of checking and validating the file header.
        Parameters:
        channel - the translog file channel
        path - the path to the translog
        checkpoint - the translog checkpoint
        translogUUID - the tranlog UUID
        Returns:
        a new TranslogReader
        Throws:
        java.io.IOException - if any of the file operations resulted in an I/O exception
      • readBytes

        protected void readBytes​(java.nio.ByteBuffer buffer,
                                 long position)
                          throws java.io.IOException
        reads an operation at the given position into the given buffer.
        Specified by:
        readBytes in class BaseTranslogReader
        Throws:
        java.io.IOException
      • close

        public final void close()
                         throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • isClosed

        protected final boolean isClosed()
      • ensureOpen

        protected void ensureOpen()