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.
-
Method Summary
-
Method Details
-
attempt
@Nonnull Optional<REF_OBJ> attempt(@Nonnull CommitterState<REF_OBJ, RESULT> state, @Nonnull Supplier<Optional<REF_OBJ>> refObjSupplier) throws CommitExceptionCalled from committer implementations.Implementations call the
refObjSupplierto 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 onCommitterState, preferable viaUpdateState.writeOrReplace(Object, Obj, Class). TheStringkeys are used as symbolic identifiers, implementations are responsible for providing keys that are unique.Reads must happen via the specialized
Persistenceprovided by the committer implementation.- Parameters:
state- Communicate objects to be persisted viaCommitterStaterefObjSupplier- supplier returning the current object, if present. Must be invoked.- Returns:
- Successful attempts return a non-empty
Optionalcontaining the result. An empty optional indicates that a retry should be attempted. - Throws:
CommitException- Instances of this class let the whole commit operation abort.
-