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.FileChannel
channel
protected long
generation
protected org.elasticsearch.index.translog.TranslogHeader
header
protected java.nio.file.Path
path
-
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
Modifier and Type Method Description protected BufferedChecksumStreamInput
checksummedStream(java.nio.ByteBuffer reusableBuffer, long position, int opSize, BufferedChecksumStreamInput reuse)
reads an operation at the given position and returns it.int
compareTo(BaseTranslogReader o)
long
getFirstOperationOffset()
long
getGeneration()
long
getLastModifiedTime()
long
getPrimaryTerm()
Returns the primary term associated with this translog reader.org.elasticsearch.index.translog.TranslogSnapshot
newSnapshot()
java.nio.file.Path
path()
protected Translog.Operation
read(BufferedChecksumStreamInput inStream)
protected abstract void
readBytes(java.nio.ByteBuffer buffer, long position)
reads bytes at position into the given buffer, filling it.protected int
readSize(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 long
sizeInBytes()
java.lang.String
toString()
abstract int
totalOperations()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
generation
protected final long generation -
channel
protected final java.nio.channels.FileChannel channel -
path
protected final java.nio.file.Path path -
header
protected final org.elasticsearch.index.translog.TranslogHeader header
-
-
Constructor Details
-
BaseTranslogReader
public BaseTranslogReader(long generation, java.nio.channels.FileChannel channel, java.nio.file.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(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.IOExceptionreads 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
- 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:
toString
in classjava.lang.Object
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<BaseTranslogReader>
-
path
public java.nio.file.Path path() -
getLastModifiedTime
public long getLastModifiedTime() throws java.io.IOException- Throws:
java.io.IOException
-