- public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
- checkRunning(commitImpl);
- getSubtransaction(store).delete(path);
- }
-
- @Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
- checkRunning(commitImpl);
- getSubtransaction(store).merge(path, data);
- }
-
- @Override
- public boolean cancel() {
- final AbstractDOMTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- if (impl != null) {
- LOG.trace("Transaction {} cancelled before submit", getIdentifier());
- FUTURE_UPDATER.lazySet(this, CANCELLED_FUTURE);
- closeSubtransactions();
- return true;
- }
-
- // The transaction is in process of being submitted or cancelled. Busy-wait
- // for the corresponding future.
- Future<?> future;
- do {
- future = commitFuture;
- } while (future == null);
-
- return future.cancel(false);
- }
-
- @Deprecated
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> commit() {
- return AbstractDataTransaction.convertToLegacyCommitFuture(submit());
- }
-
- @Override
- public CheckedFuture<Void, TransactionCommitFailedException> submit() {
- final AbstractDOMTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
- checkRunning(impl);
-
- final Collection<T> txns = getSubtransactions();
- final Collection<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(txns.size());
-
- // FIXME: deal with errors thrown by backed (ready and submit can fail in theory)
- for (DOMStoreWriteTransaction txn : txns) {
- cohorts.add(txn.ready());
- }
-
- final CheckedFuture<Void, TransactionCommitFailedException> ret = impl.submit(this, cohorts);
- FUTURE_UPDATER.lazySet(this, ret);
- return ret;
- }
-
- private void checkRunning(final AbstractDOMTransactionFactory<?> impl) {
- Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());