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=dae12af731846a278386dcf75f8348e61eb30752;hb=cd801d3b254bf709903b1fd31379967ab8ac1f36;hp=03d2a0377f83050c031202e64b096e39f006e41a;hpb=b66d5a3c59525a1c7885c3d653d9657a99f4103d;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 03d2a0377f..dae12af731 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 @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -abstract class AbstractClientHistory extends LocalAbortable implements Identifiable { +public abstract class AbstractClientHistory extends LocalAbortable implements Identifiable { enum State { IDLE, TX_OPEN, @@ -83,8 +83,22 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia 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); + histories.values().forEach(ProxyHistory::close); + updateState(local, State.CLOSED); + } + } + + final synchronized void onProxyDestroyed(final ProxyHistory proxyHistory) { + histories.remove(proxyHistory.getIdentifier().getCookie()); + LOG.debug("{}: removed destroyed proxy {}", this, proxyHistory); + } + @Override - public final LocalHistoryIdentifier getIdentifier() { + public LocalHistoryIdentifier getIdentifier() { return identifier; } @@ -181,7 +195,7 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia * @throws TransactionChainClosedException if this history is closed * @throws IllegalStateException if a previous dependent transaction has not been closed */ - public final ClientTransaction createTransaction() { + public ClientTransaction createTransaction() { checkNotClosed(); synchronized (this) { @@ -198,7 +212,7 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia * @throws TransactionChainClosedException if this history is closed * @throws IllegalStateException if a previous dependent transaction has not been closed */ - public final ClientSnapshot takeSnapshot() { + public ClientSnapshot takeSnapshot() { checkNotClosed(); synchronized (this) { @@ -292,8 +306,8 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia } @Override - void replaySuccessfulRequests(final Iterable previousEntries) { - proxy.replaySuccessfulRequests(previousEntries); + void replayRequests(final Iterable previousEntries) { + proxy.replayRequests(previousEntries); } @Override @@ -307,4 +321,5 @@ abstract class AbstractClientHistory extends LocalAbortable implements Identifia } }; } + }