Interface UpdateState

All Known Subinterfaces:
CommitterState<REF_OBJ,RESULT>

public interface UpdateState
  • Method Details

    • persistence

      Persistence persistence()
      Use this instance of Persistence instead for operations related to this state, especially from CommitRetryable.attempt(CommitterState, Supplier).
    • writeIfNew

      <O extends Obj> O writeIfNew(@Nonnull Object key, @Nonnull O obj, @Nonnull Class<O> type)
      Add obj to the list of objects to be persisted, using key to identify/reuse an already persisted object in a retried attempt.

      Prefer this function over writeIntent(Object, Obj) and getWrittenByKey(Object).

      Note that objects will not be immediately persisted, but after the attempt returns, but before the commit returns.

      A failed commit will delete objects passed to this function.

      Parameters:
      key - key identifying obj
      obj - object to persist
      Returns:
      returns the given obj, if key is new, or the previous Obj, if key was already used in a call to this function or writeIntent(Object, Obj).
    • writeIfNew

      default Obj writeIfNew(@Nonnull Object key, @Nonnull Obj obj)
    • writeOrReplace

      <O extends Obj> O writeOrReplace(@Nonnull Object key, @Nonnull O obj, @Nonnull Class<O> type)
      Add obj to the list of objects to be persisted, using key to identify/reuse an already persisted object in a retried attempt.

      If an object was already associated with the same key, the previous object will be eventually deleted.

      Parameters:
      key - key identifying obj
      obj - object to persist
      Returns:
      returns obj
    • writeOrReplace

      default Obj writeOrReplace(@Nonnull Object key, @Nonnull Obj obj)
    • getWrittenByKey

      Obj getWrittenByKey(@Nonnull Object key)
      Get an already present object by a use-case defined key.
      Returns:
      the already present object or null, if no object is associated with the key
    • getWrittenById

      <C extends Obj> C getWrittenById(ObjRef id, Class<C> clazz)
      Get an already present object by its ObjRef.
      Returns:
      the already present object or null, if no object is associated with the id
    • writeIntent

      void writeIntent(@Nonnull Object key, @Nonnull Obj obj)
      Add obj to the list of objects to be persisted, using key to identify/reuse an already persisted object in a retried attempt.

      Note that objects will not be immediately persisted, but after the attempt returns, but before the commit returns.

      A failed commit will delete objects passed to this function.

      Prefer writeIfNew(Object, Obj), if possible.

      Parameters:
      key - key identifying obj, must be unique across all objects. Throws an IllegalStateException, if the key has already been used.
      obj - object to persist