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%2FShardTransaction.java;h=678b7815693382179328a8c13adb567d80d61b13;hp=32de47f451d9ff53f301339975357440e651bea5;hb=cad857b425b1a0072681066b2ba37b0b0dc8c111;hpb=139937c2e646894af6a9b2b8a8a1047c6ef82485 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java index 32de47f451..678b781569 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java @@ -57,26 +57,29 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; */ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering { + protected static final boolean SERIALIZED_REPLY = true; + private final ActorRef shardActor; private final SchemaContext schemaContext; private final ShardStats shardStats; private final String transactionID; - protected static final boolean SERIALIZED_REPLY = true; + private final short clientTxVersion; protected ShardTransaction(ActorRef shardActor, SchemaContext schemaContext, - ShardStats shardStats, String transactionID) { + ShardStats shardStats, String transactionID, short clientTxVersion) { super("shard-tx"); //actor name override used for metering. This does not change the "real" actor name this.shardActor = shardActor; this.schemaContext = schemaContext; this.shardStats = shardStats; this.transactionID = transactionID; + this.clientTxVersion = clientTxVersion; } public static Props props(DOMStoreTransaction transaction, ActorRef shardActor, SchemaContext schemaContext,DatastoreContext datastoreContext, ShardStats shardStats, - String transactionID) { + String transactionID, short txnClientVersion) { return Props.create(new ShardTransactionCreator(transaction, shardActor, schemaContext, - datastoreContext, shardStats, transactionID)); + datastoreContext, shardStats, transactionID, txnClientVersion)); } protected abstract DOMStoreTransaction getDOMStoreTransaction(); @@ -93,6 +96,10 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering return schemaContext; } + protected short getClientTxVersion() { + return clientTxVersion; + } + @Override public void handleReceive(Object message) throws Exception { if (message.getClass().equals(CloseTransaction.SERIALIZABLE_CLASS)) { @@ -111,28 +118,28 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering getDOMStoreTransaction().close(); if(sendReply) { - getSender().tell(new CloseTransactionReply().toSerializable(), getSelf()); + getSender().tell(CloseTransactionReply.INSTANCE.toSerializable(), getSelf()); } getSelf().tell(PoisonPill.getInstance(), getSelf()); } - protected void readData(DOMStoreReadTransaction transaction, ReadData message, final boolean returnSerialized) { + protected void readData(DOMStoreReadTransaction transaction, ReadData message, + final boolean returnSerialized) { final ActorRef sender = getSender(); final ActorRef self = getSelf(); final YangInstanceIdentifier path = message.getPath(); final CheckedFuture>, ReadFailedException> future = transaction.read(path); - future.addListener(new Runnable() { @Override public void run() { try { Optional> optional = future.checkedGet(); - ReadDataReply readDataReply = new ReadDataReply(schemaContext, optional.orNull()); + ReadDataReply readDataReply = new ReadDataReply(optional.orNull()); - sender.tell((returnSerialized ? readDataReply.toSerializable(): + sender.tell((returnSerialized ? readDataReply.toSerializable(clientTxVersion): readDataReply), self); } catch (Exception e) { @@ -169,16 +176,18 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering final DatastoreContext datastoreContext; final ShardStats shardStats; final String transactionID; + final short txnClientVersion; ShardTransactionCreator(DOMStoreTransaction transaction, ActorRef shardActor, SchemaContext schemaContext, DatastoreContext datastoreContext, - ShardStats shardStats, String transactionID) { + ShardStats shardStats, String transactionID, short txnClientVersion) { this.transaction = transaction; this.shardActor = shardActor; this.shardStats = shardStats; this.schemaContext = schemaContext; this.datastoreContext = datastoreContext; this.transactionID = transactionID; + this.txnClientVersion = txnClientVersion; } @Override @@ -186,13 +195,13 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering ShardTransaction tx; if(transaction instanceof DOMStoreReadWriteTransaction) { tx = new ShardReadWriteTransaction((DOMStoreReadWriteTransaction)transaction, - shardActor, schemaContext, shardStats, transactionID); + shardActor, schemaContext, shardStats, transactionID, txnClientVersion); } else if(transaction instanceof DOMStoreReadTransaction) { tx = new ShardReadTransaction((DOMStoreReadTransaction)transaction, shardActor, - schemaContext, shardStats, transactionID); + schemaContext, shardStats, transactionID, txnClientVersion); } else { tx = new ShardWriteTransaction((DOMStoreWriteTransaction)transaction, - shardActor, schemaContext, shardStats, transactionID); + shardActor, schemaContext, shardStats, transactionID, txnClientVersion); } tx.getContext().setReceiveTimeout(datastoreContext.getShardTransactionIdleTimeout());