Class MemoryStateStore

  • All Implemented Interfaces:
    StateStore, Closeable, AutoCloseable

    public abstract class MemoryStateStore
    extends AbstractStateStore
    A state store in-memory only. Not backed by any persisted storage. Abstract parent class for all state store implementations.
    • Constructor Detail

      • MemoryStateStore

        public MemoryStateStore()
    • Method Detail

      • create

        public static MemoryStateStore create()
        Initialize an in-memory state store.
        Returns:
        the state store.
      • start

        public boolean start()
        Start a background thread to perform a commit every maxUploadInterval. The default upload interval is every 20 seconds. If the background thread has already been started (for example by an earlier call to start() then this method does nothing and returns false.
        Specified by:
        start in interface StateStore
        Overrides:
        start in class AbstractStateStore
        Returns:
        true if the upload thread started successfully, false if the background thread has already been started.
      • stop

        public boolean stop()
        Stops the background thread if it is running and ensures the upload queue is empty by calling upload() one last time after shutting down the thread.
        Specified by:
        stop in interface StateStore
        Overrides:
        stop in class AbstractStateStore
        Returns:
        true if the upload thread stopped successfully, false if the upload thread was not started in the first place.