}
}
- @Override
- void purge(final Runnable callback) {
- openTransaction.purge(callback);
- }
-
private void handleTransactionPreCommit(final TransactionPreCommitRequest request,
final RequestEnvelope envelope, final long now) throws RequestException {
readyCohort.preCommit(new FutureCallback<DataTreeCandidate>() {
private void successfulDirectPreCommit(final RequestEnvelope envelope, final long startTime) {
readyCohort.commit(new FutureCallback<UnsignedLong>() {
-
@Override
public void onSuccess(final UnsignedLong result) {
successfulCommit(envelope, startTime);
private void handleCommitLocalTransaction(final CommitLocalTransactionRequest request,
final RequestEnvelope envelope, final long now) throws RequestException {
- if (sealedModification.equals(request.getModification())) {
+ if (!sealedModification.equals(request.getModification())) {
+ LOG.warn("Expecting modification {}, commit request has {}", sealedModification, request.getModification());
+ throw new UnsupportedRequestException(request);
+ }
+
+ final java.util.Optional<Exception> optFailure = request.getDelayedFailure();
+ if (optFailure.isPresent()) {
+ readyCohort = history().createFailedCohort(getIdentifier(), sealedModification, optFailure.get());
+ } else {
readyCohort = history().createReadyCohort(getIdentifier(), sealedModification);
+ }
- if (request.isCoordinated()) {
- coordinatedCommit(envelope, now);
- } else {
- directCommit(envelope, now);
- }
+ if (request.isCoordinated()) {
+ coordinatedCommit(envelope, now);
} else {
- throw new UnsupportedRequestException(request);
+ directCommit(envelope, now);
}
}