Package org.elasticsearch.index.translog
Class TranslogReader
- java.lang.Object
-
- org.elasticsearch.index.translog.BaseTranslogReader
-
- org.elasticsearch.index.translog.TranslogReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Comparable<BaseTranslogReader>
public class TranslogReader extends BaseTranslogReader implements Closeable
an immutable translog filereader
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicBooleanclosedprotected longlength-
Fields inherited from class org.elasticsearch.index.translog.BaseTranslogReader
channel, generation, header, path
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidensureOpen()protected booleanisClosed()static TranslogReaderopen(FileChannel channel, Path path, org.elasticsearch.index.translog.Checkpoint checkpoint, String translogUUID)Given a file channel, opens aTranslogReader, taking care of checking and validating the file header.protected voidreadBytes(ByteBuffer buffer, long position)reads an operation at the given position into the given buffer.longsizeInBytes()inttotalOperations()-
Methods inherited from class org.elasticsearch.index.translog.BaseTranslogReader
checksummedStream, compareTo, getFirstOperationOffset, getGeneration, getLastModifiedTime, getPrimaryTerm, newSnapshot, path, read, readSize, toString
-
-
-
-
Field Detail
-
length
protected final long length
-
closed
protected final AtomicBoolean closed
-
-
Method Detail
-
open
public static TranslogReader open(FileChannel channel, Path path, org.elasticsearch.index.translog.Checkpoint checkpoint, String translogUUID) throws IOException
Given a file channel, opens aTranslogReader, taking care of checking and validating the file header.- Parameters:
channel- the translog file channelpath- the path to the translogcheckpoint- the translog checkpointtranslogUUID- the tranlog UUID- Returns:
- a new TranslogReader
- Throws:
IOException- if any of the file operations resulted in an I/O exception
-
sizeInBytes
public long sizeInBytes()
- Specified by:
sizeInBytesin classBaseTranslogReader
-
totalOperations
public int totalOperations()
- Specified by:
totalOperationsin classBaseTranslogReader
-
readBytes
protected void readBytes(ByteBuffer buffer, long position) throws IOException
reads an operation at the given position into the given buffer.- Specified by:
readBytesin classBaseTranslogReader- Throws:
IOException
-
close
public final void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isClosed
protected final boolean isClosed()
-
ensureOpen
protected void ensureOpen()
-
-