X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2Factors%2Fdds%2FAbstractClientHistory.java;h=44292307969a27ba26b893440c5e73d71c9787d1;hb=abaef4a5ae37f27542155457fe7306a4662b1eeb;hp=f2e72f18ec25044c62bc6e018243e9f871f1bb44;hpb=e46f5ca6e44904d9dd0b69fb8a36ebf69a293496;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHistory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHistory.java index f2e72f18ec..4429230796 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHistory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHistory.java @@ -7,15 +7,19 @@ */ package org.opendaylight.controller.cluster.databroker.actors.dds; -import com.google.common.base.Preconditions; -import com.google.common.base.Verify; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Verify.verifyNotNull; +import static java.util.Objects.requireNonNull; + +import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLongFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.concurrent.locks.StampedLock; -import javax.annotation.concurrent.GuardedBy; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.opendaylight.controller.cluster.access.client.AbstractClientConnection; import org.opendaylight.controller.cluster.access.client.ConnectedClientConnection; import org.opendaylight.controller.cluster.access.client.ConnectionEntry; @@ -24,7 +28,7 @@ import org.opendaylight.controller.cluster.access.commands.CreateLocalHistoryReq import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; import org.opendaylight.controller.cluster.access.concepts.Response; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.mdsal.common.api.TransactionChainClosedException; +import org.opendaylight.mdsal.dom.api.DOMTransactionChainClosedException; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.slf4j.Logger; @@ -68,9 +72,9 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id private volatile State state = State.IDLE; AbstractClientHistory(final AbstractDataStoreClientBehavior client, final LocalHistoryIdentifier identifier) { - this.client = Preconditions.checkNotNull(client); - this.identifier = Preconditions.checkNotNull(identifier); - Preconditions.checkArgument(identifier.getCookie() == 0); + this.client = requireNonNull(client); + this.identifier = requireNonNull(identifier); + checkArgument(identifier.getCookie() == 0); } final State state() { @@ -79,14 +83,14 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id final void updateState(final State expected, final State next) { final boolean success = STATE_UPDATER.compareAndSet(this, expected, next); - Preconditions.checkState(success, "Race condition detected, state changed from %s to %s", expected, state); + checkState(success, "Race condition detected, state changed from %s to %s", expected, state); LOG.debug("Client history {} changed state from {} to {}", this, expected, next); } final synchronized void doClose() { final State local = state; if (local != State.CLOSED) { - Preconditions.checkState(local == State.IDLE, "Local history %s has an open transaction", this); + checkState(local == State.IDLE, "Local history %s has an open transaction", this); histories.values().forEach(ProxyHistory::close); updateState(local, State.CLOSED); } @@ -184,7 +188,7 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id private void checkNotClosed() { if (state == State.CLOSED) { - throw new TransactionChainClosedException(String.format("Local history %s is closed", identifier)); + throw new DOMTransactionChainClosedException(String.format("Local history %s is closed", identifier)); } } @@ -192,7 +196,7 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id * Allocate a new {@link ClientTransaction}. * * @return A new {@link ClientTransaction} - * @throws TransactionChainClosedException if this history is closed + * @throws DOMTransactionChainClosedException if this history is closed * @throws IllegalStateException if a previous dependent transaction has not been closed */ public ClientTransaction createTransaction() { @@ -209,7 +213,7 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id * Create a new {@link ClientSnapshot}. * * @return A new {@link ClientSnapshot} - * @throws TransactionChainClosedException if this history is closed + * @throws DOMTransactionChainClosedException if this history is closed * @throws IllegalStateException if a previous dependent transaction has not been closed */ public ClientSnapshot takeSnapshot() { @@ -242,8 +246,7 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id } final AbstractTransactionCommitCohort previous = readyTransactions.putIfAbsent(txId, cohort); - Preconditions.checkState(previous == null, "Duplicate cohort %s for transaction %s, already have %s", - cohort, txId, previous); + checkState(previous == null, "Duplicate cohort %s for transaction %s, already have %s", cohort, txId, previous); LOG.debug("Local history {} readied transaction {}", this, txId); return cohort; @@ -298,7 +301,7 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id return null; } - final ProxyReconnectCohort proxy = Verify.verifyNotNull(oldProxy.startReconnect(newConn)); + final ProxyReconnectCohort proxy = verifyNotNull(oldProxy.startReconnect(newConn)); return new HistoryReconnectCohort() { @Override ProxyReconnectCohort getProxy() { @@ -306,8 +309,8 @@ public abstract class AbstractClientHistory extends LocalAbortable implements Id } @Override - void replaySuccessfulRequests(final Iterable previousEntries) { - proxy.replaySuccessfulRequests(previousEntries); + void replayRequests(final Collection previousEntries) { + proxy.replayRequests(previousEntries); } @Override