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
FieldsModifier and TypeFieldDescriptionprotected FileChannelprotected longprotected org.elasticsearch.index.translog.TranslogHeaderprotected Path -
Constructor Summary
ConstructorsConstructorDescriptionBaseTranslogReader(long generation, FileChannel channel, Path path, org.elasticsearch.index.translog.TranslogHeader header) -
Method Summary
Modifier and TypeMethodDescriptionprotected BufferedChecksumStreamInputchecksummedStream(ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse)reads an operation at the given position and returns it.intlonglonglonglongReturns the primary term associated with this translog reader.org.elasticsearch.index.translog.TranslogSnapshotpath()protected Translog.Operationread(BufferedChecksumStreamInput inStream)protected abstract voidreadBytes(ByteBuffer buffer, long position)reads bytes at position into the given buffer, filling it.protected intreadSize(ByteBuffer reusableBuffer, long position)read the size of the op (i.e., number of bytes, including the op size) written at the given positionabstract longtoString()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:
compareToin interfaceComparable<BaseTranslogReader>
-
path
-
getLastModifiedTime
- Throws:
IOException
-