BUG-5280: move transactions keeping to history
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / SingleClientHistory.java
index b57e9b669ea6770622dd2f5709b2ad4b5cf44782..6fa3cdf2a9088c4c19288c6a0f075b7e3f18418e 100644 (file)
@@ -7,7 +7,11 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An {@link AbstractClientHistory} which handles free-standing transactions.
@@ -15,8 +19,23 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
  * @author Robert Varga
  */
 final class SingleClientHistory extends AbstractClientHistory {
-    protected SingleClientHistory(final DistributedDataStoreClientBehavior client,
-            final LocalHistoryIdentifier identifier) {
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractClientHistory.class);
+
+    SingleClientHistory(final DistributedDataStoreClientBehavior client, final LocalHistoryIdentifier identifier) {
         super(client, identifier);
     }
+
+    @Override
+    ClientTransaction doCreateTransaction() {
+        final TransactionIdentifier txId = new TransactionIdentifier(getIdentifier(), nextTx());
+        LOG.debug("{}: creating a new transaction {}", this, txId);
+
+        return new ClientTransaction(this, txId);
+    }
+
+    @Override
+    AbstractProxyHistory createHistoryProxy(final LocalHistoryIdentifier historyId,
+            final Optional<ShardBackendInfo> backendInfo) {
+        return AbstractProxyHistory.createSingle(getClient(), backendInfo, historyId);
+    }
 }