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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long getLargestSequence()
      Return the largest sequence seen by the data store.
      T load​(long sequence)
      Loads the value of a given sequence.
      void store​(long sequence, T data)
      Stores one item with it's corresponding sequence.
      void storeAll​(long firstItemSequence, T[] items)
      Stores multiple items.
    • Method Detail

      • store

        void store​(long sequence,
                   T data)
        Stores one item with it's 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:
        Ringbuffer.add(Object), Ringbuffer.addAsync(Object, com.hazelcast.ringbuffer.OverflowPolicy)
      • 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:
        Ringbuffer.addAllAsync(java.util.Collection, com.hazelcast.ringbuffer.OverflowPolicy)
      • 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:
        Ringbuffer.readOne(long), Ringbuffer.readManyAsync(long, int, int, IFunction)
      • 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 largest sequence number.
        Returns:
        the largest sequence of the data in the data store