package org.opendaylight.mdsal.dom.spi;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Verify.verify;
import static java.util.Objects.requireNonNull;
+import com.google.common.base.VerifyException;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
* correctness.
*/
private synchronized void processNextTransaction(final PingPongTransaction tx) {
- final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null);
- checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx);
+ if (!INFLIGHT_UPDATER.compareAndSet(this, tx, null)) {
+ throw new IllegalStateException(String.format("Completed transaction %s while %s was submitted", tx,
+ inflightTx));
+ }
final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null);
if (nextTx == null) {
void readyTransaction(final @NonNull PingPongTransaction tx) {
// First mark the transaction as not locked.
- final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
- checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx);
+ if (!LOCKED_UPDATER.compareAndSet(this, tx, null)) {
+ throw new IllegalStateException(String.format("Attempted to submit transaction %s while we have %s", tx,
+ lockedTx));
+ }
LOG.debug("Transaction {} unlocked", tx);
/*
* The transaction is ready. It will then be picked up by either next allocation,
* or a background transaction completion callback.
*/
- final boolean success = READY_UPDATER.compareAndSet(this, null, tx);
- checkState(success, "Transaction %s collided on ready state", tx, readyTx);
+ if (!READY_UPDATER.compareAndSet(this, null, tx)) {
+ throw new IllegalStateException(String.format("Transaction %s collided on ready state with %s", tx,
+ readyTx));
+ }
LOG.debug("Transaction {} readied", tx);
/*
synchronized void cancelTransaction(final PingPongTransaction tx,
final DOMDataTreeReadWriteTransaction frontendTx) {
// Attempt to unlock the operation.
- final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
- verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx);
+ if (!LOCKED_UPDATER.compareAndSet(this, tx, null)) {
+ throw new VerifyException(String.format("Cancelling transaction %s collided with locked transaction %s", tx,
+ lockedTx));
+ }
// Cancel the backend transaction, so we do not end up leaking it.
final boolean backendCancelled = tx.getTransaction().cancel();