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
public abstract class BaseTranslogReader extends Object implements Comparable<BaseTranslogReader>
A base class for all classes that allows reading ops from translog files
-
-
Field Summary
Fields Modifier and Type Field Description protected FileChannelchannelprotected longgenerationprotected org.elasticsearch.index.translog.TranslogHeaderheaderprotected Pathpath
-
Constructor Summary
Constructors Constructor Description BaseTranslogReader(long generation, FileChannel channel, Path path, org.elasticsearch.index.translog.TranslogHeader header)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected BufferedChecksumStreamInputchecksummedStream(ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse)reads an operation at the given position and returns it.intcompareTo(BaseTranslogReader o)longgetFirstOperationOffset()longgetGeneration()longgetLastModifiedTime()longgetPrimaryTerm()Returns the primary term associated with this translog reader.org.elasticsearch.index.translog.TranslogSnapshotnewSnapshot()Pathpath()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 longsizeInBytes()StringtoString()abstract inttotalOperations()
-
-
-
Field Detail
-
generation
protected final long generation
-
channel
protected final FileChannel channel
-
path
protected final Path path
-
header
protected final org.elasticsearch.index.translog.TranslogHeader header
-
-
Constructor Detail
-
BaseTranslogReader
public BaseTranslogReader(long generation, FileChannel channel, Path path, org.elasticsearch.index.translog.TranslogHeader header)
-
-
Method Detail
-
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
protected Translog.Operation read(BufferedChecksumStreamInput inStream) throws IOException
- 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
-
compareTo
public int compareTo(BaseTranslogReader o)
- Specified by:
compareToin interfaceComparable<BaseTranslogReader>
-
path
public Path path()
-
getLastModifiedTime
public long getLastModifiedTime() throws IOException- Throws:
IOException
-
-