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=2e43219523e0d34b5b015b0ef0fc39370dbf89b8;hb=85a4118a6fe51d8571a1e7bb398d954e4ceddd33;hp=b0eaf98d59c9ccd2d1eda1f6d782736db238290e;hpb=98b9623656bdd4cb4f86348f6bc9fe71ec443fbf;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 b0eaf98d59..2e43219523 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 @@ -42,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, + short clientTxVersion) { + super(shardActor, schemaContext, shardStats, transactionID, clientTxVersion); this.transaction = transaction; } @@ -65,19 +66,19 @@ public class ShardWriteTransaction extends ShardTransaction { deleteData(transaction, (DeleteData) message, !SERIALIZED_REPLY); } else if (message instanceof ReadyTransaction) { - readyTransaction(transaction, new ReadyTransaction(), !SERIALIZED_REPLY); + readyTransaction(transaction, !SERIALIZED_REPLY); - } else if(WriteData.SERIALIZABLE_CLASS.equals(message.getClass())) { - writeData(transaction, WriteData.fromSerializable(message, getSchemaContext()), SERIALIZED_REPLY); + } else if(WriteData.isSerializedType(message)) { + writeData(transaction, WriteData.fromSerializable(message), SERIALIZED_REPLY); - } else if(MergeData.SERIALIZABLE_CLASS.equals(message.getClass())) { - mergeData(transaction, MergeData.fromSerializable(message, getSchemaContext()), SERIALIZED_REPLY); + } else if(MergeData.isSerializedType(message)) { + mergeData(transaction, MergeData.fromSerializable(message), SERIALIZED_REPLY); } else if(DeleteData.SERIALIZABLE_CLASS.equals(message.getClass())) { deleteData(transaction, DeleteData.fromSerializable(message), SERIALIZED_REPLY); } else if(ReadyTransaction.SERIALIZABLE_CLASS.equals(message.getClass())) { - readyTransaction(transaction, new ReadyTransaction(), SERIALIZED_REPLY); + readyTransaction(transaction, SERIALIZED_REPLY); } else if (message instanceof GetCompositedModification) { // This is here for testing only @@ -96,9 +97,9 @@ public class ShardWriteTransaction extends ShardTransaction { new WriteModification(message.getPath(), message.getData(), getSchemaContext())); try { transaction.write(message.getPath(), message.getData()); - WriteDataReply writeDataReply = new WriteDataReply(); - getSender().tell(returnSerialized ? writeDataReply.toSerializable() : writeDataReply, - getSelf()); + WriteDataReply writeDataReply = WriteDataReply.INSTANCE; + getSender().tell(returnSerialized ? writeDataReply.toSerializable(message.getVersion()) : + writeDataReply, getSelf()); }catch(Exception e){ getSender().tell(new akka.actor.Status.Failure(e), getSelf()); } @@ -113,9 +114,9 @@ public class ShardWriteTransaction extends ShardTransaction { try { transaction.merge(message.getPath(), message.getData()); - MergeDataReply mergeDataReply = new MergeDataReply(); - getSender().tell(returnSerialized ? mergeDataReply.toSerializable() : mergeDataReply , - getSelf()); + MergeDataReply mergeDataReply = MergeDataReply.INSTANCE; + getSender().tell(returnSerialized ? mergeDataReply.toSerializable(message.getVersion()) : + mergeDataReply, getSelf()); }catch(Exception e){ getSender().tell(new akka.actor.Status.Failure(e), getSelf()); } @@ -136,16 +137,15 @@ public class ShardWriteTransaction extends ShardTransaction { } } - private void readyTransaction(DOMStoreWriteTransaction transaction, ReadyTransaction message, - boolean returnSerialized) { + private void readyTransaction(DOMStoreWriteTransaction transaction, boolean returnSerialized) { String transactionID = getTransactionID(); LOG.debug("readyTransaction : {}", transactionID); DOMStoreThreePhaseCommitCohort cohort = transaction.ready(); - getShardActor().forward(new ForwardedReadyTransaction(transactionID, cohort, modification, - returnSerialized), getContext()); + getShardActor().forward(new ForwardedReadyTransaction(transactionID, getClientTxVersion(), + 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());