@Override protected void transactionAborted(final SnapshotBackedWriteTransaction<String> tx) { LOG.debug("Tx: {} is closed.", tx.getIdentifier()); }
/** * Creates a new write-only transaction. * * @param identifier transaction Identifier * @param debug Enable transaction debugging * @param snapshot Snapshot which will be modified. * @param readyImpl Implementation of ready method. */ public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) { return new SnapshotBackedWriteTransaction<T>(identifier, debug, snapshot, readyImpl); } }
@Override @SuppressWarnings("checkstyle:IllegalCatch") public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data); try { tree.merge(path, data); // FIXME: Add checked exception } catch (RuntimeException e) { LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal input data.", e); } }
private void checkNotReady() { checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.", getIdentifier()); }
@Override @SuppressWarnings("checkstyle:IllegalCatch") public void delete(final YangInstanceIdentifier path) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Delete: {}", getIdentifier(), path); try { tree.delete(path); // FIXME: Add checked exception } catch (RuntimeException e) { LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal path to delete.", e); } }
/** * Creates a new write-only transaction. * * @param identifier transaction Identifier * @param debug Enable transaction debugging * @param snapshot Snapshot which will be modified. * @param readyImpl Implementation of ready method. */ public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) { return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl); } }
private final void checkNotReady() { checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.", getIdentifier()); }
@Override public void delete(final YangInstanceIdentifier path) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Delete: {}", getIdentifier(), path); try { tree.delete(path); // FIXME: Add checked exception } catch (Exception e) { LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal path to delete.", e); } }
protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) { Entry<State, DataTreeSnapshot> entry; DOMStoreWriteTransaction ret; do { entry = getSnapshot(transactionId); ret = new SnapshotBackedWriteTransaction<T>(transactionId, getDebugTransactions(), entry.getValue(), this); } while (!recordTransaction(entry.getKey(), ret)); return ret; }
@Override public void onComplete(final Throwable failure, final ActorSelection success) throws Throwable { if (failure != null) { LOG.info("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); transactionAborted(transaction); return; } LOG.debug("Transaction {} resolved to actor {}", transaction.getIdentifier(), success); } }, actorContext.getClientDispatcher());
@Override public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data); try { tree.write(path, data); // FIXME: Add checked exception } catch (Exception e) { LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal input data.", e); } }
protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) { Entry<State, DataTreeSnapshot> entry; DOMStoreWriteTransaction ret; do { entry = getSnapshot(transactionId); ret = new SnapshotBackedWriteTransaction<>(transactionId, getDebugTransactions(), entry.getValue(), this); } while (!recordTransaction(entry.getKey(), ret)); return ret; }
@Override protected DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction<String> tx, final DataTreeModification modification) { LOG.debug("Tx: {} is submitted. Modifications: {}", tx.getIdentifier(), modification); return new InMemoryDOMStoreThreePhaseCommitCohort(this, tx, modification); }
@Override public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data); try { tree.merge(path, data); // FIXME: Add checked exception } catch (Exception e) { LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal input data.", e); } }
@Override public void close() { @SuppressWarnings("unchecked") final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null); if (wasReady != null) { LOG.debug("Store transaction: {} : Closed", getIdentifier()); TREE_UPDATER.lazySet(this, null); wasReady.transactionAborted(this); } else { LOG.debug("Store transaction: {} : Closed after submit", getIdentifier()); } }
@Override @SuppressWarnings("checkstyle:IllegalCatch") public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) { checkNotReady(); final DataTreeModification tree = mutableTree; LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data); try { tree.write(path, data); // FIXME: Add checked exception } catch (RuntimeException e) { LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e); // Rethrow original ones if they are subclasses of RuntimeException // or Error Throwables.propagateIfPossible(e); // FIXME: Introduce proper checked exception throw new IllegalArgumentException("Illegal input data.", e); } }
@Override public void close() { @SuppressWarnings("unchecked") final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null); if (wasReady != null) { LOG.debug("Store transaction: {} : Closed", getIdentifier()); TREE_UPDATER.lazySet(this, null); wasReady.transactionAborted(this); } else { LOG.debug("Store transaction: {} : Closed after submit", getIdentifier()); } }
@Override public void onComplete(final Throwable failure, final Object message) throws Throwable { if (failure != null) { LOG.error("Failed to prepare transaction {} on backend", transaction.getIdentifier(), failure); transactionAborted(transaction); } else if (CommitTransactionReply.isSerializedType(message)) { LOG.debug("Transaction {} committed successfully", transaction.getIdentifier()); transactionCommitted(transaction); } else { LOG.error("Transaction {} resulted in unhandled message type {}, aborting", message.getClass()); transactionAborted(transaction); } } }, actorContext.getClientDispatcher());
@Override public DOMStoreThreePhaseCommitCohort ready() { @SuppressWarnings("unchecked") final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null); checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier()); LOG.debug("Store transaction: {} : Ready", getIdentifier()); final DataTreeModification tree = mutableTree; TREE_UPDATER.lazySet(this, null); tree.ready(); return wasReady.transactionReady(this, tree); }
@Override @SuppressWarnings("checkstyle:IllegalCatch") public DOMStoreThreePhaseCommitCohort ready() { @SuppressWarnings("unchecked") final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null); checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier()); LOG.debug("Store transaction: {} : Ready", getIdentifier()); final DataTreeModification tree = mutableTree; TREE_UPDATER.lazySet(this, null); try { tree.ready(); return wasReady.transactionReady(this, tree, null); } catch (RuntimeException e) { LOG.debug("Store transaction: {}: unexpected failure when readying", getIdentifier(), e); return wasReady.transactionReady(this, tree, e); } }