Interface RingbufferStore<T>

Type Parameters:
T - ring buffer item type

public interface RingbufferStore<T>
Ringbuffer store makes a ring buffer backed by a central data store; such as database, disk, etc.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Return the largest sequence seen by the data store.
    load(long sequence)
    Loads the value of a given sequence.
    void
    store(long sequence, T data)
    Stores one item with its corresponding sequence.
    void
    storeAll(long firstItemSequence, T[] items)
    Stores multiple items.
  • Method Details

    • store

      void store(long sequence, T data)
      Stores one item with its corresponding sequence.

      Exceptions thrown by this method prevent Ringbuffer from adding the item. It is the responsibility of the store to ensure that it keeps consistent with the Ringbuffer and in case of an exception is thrown, the data is not in the store.

      Parameters:
      sequence - the sequence ID of the data
      data - the value of the data to store
      See Also:
    • storeAll

      void storeAll(long firstItemSequence, T[] items)
      Stores multiple items. Implementation of this method can optimize the store operation.

      Exceptions thrown by this method prevents Ringbuffer from adding any of the items. It is the responsibility of the store to ensure that it keeps consistent with the Ringbuffer and in case of an exception is thrown the passed data is not in the store.

      Parameters:
      firstItemSequence - the sequence of the first item
      items - the items that are being stored
      See Also:
    • load

      T load(long sequence)
      Loads the value of a given sequence. Null value means that the item was not found. This method is invoked by the ringbuffer if an item is requested with a sequence which is no longer in the Ringbuffer.
      Parameters:
      sequence - the sequence of the requested item
      Returns:
      requested item, null if not found
      See Also:
    • getLargestSequence

      long getLargestSequence()
      Return the largest sequence seen by the data store. Can return -1 if the data store doesn't have or can't access any data. Used to initialize a Ringbuffer with the previously seen the largest sequence number.
      Returns:
      the largest sequence of the data in the data store