Class SlowBufferedChannel

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

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

      • getDelay

        public volatile long getDelay
      • addDelay

        public volatile long addDelay
      • flushDelay

        public volatile long flushDelay
    • Constructor Detail

      • SlowBufferedChannel

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

        public SlowBufferedChannel​(io.netty.buffer.ByteBufAllocator allocator,
                                   java.nio.channels.FileChannel fc,
                                   int writeCapacity,
                                   int readCapacity)
                            throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • 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 java.io.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:
        java.io.IOException - if a write operation fails.
      • flush

        public void flush()
                   throws java.io.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:
        java.io.IOException - if the write fails.
      • forceWrite

        public long forceWrite​(boolean forceMetadata)
                        throws java.io.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:
        java.io.IOException
      • read

        public int read​(io.netty.buffer.ByteBuf dest,
                        long pos)
                 throws java.io.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:
        java.io.IOException - if I/O error occurs