- 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<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
- transaction.read(path);
-
- future.addListener(new Runnable() {
- @Override
- public void run() {
- try {
- Optional<NormalizedNode<?, ?>> optional = future.checkedGet();
- ReadDataReply readDataReply = new ReadDataReply(optional.orNull());
-
- sender.tell((returnSerialized ? readDataReply.toSerializable(clientTxVersion):
- readDataReply), self);
-
- } catch (Exception e) {
- shardStats.incrementFailedReadTransactionsCount();
- sender.tell(new akka.actor.Status.Failure(e), self);
- }
-
- }
- }, getContext().dispatcher());
+ private boolean checkClosed(AbstractShardDataTreeTransaction<?> transaction) {
+ final boolean ret = transaction.isClosed();
+ if (ret) {
+ shardStats.incrementFailedReadTransactionsCount();
+ getSender().tell(new akka.actor.Status.Failure(new ReadFailedException("Transaction is closed")), getSelf());
+ }
+ return ret;