From: Robert Varga Date: Thu, 19 May 2016 17:10:17 +0000 (+0200) Subject: BUG-5280: do not use CompositeModification in Shard X-Git-Tag: release/boron~144 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=f508ba6d5a2a16d66b879dae928ec1a4878da729;hp=4893b3cbb09b2644fc2c93ea53dfeac949a7f87c BUG-5280: do not use CompositeModification in Shard The only production implementation of CompositeModification is BatchedModifications. That carries the transaction identifier, which will make it easier to retain proper names. It is also needed for making the transaction IDs type-safe. Change-Id: Icc49e6e13107a079db098a065e85791177db8cf0 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index b76c0fac34..e9f543f0f2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -50,8 +50,6 @@ import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeList import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeChangeListener; import org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged; import org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext; -import org.opendaylight.controller.cluster.datastore.modification.Modification; -import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.utils.Dispatchers; import org.opendaylight.controller.cluster.notifications.LeaderStateChanged; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener; @@ -607,8 +605,9 @@ public class Shard extends RaftActor { transactionId, transactionChainId); } - private void commitWithNewTransaction(final Modification modification) { - ReadWriteShardDataTreeTransaction tx = store.newReadWriteTransaction(modification.toString(), null); + private void commitWithNewTransaction(final BatchedModifications modification) { + ReadWriteShardDataTreeTransaction tx = store.newReadWriteTransaction(modification.getTransactionID(), + modification.getTransactionChainID()); modification.apply(tx.getSnapshot()); try { snapshotCohort.syncCommitTransaction(tx); @@ -693,7 +692,11 @@ public class Shard extends RaftActor { } else if(clientActor == null) { // There's no clientActor to which to send a commit reply so we must be applying // replicated state from the leader. - commitWithNewTransaction(MutableCompositeModification.fromSerializable(modification)); + + // The only implementation we know of is BatchedModifications, which also carries a transaction + // identifier -- which we really need that. + Preconditions.checkArgument(modification instanceof BatchedModifications); + commitWithNewTransaction((BatchedModifications)modification); } else { // This must be the OK to commit after replication consensus. finishCommit(clientActor, identifier);