All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DirectWriter

interface LogWriter extends AutoCloseable
Interface for writing data to a bookkeeper entry log.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close any held resources.
    void
    Flush all buffered writes to disk.
    int
    Return the ID of the log being written.
    long
    The current offset within the log at which the next call to #writeDelimited will start writing.
    void
    position(long offset)
    Set the offset within the log at which the next call to #writeDelimited will start writing.
    int
    serializedSize(io.netty.buffer.ByteBuf buf)
     
    void
    writeAt(long offset, io.netty.buffer.ByteBuf buf)
    Write the contents of a buffer at a predefined position in the log.
    int
    writeDelimited(io.netty.buffer.ByteBuf buf)
    Write a delimited buffer the log.
  • Method Details

    • logId

      int logId()
      Return the ID of the log being written.
    • writeAt

      void writeAt(long offset, io.netty.buffer.ByteBuf buf) throws IOException
      Write the contents of a buffer at a predefined position in the log. Both the position and the size of the buffer must be page aligned (i.e. to 4096).
      Throws:
      IOException
    • writeDelimited

      int writeDelimited(io.netty.buffer.ByteBuf buf) throws IOException
      Write a delimited buffer the log. The size of the buffer is first written and then the buffer itself. Note that the returned offset is for the buffer itself, not the size. So, if a buffer is written at the start of the file, the returned offset will be 4, not 0. The returned offset is an int. Consequently, entries can only be written in the first Integer.MAX_VALUE bytes of the file. This is due to how offsets are stored in the index.
      Returns:
      the offset of the buffer within the file.
      Throws:
      IOException
    • serializedSize

      int serializedSize(io.netty.buffer.ByteBuf buf)
      Returns:
      the number of bytes consumed by the buffer when written with #writeDelimited
    • position

      long position() throws IOException
      The current offset within the log at which the next call to #writeDelimited will start writing.
      Throws:
      IOException
    • position

      void position(long offset) throws IOException
      Set the offset within the log at which the next call to #writeDelimited will start writing.
      Throws:
      IOException
    • flush

      void flush() throws IOException
      Flush all buffered writes to disk. This call must ensure that the bytes are actually on disk before returning.
      Throws:
      IOException
    • close

      void close() throws IOException
      Close any held resources.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException