Interface Status.DataUpdater
- Enclosing class:
- Status
DataSynchronizer implementation will use to push data into the SDK.
The DataSynchronizer interacts with this object, rather than manipulating the DataStorage directly,
so that the SDK can perform any other necessary operations that should perform around data updating.
if you overwrite our default DataSynchronizer, you should integrateStatus.DataUpdater to push data
and maintain the processor status in your own code, but note that the implementation of this interface is not public
-
Method Summary
Modifier and TypeMethodDescriptionlongreturn the latest version ofDataStoragebooleaninit(Map<DataStoreTypes.Category, Map<String, DataStoreTypes.Item>> allData, Long version) Overwrites the storage with a set of items for each collection, if the new version > the old onebooleanreturn true if theDataStorageis well initializedvoidupdateStatus(Status.State newState) Informs the SDK of a change in theDataSynchronizerstatus.booleanupsert(DataStoreTypes.Category category, String key, DataStoreTypes.Item item, Long version) Updates or inserts an item in the specified collection.
-
Method Details
-
init
Overwrites the storage with a set of items for each collection, if the new version > the old oneIf the underlying data store throws an error during this operation, the SDK will catch it, log it, and set the data source state to
Status.StateType.INTERRUPTED.It will not rethrow the error to other level but will simply returnfalseto indicate that the operation failed.- Parameters:
allData- map ofDataStoreTypes.Categoryand their data setDataStoreTypes.Itemversion- the version of dataset, Ordinarily it's a timestamp.- Returns:
- true if the update succeeded
-
upsert
boolean upsert(DataStoreTypes.Category category, String key, DataStoreTypes.Item item, Long version) Updates or inserts an item in the specified collection. For updates, the object will only be updated if the existing version is less than the new version; for inserts, if the version > the existing one, it will replace the existing one.If the underlying data store throws an error during this operation, the SDK will catch it, log it, and set the data source state to
Status.StateType.INTERRUPTED.It will not rethrow the error to other level but will simply returnfalseto indicate that the operation failed.- Parameters:
category- specifies which collection to usekey- the unique key of the item in the collectionitem- the item to insert or updateversion- the version of item- Returns:
- true if success
-
updateStatus
Informs the SDK of a change in theDataSynchronizerstatus.DataSynchronizerimplementations should use this method if they have any concept of being in a valid state, a temporarily disconnected state, or a permanently stopped state.If
newStateis different from the previous state, and/ornewErroris non-null, the SDK will start returning the new status (adding a timestamp for the change) fromStatus.DataUpdateStatusProvider.getState().A special case is that if
newStateisStatus.StateType.INTERRUPTED, but the previous state wasStatus.StateType.INITIALIZING, the state will remain atStatus.StateType.INITIALIZINGbecauseStatus.StateType.INTERRUPTEDis only meaningful after a successful startup.- Parameters:
newState- the new state ofDataSynchronizer
-
getVersion
long getVersion()return the latest version ofDataStorage- Returns:
- a long value
-
storageInitialized
boolean storageInitialized()return true if theDataStorageis well initialized- Returns:
- true if the
DataStorageis well initialized
-