BUG-5280: Close client history after all histories are closed
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / SingleClientHistory.java
index 6fa3cdf2a9088c4c19288c6a0f075b7e3f18418e..7c3bba9756043c0b4bad67ede6f272cb1c813111 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
-import java.util.Optional;
+import org.opendaylight.controller.cluster.access.client.AbstractClientConnection;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.slf4j.Logger;
@@ -21,10 +21,18 @@ import org.slf4j.LoggerFactory;
 final class SingleClientHistory extends AbstractClientHistory {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractClientHistory.class);
 
-    SingleClientHistory(final DistributedDataStoreClientBehavior client, final LocalHistoryIdentifier identifier) {
+    SingleClientHistory(final AbstractDataStoreClientBehavior client, final LocalHistoryIdentifier identifier) {
         super(client, identifier);
     }
 
+    @Override
+    ClientSnapshot doCreateSnapshot() {
+        final TransactionIdentifier txId = new TransactionIdentifier(getIdentifier(), nextTx());
+        LOG.debug("{}: creating a new snapshot {}", this, txId);
+
+        return new ClientSnapshot(this, txId);
+    }
+
     @Override
     ClientTransaction doCreateTransaction() {
         final TransactionIdentifier txId = new TransactionIdentifier(getIdentifier(), nextTx());
@@ -34,8 +42,8 @@ final class SingleClientHistory extends AbstractClientHistory {
     }
 
     @Override
-    AbstractProxyHistory createHistoryProxy(final LocalHistoryIdentifier historyId,
-            final Optional<ShardBackendInfo> backendInfo) {
-        return AbstractProxyHistory.createSingle(getClient(), backendInfo, historyId);
+    ProxyHistory createHistoryProxy(final LocalHistoryIdentifier historyId,
+            final AbstractClientConnection<ShardBackendInfo> connection) {
+        return ProxyHistory.createSingle(this, connection, historyId);
     }
 }