Package org.elasticsearch.index.translog
Class BaseTranslogReader
- java.lang.Object
-
- org.elasticsearch.index.translog.BaseTranslogReader
-
- All Implemented Interfaces:
java.lang.Comparable<BaseTranslogReader>
- Direct Known Subclasses:
TranslogReader,TranslogWriter
public abstract class BaseTranslogReader extends java.lang.Object implements java.lang.Comparable<BaseTranslogReader>
A base class for all classes that allows reading ops from translog files
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.channels.FileChannelchannelprotected longgenerationprotected org.elasticsearch.index.translog.TranslogHeaderheaderprotected java.nio.file.Pathpath
-
Constructor Summary
Constructors Constructor Description BaseTranslogReader(long generation, java.nio.channels.FileChannel channel, java.nio.file.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(java.nio.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()java.nio.file.Pathpath()protected Translog.Operationread(BufferedChecksumStreamInput inStream)protected abstract voidreadBytes(java.nio.ByteBuffer buffer, long position)reads bytes at position into the given buffer, filling it.protected intreadSize(java.nio.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()java.lang.StringtoString()abstract inttotalOperations()
-
-
-
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(java.nio.ByteBuffer reusableBuffer, long position) throws java.io.IOExceptionread the size of the op (i.e., number of bytes, including the op size) written at the given position- Throws:
java.io.IOException
-
newSnapshot
public org.elasticsearch.index.translog.TranslogSnapshot newSnapshot()
-
checksummedStream
protected final BufferedChecksumStreamInput checksummedStream(java.nio.ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse) throws java.io.IOException
reads an operation at the given position and returns it. The buffer length is equal to the number of bytes reads.- Throws:
java.io.IOException
-
read
protected Translog.Operation read(BufferedChecksumStreamInput inStream) throws java.io.IOException
- Throws:
java.io.IOException
-
readBytes
protected abstract void readBytes(java.nio.ByteBuffer buffer, long position) throws java.io.IOExceptionreads bytes at position into the given buffer, filling it.- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(BaseTranslogReader o)
- Specified by:
compareToin interfacejava.lang.Comparable<BaseTranslogReader>
-
path
public java.nio.file.Path path()
-
getLastModifiedTime
public long getLastModifiedTime() throws java.io.IOException- Throws:
java.io.IOException
-
-