Interface LogReader
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
DirectReader
public interface LogReader extends java.lang.AutoCloseableInterface for reading from a bookkeeper entry log.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()booleanisClosed()intlogId()longmaxOffset()io.netty.buffer.ByteBufreadBufferAt(long offset, int size)Read a buffer from the file.io.netty.buffer.ByteBufreadEntryAt(int offset)Read an entry at a given offset.intreadIntAt(long offset)Read an integer at a given offset.voidreadIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size)longreadLongAt(long offset)Read an long at a given offset.
-
-
-
Method Detail
-
logId
int logId()
- Returns:
- the id of the log being read from.
-
maxOffset
long maxOffset()
- Returns:
- the maximum offset in the file that can be read from.
-
readBufferAt
io.netty.buffer.ByteBuf readBufferAt(long offset, int size) throws java.io.IOException, java.io.EOFExceptionRead a buffer from the file. It is the responsibility of the caller to release the returned buffer.- Parameters:
offset- the offset to read atsize- the number of bytes to read- Returns:
- a bytebuf. The caller must release.
- Throws:
java.io.IOExceptionjava.io.EOFException
-
readIntoBufferAt
void readIntoBufferAt(io.netty.buffer.ByteBuf buffer, long offset, int size) throws java.io.IOException, java.io.EOFException- Throws:
java.io.IOExceptionjava.io.EOFException
-
readIntAt
int readIntAt(long offset) throws java.io.IOException, java.io.EOFExceptionRead an integer at a given offset.- Parameters:
offset- the offset to read from.- Returns:
- the integer at that offset.
- Throws:
java.io.IOExceptionjava.io.EOFException
-
readLongAt
long readLongAt(long offset) throws java.io.IOException, java.io.EOFExceptionRead an long at a given offset.- Parameters:
offset- the offset to read from.- Returns:
- the long at that offset.
- Throws:
java.io.IOExceptionjava.io.EOFException
-
readEntryAt
io.netty.buffer.ByteBuf readEntryAt(int offset) throws java.io.IOException, java.io.EOFExceptionRead an entry at a given offset. The size of the entry must be at (offset - Integer.BYTES). The payload of the entry starts at offset. It is the responsibility of the caller to release the returned buffer.- Parameters:
offset- the offset at which to read the entry.- Returns:
- a bytebuf. The caller must release.
- Throws:
java.io.IOExceptionjava.io.EOFException
-
close
void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.io.IOException
-
isClosed
boolean isClosed()
-
-