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%2Fdatastore%2FTransactionContextFactory.java;h=34770245e7fe4884969014d4062c712724bcb676;hb=99f80f27bee37bb23e345420bf14bb7bb4793c28;hp=db8dedcf353c3450e5475dc5cb2c8723dd401f0a;hpb=86a3188d6db1e7da2803a6b36daa2898fe045e45;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java index db8dedcf35..34770245e7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextFactory.java @@ -9,11 +9,14 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorSelection; import java.util.Collection; -import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier; +import java.util.concurrent.atomic.AtomicLong; +import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; +import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; -import org.opendaylight.controller.cluster.datastore.utils.ActorContext; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; +import org.opendaylight.yangtools.yang.data.tree.api.ReadOnlyDataTree; import scala.concurrent.Future; /** @@ -21,13 +24,10 @@ import scala.concurrent.Future; * transactions (ie not chained). */ final class TransactionContextFactory extends AbstractTransactionContextFactory { + private final AtomicLong nextHistory = new AtomicLong(1); - private TransactionContextFactory(final ActorContext actorContext) { - super(actorContext); - } - - static TransactionContextFactory create(final ActorContext actorContext) { - return new TransactionContextFactory(actorContext); + TransactionContextFactory(final ActorUtils actorUtils, final ClientIdentifier clientId) { + super(actorUtils, new LocalHistoryIdentifier(clientId, 0)); } @Override @@ -35,30 +35,28 @@ final class TransactionContextFactory extends AbstractTransactionContextFactory< } @Override - protected TransactionIdentifier nextIdentifier() { - return TransactionIdentifier.create(getMemberName(), TX_COUNTER.getAndIncrement()); - } - - @Override - protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader, final DataTree dataTree) { - return new LocalTransactionFactoryImpl(getActorContext(), shardLeader, dataTree); + protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader, + final ReadOnlyDataTree dataTree) { + return new LocalTransactionFactoryImpl(getActorUtils(), shardLeader, dataTree); } @Override - protected Future findPrimaryShard(final String shardName, TransactionIdentifier txId) { - return getActorContext().findPrimaryShardAsync(shardName); + protected Future findPrimaryShard(final String shardName, final TransactionIdentifier txId) { + return getActorUtils().findPrimaryShardAsync(shardName); } @Override - protected void onTransactionReady(final TransactionIdentifier transaction, final Collection> cohortFutures) { + protected void onTransactionReady(final TransactionIdentifier transaction, + final Collection> cohortFutures) { // Transactions are disconnected, this is a no-op } DOMStoreTransactionChain createTransactionChain() { - return new TransactionChainProxy(this); + return new TransactionChainProxy(this, new LocalHistoryIdentifier(getHistoryId().getClientId(), + nextHistory.getAndIncrement())); } @Override - protected void onTransactionContextCreated(TransactionIdentifier transactionId) { + protected void onTransactionContextCreated(final TransactionIdentifier transactionId) { } }