Class MemoryStateStore

java.lang.Object
com.cognite.client.statestore.AbstractStateStore
com.cognite.client.statestore.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 Details

    • MemoryStateStore

      public MemoryStateStore()
  • Method Details

    • create

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

      public void load() throws Exception
      Load the states from the persistent store.
      Specified by:
      load in interface StateStore
      Specified by:
      load in class AbstractStateStore
      Throws:
      Exception
    • commit

      public void commit() throws Exception
      Commit the current states to the persistent store. Will overwrite/replace previously persisted states.
      Specified by:
      commit in interface StateStore
      Specified by:
      commit in class AbstractStateStore
      Throws:
      Exception
    • 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.