3 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
11 package org.opendaylight.controller.cluster.datastore;
13 import akka.actor.ActorRef;
14 import akka.actor.PoisonPill;
15 import akka.event.Logging;
16 import akka.event.LoggingAdapter;
17 import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
18 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
19 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
20 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
21 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
22 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
29 public class ShardReadTransaction extends ShardTransaction {
30 private final DOMStoreReadTransaction transaction;
31 private final LoggingAdapter log =
32 Logging.getLogger(getContext().system(), this);
34 public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
35 super(shardActor, schemaContext);
36 this.transaction = transaction;
40 public ShardReadTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
41 super(transactionChain, shardActor, schemaContext);
42 this.transaction = transaction;
46 public void handleReceive(Object message) throws Exception {
47 if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
48 readData(transaction, ReadData.fromSerializable(message));
49 } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
50 dataExists(transaction, DataExists.fromSerializable(message));
52 super.handleReceive(message);
55 protected void closeTransaction(CloseTransaction message) {
57 getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
58 getSelf().tell(PoisonPill.getInstance(), getSelf());
61 //default scope test method to check if we get correct exception
62 void forUnitTestOnlyExplicitTransactionClose(){