/** * Notify the base logic that a previously-submitted transaction has been committed successfully. * * @param transaction Transaction which completed successfully. */ protected final void onTransactionCommited(final SnapshotBackedWriteTransaction<T> transaction) { // If the committed transaction was the one we allocated last, // we clear it and the ready snapshot, so the next transaction // allocated refers to the data tree directly. final State localState = state; if (!(localState instanceof Allocated)) { // This can legally happen if the chain is shut down before the transaction was committed // by the backend. LOG.debug("Ignoring successful transaction {} in state {}", transaction, localState); return; } final Allocated allocated = (Allocated)localState; final DOMStoreWriteTransaction tx = allocated.getTransaction(); if (!tx.equals(transaction)) { LOG.debug("Ignoring non-latest successful transaction {} in state {}", transaction, allocated); return; } if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) { LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", this, localState, state); } }
/** * Notify the base logic that a previously-submitted transaction has been committed successfully. * * @param transaction Transaction which completed successfully. */ protected final void onTransactionCommited(final SnapshotBackedWriteTransaction<T> transaction) { // If the committed transaction was the one we allocated last, // we clear it and the ready snapshot, so the next transaction // allocated refers to the data tree directly. final State localState = state; if (!(localState instanceof Allocated)) { // This can legally happen if the chain is shut down before the transaction was committed // by the backend. LOG.debug("Ignoring successful transaction {} in state {}", transaction, localState); return; } final Allocated allocated = (Allocated)localState; final DOMStoreWriteTransaction tx = allocated.getTransaction(); if (!tx.equals(transaction)) { LOG.debug("Ignoring non-latest successful transaction {} in state {}", transaction, allocated); return; } if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) { LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", this, localState, state); } }
@Override protected final DOMStoreThreePhaseCommitCohort transactionReady( final SnapshotBackedWriteTransaction<T> tx, final DataTreeModification tree, final Exception readyError) { final State localState = state; if (localState instanceof Allocated) { final Allocated allocated = (Allocated)localState; final DOMStoreWriteTransaction transaction = allocated.getTransaction(); Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx, transaction); allocated.setSnapshot(tree); } else { LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState); } return createCohort(tx, tree, readyError); }
@Override protected final DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction<T> tx, final DataTreeModification tree) { final State localState = state; if (localState instanceof Allocated) { final Allocated allocated = (Allocated)localState; final DOMStoreWriteTransaction transaction = allocated.getTransaction(); Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx, transaction); allocated.setSnapshot(tree); } else { LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState); } return createCohort(tx, tree); }
@Override protected final void transactionAborted(final SnapshotBackedWriteTransaction<T> tx) { final State localState = state; if (localState instanceof Allocated) { final Allocated allocated = (Allocated)localState; if (allocated.getTransaction().equals(tx)) { final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState); if (!success) { LOG.warn("Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange", tx, this, localState, state); } } } }
private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) { final State localState = new Allocated(transaction); return STATE_UPDATER.compareAndSet(this, expected, localState); }
@Override protected final void transactionAborted(final SnapshotBackedWriteTransaction<T> tx) { final State localState = state; if (localState instanceof Allocated) { final Allocated allocated = (Allocated)localState; if (allocated.getTransaction().equals(tx)) { final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState); if (!success) { LOG.warn( "Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange", tx, this, localState, state); } } } }
private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) { final State state = new Allocated(transaction); return STATE_UPDATER.compareAndSet(this, expected, state); }