@Override public synchronized void close() throws Exception { for (DOMDataReadWriteTransaction rwt : allOpenReadWriteTransactions) { rwt.cancel(); } allOpenReadWriteTransactions.clear(); }
@Override public synchronized void close() throws Exception { for (DOMDataReadWriteTransaction rwt : allOpenReadWriteTransactions) { rwt.cancel(); } allOpenReadWriteTransactions.clear(); }
public synchronized void abortRunningTransaction(DOMDataReadWriteTransaction tx) { LOG.debug("Aborting current running Transaction"); Preconditions.checkState(runningTransaction != null, NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting); tx.cancel(); allOpenReadWriteTransactions.remove(tx); }
public synchronized void abortRunningTransaction(DOMDataReadWriteTransaction tx) { LOG.debug("Aborting current running Transaction"); Preconditions.checkState(runningTransaction != null, NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting); tx.cancel(); allOpenReadWriteTransactions.remove(tx); }
@Override public boolean cancel() { return delegate().cancel(); }
public synchronized void abortTransaction() { LOG.debug("Aborting current candidateTransaction"); Optional<DOMDataReadWriteTransaction> otx = getCandidateTransaction(); if (!otx.isPresent()) { LOG.warn("discard-changes triggerd on an empty transaction for session: {}", netconfSessionIdForReporting ); return; } candidateTransaction.cancel(); allOpenReadWriteTransactions.remove(candidateTransaction); candidateTransaction = null; }
@Override public boolean cancel() { if (AuthzServiceImpl.isAuthorized(ActionType.Cancel)) { return domDataReadWriteTransaction.cancel(); } return false; }
public synchronized void abortTransaction() { LOG.debug("Aborting current candidateTransaction"); Optional<DOMDataReadWriteTransaction> otx = getCandidateTransaction(); if (!otx.isPresent()) { LOG.warn("discard-changes triggerd on an empty transaction for session: {}", netconfSessionIdForReporting ); return; } candidateTransaction.cancel(); allOpenReadWriteTransactions.remove(candidateTransaction); candidateTransaction = null; }
@Override public boolean cancel() { return delegate().cancel(); }
@Override public boolean cancel() { return delegate().cancel(); }
private synchronized PingPongTransaction slowAllocateTransaction() { Preconditions.checkState(shutdownTx == null, "Transaction chain %s has been shut down", this); if (deadTx != null) { throw new IllegalStateException(String.format( "Transaction chain %s has failed due to transaction %s being canceled", this, deadTx.getKey()), deadTx.getValue()); } final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction(); final PingPongTransaction newTx = new PingPongTransaction(delegateTx); if (!LOCKED_UPDATER.compareAndSet(this, null, newTx)) { delegateTx.cancel(); throw new IllegalStateException(String.format("New transaction %s raced with transacion %s", newTx, lockedTx)); } return newTx; }
private void checkItemDoesNotExists(final DOMDataReadWriteTransaction rWTransaction,final LogicalDatastoreType store, final YangInstanceIdentifier path) { final ListenableFuture<Boolean> futureDatastoreData = rWTransaction.exists(store, path); try { if (futureDatastoreData.get()) { final String errMsg = "Post Configuration via Restconf was not executed because data already exists"; LOG.trace(errMsg + ":{}", path); rWTransaction.cancel(); throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS); } } catch (InterruptedException | ExecutionException e) { LOG.warn("It wasn't possible to get data loaded from datastore at path " + path, e); } }
private PingPongTransaction allocateTransaction() { // Step 1: acquire current state final PingPongTransaction oldTx = READY_UPDATER.getAndSet(this, null); // Slow path: allocate a delegate transaction if (oldTx == null) { return slowAllocateTransaction(); } // Fast path: reuse current transaction. We will check failures and similar on submit(). if (!LOCKED_UPDATER.compareAndSet(this, null, oldTx)) { // Ouch. Delegate chain has not detected a duplicate transaction allocation. This is the best we can do. oldTx.getTransaction().cancel(); throw new IllegalStateException(String.format("Reusable transaction %s raced with transaction %s", oldTx, lockedTx)); } return oldTx; }
/** * Process a ready transaction. The caller needs to ensure that * each transaction is seen only once by this method. * * @param tx Transaction which needs processing. */ @GuardedBy("this") private void processTransaction(@Nonnull final PingPongTransaction tx) { if (failed) { LOG.debug("Cancelling transaction {}", tx); tx.getTransaction().cancel(); return; } LOG.debug("Submitting transaction {}", tx); if (!INFLIGHT_UPDATER.compareAndSet(this, null, tx)) { LOG.warn("Submitting transaction {} while {} is still running", tx, inflightTx); } Futures.addCallback(tx.getTransaction().submit(), new FutureCallback<Void>() { @Override public void onSuccess(final Void result) { transactionSuccessful(tx, result); } @Override public void onFailure(final Throwable t) { transactionFailed(tx, t); } }); }
final boolean backendCancelled = tx.getTransaction().cancel();
private CheckedFuture<Void, TransactionCommitFailedException> putDataViaTransaction( final DOMDataBroker domDataBroker, final LogicalDatastoreType datastore, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext) { DOMDataReadWriteTransaction transaction = domDataBroker.newReadWriteTransaction(); LOG.trace("Put " + datastore.name() + " via Restconf: {} with payload {}", path, payload); if (!ensureParentsByMerge(datastore, path, transaction, schemaContext)) { transaction.cancel(); transaction = domDataBroker.newReadWriteTransaction(); } transaction.put(datastore, path, payload); return transaction.submit(); }
transaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree); } catch (RuntimeException e) { transaction.cancel(); transaction = domDataBroker.newReadWriteTransaction(); LOG.debug("Empty subtree merge failed", e); transaction.cancel(); transaction = domDataBroker.newReadWriteTransaction(); checkItemDoesNotExists(transaction,datastore, path); if(!ensureParentsByMerge(datastore, path, transaction, schemaContext)) { transaction.cancel(); transaction = domDataBroker.newReadWriteTransaction();