X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionContextFactory.java;h=8c4f6b3456c63a8db9697cf1c9a277dbae9eb01b;hp=49f2ea85ff3221c4357b9ef20344bffa9a27f6ec;hb=c796596b5c46b5203c30b143e6282662e66c5642;hpb=d3a97264ecf47e8c60ea11a7caebce41b580e91d 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 49f2ea85ff..8c4f6b3456 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,7 +9,10 @@ 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; @@ -21,31 +24,23 @@ 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 ActorContext actorContext, final ClientIdentifier clientId) { + super(actorContext, new LocalHistoryIdentifier(clientId, 0)); } @Override public void close() { } - @Override - protected TransactionIdentifier nextIdentifier() { - return TransactionIdentifier.create(getMemberName(), TX_COUNTER.getAndIncrement(), null); - } - @Override protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader, final DataTree dataTree) { return new LocalTransactionFactoryImpl(getActorContext(), shardLeader, dataTree); } @Override - protected Future findPrimaryShard(final String shardName) { + protected Future findPrimaryShard(final String shardName, TransactionIdentifier txId) { return getActorContext().findPrimaryShardAsync(shardName); } @@ -55,6 +50,11 @@ final class TransactionContextFactory extends AbstractTransactionContextFactory< } DOMStoreTransactionChain createTransactionChain() { - return new TransactionChainProxy(this); + return new TransactionChainProxy(this, new LocalHistoryIdentifier(getHistoryId().getClientId(), + nextHistory.getAndIncrement())); + } + + @Override + protected void onTransactionContextCreated(final TransactionIdentifier transactionId) { } }