Class SlowBufferedChannel

All Implemented Interfaces:
Closeable, AutoCloseable

public class SlowBufferedChannel extends BufferedChannel
Strictly for testing. Have to be alongside with prod code for Journal to inject in tests.
  • Field Details

    • getDelay

      public volatile long getDelay
    • addDelay

      public volatile long addDelay
    • flushDelay

      public volatile long flushDelay
  • Constructor Details

    • SlowBufferedChannel

      public SlowBufferedChannel(io.netty.buffer.ByteBufAllocator allocator, FileChannel fc, int capacity) throws IOException
      Throws:
      IOException
    • SlowBufferedChannel

      public SlowBufferedChannel(io.netty.buffer.ByteBufAllocator allocator, FileChannel fc, int writeCapacity, int readCapacity) throws IOException
      Throws:
      IOException
  • Method Details

    • setAddDelay

      public void setAddDelay(long delay)
    • setGetDelay

      public void setGetDelay(long delay)
    • setFlushDelay

      public void setFlushDelay(long delay)
    • write

      public void write(io.netty.buffer.ByteBuf src) throws IOException
      Description copied from class: BufferedChannel
      Write all the data in src to the FileChannel. Note that this function can buffer or re-order writes based on the implementation. These writes will be flushed to the disk only when flush() is invoked.
      Overrides:
      write in class BufferedChannel
      Parameters:
      src - The source ByteBuffer which contains the data to be written.
      Throws:
      IOException - if a write operation fails.
    • flush

      public void flush() throws IOException
      Description copied from class: BufferedChannel
      Write any data in the buffer to the file and advance the writeBufferPosition. Callers are expected to synchronize appropriately
      Overrides:
      flush in class BufferedChannel
      Throws:
      IOException - if the write fails.
    • forceWrite

      public long forceWrite(boolean forceMetadata) throws IOException
      Description copied from class: BufferedChannel
      force a sync operation so that data is persisted to the disk.
      Overrides:
      forceWrite in class BufferedChannel
      Returns:
      Throws:
      IOException
    • read

      public int read(io.netty.buffer.ByteBuf dest, long pos) throws IOException
      Description copied from class: BufferedReadChannel
      Read as many bytes into dest as dest.capacity() starting at position pos in the FileChannel. This function can read from the buffer or the file channel depending on the implementation..
      Overrides:
      read in class BufferedReadChannel
      Returns:
      The total number of bytes read. -1 if the given position is greater than or equal to the file's current size.
      Throws:
      IOException - if I/O error occurs