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%2FShardWriteTransaction.java;h=a4a2f45fdbdda87cc1166aa0e169214eea0df313;hp=44f2c7bd0a2794715d09cb29bb7a5ce42b352344;hb=707e2aa73c7314180472539ed4137950d33f5776;hpb=f281dc3e886501dc617e397c8e203732300a8f08 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 44f2c7bd0a..a4a2f45fdb 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 @@ -23,7 +23,6 @@ import org.opendaylight.controller.cluster.datastore.messages.WriteData; import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply; import org.opendaylight.controller.cluster.datastore.modification.CompositeModification; import org.opendaylight.controller.cluster.datastore.modification.DeleteModification; -import org.opendaylight.controller.cluster.datastore.modification.ImmutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.MergeModification; import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; @@ -43,8 +42,8 @@ public class ShardWriteTransaction extends ShardTransaction { public ShardWriteTransaction(DOMStoreWriteTransaction transaction, ActorRef shardActor, SchemaContext schemaContext, ShardStats shardStats, String transactionID, - int txnClientVersion) { - super(shardActor, schemaContext, shardStats, transactionID, txnClientVersion); + short clientTxVersion) { + super(shardActor, schemaContext, shardStats, transactionID, clientTxVersion); this.transaction = transaction; } @@ -66,24 +65,23 @@ 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())) { + } else if(DeleteData.isSerializedType(message)) { 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 - getSender().tell(new GetCompositeModificationReply( - new ImmutableCompositeModification(modification)), getSelf()); + getSender().tell(new GetCompositeModificationReply(modification), getSelf()); } else { super.handleReceive(message); } @@ -94,12 +92,12 @@ public class ShardWriteTransaction extends ShardTransaction { LOG.debug("writeData at path : {}", message.getPath()); modification.addModification( - new WriteModification(message.getPath(), message.getData(), getSchemaContext())); + new WriteModification(message.getPath(), message.getData())); 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()); } @@ -110,13 +108,13 @@ public class ShardWriteTransaction extends ShardTransaction { LOG.debug("mergeData at path : {}", message.getPath()); modification.addModification( - new MergeModification(message.getPath(), message.getData(), getSchemaContext())); + new MergeModification(message.getPath(), message.getData())); 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()); } @@ -129,23 +127,22 @@ public class ShardWriteTransaction extends ShardTransaction { modification.addModification(new DeleteModification(message.getPath())); try { transaction.delete(message.getPath()); - DeleteDataReply deleteDataReply = new DeleteDataReply(); - getSender().tell(returnSerialized ? deleteDataReply.toSerializable() : deleteDataReply, - getSelf()); + DeleteDataReply deleteDataReply = DeleteDataReply.INSTANCE; + getSender().tell(returnSerialized ? deleteDataReply.toSerializable(message.getVersion()) : + deleteDataReply, getSelf()); }catch(Exception e){ getSender().tell(new akka.actor.Status.Failure(e), getSelf()); } } - 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, getTxnClientVersion(), + 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.