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%2FShardSnapshotCohort.java;h=d3d840923bd5bac4d7b599f05c7a3629a2fc5344;hb=3ebd44f9b7a4a217222036c2889d2a04b4f1eb30;hp=7cdd7c6b98681cdc56f06f91552e6d0b191b9a8e;hpb=4062f5241a2a6f58ffb83dd1e9939ee66122d217;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java index 7cdd7c6b98..d3d840923b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java @@ -10,6 +10,12 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import com.google.common.base.Preconditions; import java.util.concurrent.ExecutionException; +import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; +import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; +import org.opendaylight.controller.cluster.access.concepts.FrontendType; +import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; +import org.opendaylight.controller.cluster.access.concepts.MemberName; +import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot; import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort; @@ -23,19 +29,30 @@ import org.slf4j.Logger; * @author Thomas Pantelis */ class ShardSnapshotCohort implements RaftActorSnapshotCohort { + private static final FrontendType SNAPSHOT_APPLY = FrontendType.forName("snapshot-apply"); + private static final FrontendType SNAPSHOT_READ = FrontendType.forName("snapshot-read"); + private final ShardTransactionActorFactory transactionActorFactory; + private final LocalHistoryIdentifier applyHistoryId; + private final LocalHistoryIdentifier readHistoryId; private final ShardDataTree store; private final String logId; private final Logger log; - private int createSnapshotTransactionCounter; + private long applyCounter; + private long readCounter; - ShardSnapshotCohort(ShardTransactionActorFactory transactionActorFactory, ShardDataTree store, + ShardSnapshotCohort(MemberName memberName, ShardTransactionActorFactory transactionActorFactory, ShardDataTree store, Logger log, String logId) { - this.transactionActorFactory = transactionActorFactory; + this.transactionActorFactory = Preconditions.checkNotNull(transactionActorFactory); this.store = Preconditions.checkNotNull(store); this.log = log; this.logId = logId; + + this.applyHistoryId = new LocalHistoryIdentifier(ClientIdentifier.create( + FrontendIdentifier.create(memberName, SNAPSHOT_APPLY), 0), 0); + this.readHistoryId = new LocalHistoryIdentifier(ClientIdentifier.create( + FrontendIdentifier.create(memberName, SNAPSHOT_READ), 0), 0); } @Override @@ -45,7 +62,7 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { // after processing the CreateSnapshot message. ActorRef createSnapshotTransaction = transactionActorFactory.newShardTransaction( - TransactionType.READ_ONLY, "createSnapshot" + ++createSnapshotTransactionCounter, ""); + TransactionType.READ_ONLY, new TransactionIdentifier(readHistoryId, readCounter++)); createSnapshotTransaction.tell(CreateSnapshot.INSTANCE, actorRef); } @@ -59,7 +76,8 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { log.info("{}: Applying snapshot", logId); try { - ReadWriteShardDataTreeTransaction transaction = store.newReadWriteTransaction("snapshot-" + logId, null); + ReadWriteShardDataTreeTransaction transaction = store.newReadWriteTransaction( + new TransactionIdentifier(applyHistoryId, applyCounter++)); NormalizedNode node = SerializationUtils.deserializeNormalizedNode(snapshotBytes);