java.lang.Object
org.apache.bookkeeper.bookie.storage.directentrylogger.DirectWriter
All Implemented Interfaces:
AutoCloseable, LogWriter

class DirectWriter extends Object implements LogWriter
  • Field Details

    • nativeIO

      final NativeIO nativeIO
    • fd

      final int fd
    • id

      final int id
    • filename

      final String filename
    • bufferPool

      final BufferPool bufferPool
    • writeExecutor

      final ExecutorService writeExecutor
    • bufferLock

      final Object bufferLock
    • outstandingWrites

      final List<Future<?>> outstandingWrites
    • slog

      final Slogger slog
    • nativeBuffer

      Buffer nativeBuffer
    • offset

      long offset
  • Constructor Details

  • Method Details

    • logId

      public int logId()
      Description copied from interface: LogWriter
      Return the ID of the log being written.
      Specified by:
      logId in interface LogWriter
    • writeAt

      public void writeAt(long offset, io.netty.buffer.ByteBuf buf) throws IOException
      Description copied from interface: LogWriter
      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).
      Specified by:
      writeAt in interface LogWriter
      Throws:
      IOException
    • writeDelimited

      public int writeDelimited(io.netty.buffer.ByteBuf buf) throws IOException
      Description copied from interface: LogWriter
      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.
      Specified by:
      writeDelimited in interface LogWriter
      Returns:
      the offset of the buffer within the file.
      Throws:
      IOException
    • position

      public void position(long offset) throws IOException
      Description copied from interface: LogWriter
      Set the offset within the log at which the next call to #writeDelimited will start writing.
      Specified by:
      position in interface LogWriter
      Throws:
      IOException
    • position

      public long position()
      Description copied from interface: LogWriter
      The current offset within the log at which the next call to #writeDelimited will start writing.
      Specified by:
      position in interface LogWriter
    • flush

      public void flush() throws IOException
      Description copied from interface: LogWriter
      Flush all buffered writes to disk. This call must ensure that the bytes are actually on disk before returning.
      Specified by:
      flush in interface LogWriter
      Throws:
      IOException
    • close

      public void close() throws IOException
      Description copied from interface: LogWriter
      Close any held resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface LogWriter
      Throws:
      IOException
    • serializedSize

      public int serializedSize(io.netty.buffer.ByteBuf buf)
      Specified by:
      serializedSize in interface LogWriter
      Returns:
      the number of bytes consumed by the buffer when written with #writeDelimited