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.

  • 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 buffer
      highestPosition - the highest record position of all records in the block buffer
      blockBuffer - the buffer containing a block of log entries to be written into storage
    • addCommitListener

      void addCommitListener(LogStorage.CommitListener listener)
      Register a commit listener
      Parameters:
      listener - the listener which will be notified when a new record is committed.
    • removeCommitListener

      void removeCommitListener(LogStorage.CommitListener listener)
      Remove a commit listener
      Parameters:
      listener - the listener to remove