Class BaseTranslogReader

java.lang.Object
org.elasticsearch.index.translog.BaseTranslogReader
All Implemented Interfaces:
Comparable<BaseTranslogReader>
Direct Known Subclasses:
TranslogReader, TranslogWriter

public abstract class BaseTranslogReader extends Object implements Comparable<BaseTranslogReader>
A base class for all classes that allows reading ops from translog files
  • Field Details

    • generation

      protected final long generation
    • channel

      protected final FileChannel channel
    • path

      protected final Path path
  • Constructor Details

    • BaseTranslogReader

      public BaseTranslogReader(long generation, FileChannel channel, Path path, org.elasticsearch.index.translog.TranslogHeader header)
  • Method Details

    • getGeneration

      public long getGeneration()
    • sizeInBytes

      public abstract long sizeInBytes()
    • totalOperations

      public abstract int totalOperations()
    • getFirstOperationOffset

      public final long getFirstOperationOffset()
    • getPrimaryTerm

      public final long getPrimaryTerm()
      Returns the primary term associated with this translog reader.
    • readSize

      protected final int readSize(ByteBuffer reusableBuffer, long position) throws IOException
      read the size of the op (i.e., number of bytes, including the op size) written at the given position
      Throws:
      IOException
    • newSnapshot

      public org.elasticsearch.index.translog.TranslogSnapshot newSnapshot()
    • checksummedStream

      protected final BufferedChecksumStreamInput checksummedStream(ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse) throws IOException
      reads an operation at the given position and returns it. The buffer length is equal to the number of bytes reads.
      Throws:
      IOException
    • read

      Throws:
      IOException
    • readBytes

      protected abstract void readBytes(ByteBuffer buffer, long position) throws IOException
      reads bytes at position into the given buffer, filling it.
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(BaseTranslogReader o)
      Specified by:
      compareTo in interface Comparable<BaseTranslogReader>
    • path

      public Path path()
    • getLastModifiedTime

      public long getLastModifiedTime() throws IOException
      Throws:
      IOException