Interface CommitRetryable<REF_OBJ extends BaseCommitObj,RESULT>

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CommitRetryable<REF_OBJ extends BaseCommitObj,RESULT>
  • Method Details

    • attempt

      @Nonnull Optional<REF_OBJ> attempt(@Nonnull CommitterState<REF_OBJ,RESULT> state, @Nonnull Supplier<Optional<REF_OBJ>> refObjSupplier) throws CommitException
      Called from committer implementations.

      Implementations call the refObjSupplier to retrieve the current reference object using the current state of the reference. Long-running attempt implementations that need to have the reference object early should call the supplier again shortly before from this function and attempt to perform the required checks against the latest state of the reference object. This helps in reducing unnecessary retries when the attempt can be safely applied to the latest state of the reference object.

      Writes must be triggered via the various write*() functions on CommitterState, preferable via UpdateState.writeOrReplace(Object, Obj, Class). The String keys are used as symbolic identifiers, implementations are responsible for providing keys that are unique.

      Reads must happen via the specialized Persistence provided by the committer implementation.

      Parameters:
      state - Communicate objects to be persisted via CommitterState
      refObjSupplier - supplier returning the current object, if present. Must be invoked.
      Returns:
      Successful attempts return a non-empty Optional containing the result. An empty optional indicates that a retry should be attempted.
      Throws:
      CommitException - Instances of this class let the whole commit operation abort.