Package com.cognite.client.statestore
Class LocalStateStore
java.lang.Object
com.cognite.client.statestore.AbstractStateStore
com.cognite.client.statestore.LocalStateStore
- All Implemented Interfaces:
StateStore,Closeable,AutoCloseable
A state store using a local file to persist state entries.
Abstract parent class for all state store implementations.
-
Field Summary
Fields inherited from class com.cognite.client.statestore.AbstractStateStore
COLUMN_KEY_HIGH, COLUMN_KEY_LOW, DEFAULT_MAX_COMMIT_INTERVAL, deletedEntries, executor, LOG, MAX_MAX_COMMIT_INTERVAL, MIN_MAX_COMMIT_INTERVAL, modifiedEntries, recurringTask, stateMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommit()Commit the current states to the persistent store.voidload()Load the states from the persistent store.static LocalStateStoreInitialize a local state store based on the provided file name.static LocalStateStoreInitialize a local state store based on the providedPath.withMaxCommitInterval(Duration interval) Sets the max commit interval.Methods inherited from class com.cognite.client.statestore.AbstractStateStore
close, deleteState, expandHigh, expandLow, getHigh, getLow, getState, isOutsideState, keySet, setHigh, setLow, start, stop, verifyStateMap
-
Constructor Details
-
LocalStateStore
public LocalStateStore()
-
-
Method Details
-
of
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
Initialize a local state store based on the providedPath.- Parameters:
fileName- thePathof the state file.- Returns:
- the state store.
- Throws:
InvalidPathException- if the providedPathname cannot be resolved to a valid file.
-
withMaxCommitInterval
Sets the max commit interval. When you activate the commit background thread viaAbstractStateStore.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
LocalStateStorewith the upload interval configured.
-
load
Load the states from the persistent store.- Specified by:
loadin interfaceStateStore- Specified by:
loadin classAbstractStateStore- Throws:
Exception
-
commit
Commit the current states to the persistent store. Will overwrite/replace previously persisted states.- Specified by:
commitin interfaceStateStore- Specified by:
commitin classAbstractStateStore- Throws:
Exception
-