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%2FShardWriteTransaction.java;h=44f2c7bd0a2794715d09cb29bb7a5ce42b352344;hb=bc9665899219b2218abd8a9bee314cd07f0f84d0;hp=21c210daf252fc4633b12882bb18dfea99779aa5;hpb=531621aac4cff9d39cbd8668a53bdeba8a0e6d81;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java index 21c210daf2..44f2c7bd0a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardWriteTransaction.java @@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; +import akka.actor.PoisonPill; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; import org.opendaylight.controller.cluster.datastore.messages.DeleteData; import org.opendaylight.controller.cluster.datastore.messages.DeleteDataReply; @@ -41,8 +42,9 @@ public class ShardWriteTransaction extends ShardTransaction { private final DOMStoreWriteTransaction transaction; public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor, - SchemaContext schemaContext, ShardStats shardStats, String transactionID) { - super(shardActor, schemaContext, shardStats, transactionID); + SchemaContext schemaContext, ShardStats shardStats, String transactionID, + int txnClientVersion) { + super(shardActor, schemaContext, shardStats, transactionID, txnClientVersion); this.transaction = transaction; } @@ -87,12 +89,12 @@ public class ShardWriteTransaction extends ShardTransaction { } } - private void writeData(DOMStoreWriteTransaction transaction, WriteData message, boolean returnSerialized) { + private void writeData(DOMStoreWriteTransaction transaction, WriteData message, + boolean returnSerialized) { + LOG.debug("writeData at path : {}", message.getPath()); + modification.addModification( new WriteModification(message.getPath(), message.getData(), getSchemaContext())); - if(LOG.isDebugEnabled()) { - LOG.debug("writeData at path : " + message.getPath().toString()); - } try { transaction.write(message.getPath(), message.getData()); WriteDataReply writeDataReply = new WriteDataReply(); @@ -103,12 +105,13 @@ public class ShardWriteTransaction extends ShardTransaction { } } - private void mergeData(DOMStoreWriteTransaction transaction, MergeData message, boolean returnSerialized) { + private void mergeData(DOMStoreWriteTransaction transaction, MergeData message, + boolean returnSerialized) { + LOG.debug("mergeData at path : {}", message.getPath()); + modification.addModification( new MergeModification(message.getPath(), message.getData(), getSchemaContext())); - if(LOG.isDebugEnabled()) { - LOG.debug("mergeData at path : " + message.getPath().toString()); - } + try { transaction.merge(message.getPath(), message.getData()); MergeDataReply mergeDataReply = new MergeDataReply(); @@ -119,10 +122,10 @@ public class ShardWriteTransaction extends ShardTransaction { } } - private void deleteData(DOMStoreWriteTransaction transaction, DeleteData message, boolean returnSerialized) { - if(LOG.isDebugEnabled()) { - LOG.debug("deleteData at path : " + message.getPath().toString()); - } + private void deleteData(DOMStoreWriteTransaction transaction, DeleteData message, + boolean returnSerialized) { + LOG.debug("deleteData at path : {}", message.getPath()); + modification.addModification(new DeleteModification(message.getPath())); try { transaction.delete(message.getPath()); @@ -134,12 +137,19 @@ public class ShardWriteTransaction extends ShardTransaction { } } - private void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message, boolean returnSerialized) { + private void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message, + boolean returnSerialized) { + String transactionID = getTransactionID(); + + LOG.debug("readyTransaction : {}", transactionID); + DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); - getShardActor().forward(new ForwardedReadyTransaction( - getTransactionID(), cohort, modification, returnSerialized), - getContext()); + getShardActor().forward(new ForwardedReadyTransaction(transactionID, getTxnClientVersion(), + cohort, modification, returnSerialized), getContext()); + + // The shard will handle the commit from here so we're no longer needed - self-destruct. + getSelf().tell(PoisonPill.getInstance(), getSelf()); } // These classes are in here for test purposes only