Interface Status.DataUpdater

Enclosing class:
Status

public static interface Status.DataUpdater
Interface that 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 Details

    • init

      boolean init(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 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 return false to indicate that the operation failed.

      Parameters:
      allData - map of DataStoreTypes.Category and their data set DataStoreTypes.Item
      version - 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 return false to indicate that the operation failed.

      Parameters:
      category - specifies which collection to use
      key - the unique key of the item in the collection
      item - the item to insert or update
      version - the version of item
      Returns:
      true if success
    • updateStatus

      void updateStatus(Status.State newState)
      Informs the SDK of a change in the DataSynchronizer status.

      DataSynchronizer implementations 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 newState is different from the previous state, and/or newError is non-null, the SDK will start returning the new status (adding a timestamp for the change) from Status.DataUpdateStatusProvider.getState().

      A special case is that if newState is Status.StateType.INTERRUPTED, but the previous state was Status.StateType.INITIALIZING, the state will remain at Status.StateType.INITIALIZING because Status.StateType.INTERRUPTED is only meaningful after a successful startup.

      Parameters:
      newState - the new state of DataSynchronizer
    • getVersion

      long getVersion()
      return the latest version of DataStorage
      Returns:
      a long value
    • storageInitialized

      boolean storageInitialized()
      return true if the DataStorage is well initialized
      Returns:
      true if the DataStorage is well initialized