- private final class CommitCohort extends ForwardingDOMStoreThreePhaseCommitCohort {
- private final ReadWriteShardDataTreeTransaction transaction;
- private final DOMStoreThreePhaseCommitCohort delegate;
-
- CommitCohort(final ReadWriteShardDataTreeTransaction transaction, final DOMStoreThreePhaseCommitCohort delegate) {
- this.transaction = Preconditions.checkNotNull(transaction);
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- @Override
- protected DOMStoreThreePhaseCommitCohort delegate() {
- return delegate;
- }
-
- @Override
- public ListenableFuture<Void> commit() {
- final ListenableFuture<Void> ret = super.commit();
-
- Futures.addCallback(ret, new FutureCallback<Void>() {
- @Override
- public void onSuccess(Void result) {
- if (transaction.equals(previousTx)) {
- previousTx = null;
- }
- LOG.debug("Committed transaction {}", transaction);
- }
-
- @Override
- public void onFailure(Throwable t) {
- LOG.error("Transaction {} commit failed, cannot recover", transaction, t);
- }
- });
-
- return ret;
+ void clearTransaction(ReadWriteShardDataTreeTransaction transaction) {
+ if (transaction.equals(previousTx)) {
+ previousTx = null;