Package org.elasticsearch.index.translog
Class TranslogReader
- java.lang.Object
-
- org.elasticsearch.index.translog.BaseTranslogReader
-
- org.elasticsearch.index.translog.TranslogReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Comparable<BaseTranslogReader>
public class TranslogReader extends BaseTranslogReader implements java.io.Closeable
an immutable translog filereader
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicBoolean
closed
protected long
length
-
Fields inherited from class org.elasticsearch.index.translog.BaseTranslogReader
channel, generation, header, path
-
-
Method Summary
Modifier and Type Method Description void
close()
protected void
ensureOpen()
protected boolean
isClosed()
static TranslogReader
open(java.nio.channels.FileChannel channel, java.nio.file.Path path, org.elasticsearch.index.translog.Checkpoint checkpoint, java.lang.String translogUUID)
Given a file channel, opens aTranslogReader
, taking care of checking and validating the file header.protected void
readBytes(java.nio.ByteBuffer buffer, long position)
reads an operation at the given position into the given buffer.long
sizeInBytes()
int
totalOperations()
-
Methods inherited from class org.elasticsearch.index.translog.BaseTranslogReader
checksummedStream, compareTo, getFirstOperationOffset, getGeneration, getLastModifiedTime, getPrimaryTerm, newSnapshot, path, read, readSize, toString
-
-
-
-
Method Detail
-
open
public static TranslogReader open(java.nio.channels.FileChannel channel, java.nio.file.Path path, org.elasticsearch.index.translog.Checkpoint checkpoint, java.lang.String translogUUID) throws java.io.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:
java.io.IOException
- if any of the file operations resulted in an I/O exception
-
sizeInBytes
public long sizeInBytes()
- Specified by:
sizeInBytes
in classBaseTranslogReader
-
totalOperations
public int totalOperations()
- Specified by:
totalOperations
in classBaseTranslogReader
-
readBytes
protected void readBytes(java.nio.ByteBuffer buffer, long position) throws java.io.IOException
reads an operation at the given position into the given buffer.- Specified by:
readBytes
in classBaseTranslogReader
- Throws:
java.io.IOException
-
close
public final void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isClosed
protected final boolean isClosed()
-
ensureOpen
protected void ensureOpen()
-
-