Interface LogReader

  • All Superinterfaces:
    java.lang.AutoCloseable
    All Known Implementing Classes:
    DirectReader

    public interface LogReader
    extends java.lang.AutoCloseable
    Interface for reading from a bookkeeper entry log.
    • 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.EOFException
        Read a buffer from the file. It is the responsibility of the caller to release the returned buffer.
        Parameters:
        offset - the offset to read at
        size - the number of bytes to read
        Returns:
        a bytebuf. The caller must release.
        Throws:
        java.io.IOException
        java.io.EOFException
      • readIntoBufferAt

        void readIntoBufferAt​(io.netty.buffer.ByteBuf buffer,
                              long offset,
                              int size)
                       throws java.io.IOException,
                              java.io.EOFException
        Throws:
        java.io.IOException
        java.io.EOFException
      • readIntAt

        int readIntAt​(long offset)
               throws java.io.IOException,
                      java.io.EOFException
        Read an integer at a given offset.
        Parameters:
        offset - the offset to read from.
        Returns:
        the integer at that offset.
        Throws:
        java.io.IOException
        java.io.EOFException
      • readLongAt

        long readLongAt​(long offset)
                 throws java.io.IOException,
                        java.io.EOFException
        Read an long at a given offset.
        Parameters:
        offset - the offset to read from.
        Returns:
        the long at that offset.
        Throws:
        java.io.IOException
        java.io.EOFException
      • readEntryAt

        io.netty.buffer.ByteBuf readEntryAt​(int offset)
                                     throws java.io.IOException,
                                            java.io.EOFException
        Read 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.IOException
        java.io.EOFException
      • close

        void close()
            throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException
      • isClosed

        boolean isClosed()