- checkSealed();
-
- final SettableFuture<Boolean> ret = SettableFuture.create();
- sendRequest(Verify.verifyNotNull(commitRequest(false)), t -> {
- if (t instanceof TransactionCommitSuccess) {
- ret.set(Boolean.TRUE);
- } else if (t instanceof RequestFailure) {
- ret.setException(((RequestFailure<?, ?>) t).getCause());
- } else {
- ret.setException(new IllegalStateException("Unhandled response " + t.getClass()));
+ final CountDownLatch localLatch;
+
+ synchronized (this) {
+ final SealState local = checkSealed();
+
+ // Fast path: no successor asserted
+ if (successor == null) {
+ Verify.verify(local == SealState.SEALED);
+
+ final SettableFuture<Boolean> ret = SettableFuture.create();
+ sendRequest(Verify.verifyNotNull(commitRequest(false)), t -> {
+ if (t instanceof TransactionCommitSuccess) {
+ ret.set(Boolean.TRUE);
+ } else if (t instanceof RequestFailure) {
+ ret.setException(((RequestFailure<?, ?>) t).getCause());
+ } else {
+ ret.setException(new IllegalStateException("Unhandled response " + t.getClass()));
+ }
+
+ // This is a terminal request, hence we do not need to record it
+ LOG.debug("Transaction {} directCommit completed", this);
+ parent.completeTransaction(this);
+ });
+
+ sealed = SealState.FLUSHED;
+ return ret;