Interface LogStorage
- All Known Implementing Classes:
AtomixLogStorage
public interface LogStorage
Storage abstraction for the log stream API. The storage is expected to store the given blocks of
data atomically (i.e. a block is fully written or not at all), in the order in which they were
appended.
The main access pattern is via the LogStorageReader, and is expected to be sequential.
The reader should support seek as efficiently as possible, but random access is not the common
case.
The lifecycle of the storage is expected to be independent of the log stream, and the storage is simply passed along to the stream.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn append listener can be added to an append call to be notified of different events that can occur during the append operation.static interfaceConsumers of LogStorage can use this listener to get notified when new records are committed. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommitListener(LogStorage.CommitListener listener) Register a commit listenervoidappend(long lowestPosition, long highestPosition, ByteBuffer blockBuffer, LogStorage.AppendListener listener) Writes a block containing one or multiple log entries in the storage and returns the address at which the block has been written.Creates a new reader initialized at the given address.voidRemove a commit listener
-
Method Details
-
newReader
LogStorageReader newReader()Creates a new reader initialized at the given address.- Returns:
- a new stateful storage reader
-
append
void append(long lowestPosition, long highestPosition, ByteBuffer blockBuffer, LogStorage.AppendListener listener) Writes a block containing one or multiple log entries in the storage and returns the address at which the block has been written.Storage implementations must guarantee eventually atomicity. When this method completes, either all the bytes must be written or none at all.
The caller of this method must guarantee that the provided block contains unfragmented log entries.
- Parameters:
lowestPosition- the lowest record position of all records in the block bufferhighestPosition- the highest record position of all records in the block bufferblockBuffer- the buffer containing a block of log entries to be written into storage
-
addCommitListener
Register a commit listener- Parameters:
listener- the listener which will be notified when a new record is committed.
-
removeCommitListener
Remove a commit listener- Parameters:
listener- the listener to remove
-