Package org.elasticsearch.index.translog
Class BaseTranslogReader
java.lang.Object
org.elasticsearch.index.translog.BaseTranslogReader
- All Implemented Interfaces:
Comparable<BaseTranslogReader>
- Direct Known Subclasses:
TranslogReader
,TranslogWriter
A base class for all classes that allows reading ops from translog files
-
Field Summary
Modifier and TypeFieldDescriptionprotected FileChannel
protected long
protected org.elasticsearch.index.translog.TranslogHeader
protected Path
-
Constructor Summary
ConstructorDescriptionBaseTranslogReader(long generation, FileChannel channel, Path path, org.elasticsearch.index.translog.TranslogHeader header)
-
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedChecksumStreamInput
checksummedStream(ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse)
reads an operation at the given position and returns it.int
long
long
long
long
Returns the primary term associated with this translog reader.org.elasticsearch.index.translog.TranslogSnapshot
path()
protected Translog.Operation
read(BufferedChecksumStreamInput inStream)
protected abstract void
readBytes(ByteBuffer buffer, long position)
reads bytes at position into the given buffer, filling it.protected int
readSize(ByteBuffer reusableBuffer, long position)
read the size of the op (i.e., number of bytes, including the op size) written at the given positionabstract long
toString()
abstract int
-
Field Details
-
generation
protected final long generation -
channel
-
path
-
header
protected final org.elasticsearch.index.translog.TranslogHeader header
-
-
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
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 IOExceptionreads 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
reads bytes at position into the given buffer, filling it.- Throws:
IOException
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<BaseTranslogReader>
-
path
-
getLastModifiedTime
- Throws:
IOException
-