X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2Fspi%2Fdata%2FAbstractSnapshotBackedTransactionChain.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2Fspi%2Fdata%2FAbstractSnapshotBackedTransactionChain.java;h=f80c80001f6bfd33abd95e2d3abaa58770a234d7;hb=356ac60051791b56cd28390356906810c0db6024;hp=383a0e5a46d56bdace7094c9135a6d3b62c318d4;hpb=7c1be1d20084ee053747d517d597f1a07df694bd;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java index 383a0e5a46..f80c80001f 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractSnapshotBackedTransactionChain.java @@ -19,14 +19,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot} supplier - * and backend commit coordinator. + * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot} + * supplier and backend commit coordinator. * * @param transaction identifier type */ @Beta -public abstract class AbstractSnapshotBackedTransactionChain extends TransactionReadyPrototype implements DOMStoreTransactionChain { - private static abstract class State { +public abstract class AbstractSnapshotBackedTransactionChain extends TransactionReadyPrototype + implements DOMStoreTransactionChain { + private abstract static class State { /** * Allocate a new snapshot. * @@ -68,14 +69,16 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact @Override protected DataTreeSnapshot getSnapshot(Object transactionId) { final DataTreeSnapshot ret = snapshot; - Preconditions.checkState(ret != null, "Could not get snapshot for transaction %s - previous transaction %s is not ready yet", + Preconditions.checkState(ret != null, + "Could not get snapshot for transaction %s - previous transaction %s is not ready yet", transactionId, transaction.getIdentifier()); return ret; } void setSnapshot(final DataTreeSnapshot snapshot) { final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot); - Preconditions.checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier()); + Preconditions.checkState(success, "Transaction %s has already been marked as ready", + transaction.getIdentifier()); } } @@ -115,8 +118,8 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact } private boolean recordTransaction(final State expected, final DOMStoreWriteTransaction transaction) { - final State state = new Allocated(transaction); - return STATE_UPDATER.compareAndSet(this, expected, state); + final State localState = new Allocated(transaction); + return STATE_UPDATER.compareAndSet(this, expected, localState); } @Override @@ -172,7 +175,8 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact 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", + LOG.warn( + "Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange", tx, this, localState, state); } } @@ -190,7 +194,8 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact 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); + 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); @@ -239,7 +244,8 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact } if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) { - LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", this, localState, state); + LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", + this, localState, state); } } @@ -249,7 +255,8 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact * @param transaction Transaction which failed. * @param cause Failure cause */ - protected final void onTransactionFailed(final SnapshotBackedWriteTransaction transaction, final Throwable cause) { + protected final void onTransactionFailed(final SnapshotBackedWriteTransaction transaction, + final Throwable cause) { LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause); state = FAILED; } @@ -283,7 +290,7 @@ public abstract class AbstractSnapshotBackedTransactionChain extends Transact * @param operationError Any previous error that could be reported through three phase commit * @return A {@link DOMStoreThreePhaseCommitCohort} cohort. */ - protected abstract DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction transaction, - final DataTreeModification modification, - final Exception operationError); + protected abstract DOMStoreThreePhaseCommitCohort createCohort(SnapshotBackedWriteTransaction transaction, + DataTreeModification modification, + Exception operationError); }