Class LocalStateStore

java.lang.Object
com.cognite.client.statestore.AbstractStateStore
com.cognite.client.statestore.LocalStateStore
All Implemented Interfaces:
StateStore, Closeable, AutoCloseable

public abstract class LocalStateStore extends AbstractStateStore
A state store using a local file to persist state entries. Abstract parent class for all state store implementations.
  • Constructor Details

    • LocalStateStore

      public LocalStateStore()
  • Method Details

    • of

      public static LocalStateStore of(String fileName) throws InvalidPathException
      Initialize a local state store based on the provided file name.
      Parameters:
      fileName - the name of the state file.
      Returns:
      the state store.
      Throws:
      InvalidPathException - if the provided file name cannot be resolved to a valid file
    • of

      public static LocalStateStore of(Path fileName) throws InvalidPathException
      Initialize a local state store based on the provided Path.
      Parameters:
      fileName - the Path of the state file.
      Returns:
      the state store.
      Throws:
      InvalidPathException - if the provided Path name cannot be resolved to a valid file.
    • withMaxCommitInterval

      public LocalStateStore withMaxCommitInterval(Duration interval)
      Sets the max commit interval. When you activate the commit background thread via AbstractStateStore.start(), the state will be committed to persistent storage at least every commit interval. The default max commit interval is 20 seconds.
      Parameters:
      interval - The target max upload interval.
      Returns:
      The LocalStateStore with the upload interval configured.
    • 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