Package org.apache.bookkeeper.bookie
Class SlowBufferedChannel
java.lang.Object
org.apache.bookkeeper.bookie.BufferedChannelBase
org.apache.bookkeeper.bookie.BufferedReadChannel
org.apache.bookkeeper.bookie.BufferedChannel
org.apache.bookkeeper.bookie.SlowBufferedChannel
- All Implemented Interfaces:
Closeable,AutoCloseable
Strictly for testing.
Have to be alongside with prod code for Journal to inject in tests.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.bookkeeper.bookie.BufferedChannelBase
BufferedChannelBase.BufferedChannelClosedException -
Field Summary
FieldsFields inherited from class org.apache.bookkeeper.bookie.BufferedChannel
position, unpersistedBytes, unpersistedBytesBound, writeBuffer, writeBufferStartPosition, writeCapacityFields inherited from class org.apache.bookkeeper.bookie.BufferedReadChannel
cacheHitCount, invocationCount, readBuffer, readBufferStartPosition, readCapacity, sealedFields inherited from class org.apache.bookkeeper.bookie.BufferedChannelBase
fileChannel -
Constructor Summary
ConstructorsConstructorDescriptionSlowBufferedChannel(io.netty.buffer.ByteBufAllocator allocator, FileChannel fc, int capacity) SlowBufferedChannel(io.netty.buffer.ByteBufAllocator allocator, FileChannel fc, int writeCapacity, int readCapacity) -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Write any data in the buffer to the file and advance the writeBufferPosition.longforceWrite(boolean forceMetadata) force a sync operation so that data is persisted to the disk.intread(io.netty.buffer.ByteBuf dest, long pos) Read as many bytes into dest as dest.capacity() starting at position pos in the FileChannel.voidsetAddDelay(long delay) voidsetFlushDelay(long delay) voidsetGetDelay(long delay) voidwrite(io.netty.buffer.ByteBuf src) Write all the data in src to theFileChannel.Methods inherited from class org.apache.bookkeeper.bookie.BufferedChannel
clear, close, flushAndForceWrite, flushAndForceWriteIfRegularFlush, getFileChannelPosition, getNumOfBytesInWriteBuffer, getUnpersistedBytes, position, readMethods inherited from class org.apache.bookkeeper.bookie.BufferedReadChannel
sizeMethods inherited from class org.apache.bookkeeper.bookie.BufferedChannelBase
validateAndGetFileChannel
-
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
Description copied from class:BufferedChannelWrite all the data in src to theFileChannel. 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:
writein classBufferedChannel- Parameters:
src- The source ByteBuffer which contains the data to be written.- Throws:
IOException- if a write operation fails.
-
flush
Description copied from class:BufferedChannelWrite any data in the buffer to the file and advance the writeBufferPosition. Callers are expected to synchronize appropriately- Overrides:
flushin classBufferedChannel- Throws:
IOException- if the write fails.
-
forceWrite
Description copied from class:BufferedChannelforce a sync operation so that data is persisted to the disk.- Overrides:
forceWritein classBufferedChannel- Returns:
- Throws:
IOException
-
read
Description copied from class:BufferedReadChannelRead 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:
readin classBufferedReadChannel- 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
-