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=af25df13d2865ba867d6a529d3ad947101b1510a;hp=678b7815693382179328a8c13adb567d80d61b13;hb=8fe43e73969a8f189b76dd021c9e84146473a596;hpb=3f153e5fa694fe4147e72e615edbb5c263e5a394 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 678b781569..af25df13d2 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 @@ -39,12 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; * The ShardTransaction Actor delegates all actions to DOMDataReadWriteTransaction *

*

- * Even though the DOMStore and the DOMStoreTransactionChain implement multiple types of transactions - * the ShardTransaction Actor only works with read-write transactions. This is just to keep the logic simple. At this - * time there are no known advantages for creating a read-only or write-only transaction which may change over time - * at which point we can optimize things in the distributed store as well. - *

- *

* Handles Messages
* ----------------
*

  • {@link org.opendaylight.controller.cluster.datastore.messages.ReadData} @@ -114,10 +108,14 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering } } + protected boolean returnCloseTransactionReply() { + return true; + } + private void closeTransaction(boolean sendReply) { getDOMStoreTransaction().close(); - if(sendReply) { + if(sendReply && returnCloseTransactionReply()) { getSender().tell(CloseTransactionReply.INSTANCE.toSerializable(), getSelf()); } @@ -126,29 +124,20 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering 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(optional.orNull()); - - sender.tell((returnSerialized ? readDataReply.toSerializable(clientTxVersion): - readDataReply), self); + final YangInstanceIdentifier path = message.getPath(); + try { + final CheckedFuture>, ReadFailedException> future = transaction.read(path); + Optional> optional = future.checkedGet(); + ReadDataReply readDataReply = new ReadDataReply(optional.orNull()); - } catch (Exception e) { - shardStats.incrementFailedReadTransactionsCount(); - sender.tell(new akka.actor.Status.Failure(e), self); - } + sender().tell((returnSerialized ? readDataReply.toSerializable(clientTxVersion): readDataReply), self()); - } - }, getContext().dispatcher()); + } catch (Exception e) { + LOG.debug(String.format("Unexpected error reading path %s", path), e); + shardStats.incrementFailedReadTransactionsCount(); + sender().tell(new akka.actor.Status.Failure(e), self()); + } } protected void dataExists(DOMStoreReadTransaction transaction, DataExists message,