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%2FShardSnapshotCohort.java;h=7cdd7c6b98681cdc56f06f91552e6d0b191b9a8e;hp=600509a26b87b480156f4baf843f2b887ed4f655;hb=4062f5241a2a6f58ffb83dd1e9939ee66122d217;hpb=3d460a8bcbc24eeb969319feb9c7bf16bff496c1 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 600509a26b..7cdd7c6b98 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 @@ -7,10 +7,9 @@ */ package org.opendaylight.controller.cluster.datastore; -import com.google.common.base.Preconditions; import akka.actor.ActorRef; +import com.google.common.base.Preconditions; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.cluster.datastore.identifiers.ShardTransactionIdentifier; import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot; import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils; import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort; @@ -24,14 +23,12 @@ import org.slf4j.Logger; * @author Thomas Pantelis */ class ShardSnapshotCohort implements RaftActorSnapshotCohort { - - private static final YangInstanceIdentifier DATASTORE_ROOT = YangInstanceIdentifier.builder().build(); - - private int createSnapshotTransactionCounter; private final ShardTransactionActorFactory transactionActorFactory; private final ShardDataTree store; - private final Logger log; private final String logId; + private final Logger log; + + private int createSnapshotTransactionCounter; ShardSnapshotCohort(ShardTransactionActorFactory transactionActorFactory, ShardDataTree store, Logger log, String logId) { @@ -47,11 +44,8 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { // so that this actor does not get block building the snapshot. THe transaction actor will // after processing the CreateSnapshot message. - ShardTransactionIdentifier transactionID = new ShardTransactionIdentifier( - "createSnapshot" + ++createSnapshotTransactionCounter); - ActorRef createSnapshotTransaction = transactionActorFactory.newShardTransaction( - TransactionProxy.TransactionType.READ_ONLY, transactionID, "", DataStoreVersions.CURRENT_VERSION); + TransactionType.READ_ONLY, "createSnapshot" + ++createSnapshotTransactionCounter, ""); createSnapshotTransaction.tell(CreateSnapshot.INSTANCE, actorRef); } @@ -70,10 +64,10 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort { NormalizedNode node = SerializationUtils.deserializeNormalizedNode(snapshotBytes); // delete everything first - transaction.getSnapshot().delete(DATASTORE_ROOT); + transaction.getSnapshot().delete(YangInstanceIdentifier.EMPTY); // Add everything from the remote node back - transaction.getSnapshot().write(DATASTORE_ROOT, node); + transaction.getSnapshot().write(YangInstanceIdentifier.EMPTY, node); syncCommitTransaction(transaction); } catch (InterruptedException | ExecutionException e) { log.error("{}: An exception occurred when applying snapshot", logId, e);