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.ReadData;
20 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
21 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
22 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
28 public class ShardReadTransaction extends ShardTransaction {
29 private final DOMStoreReadTransaction transaction;
30 private final LoggingAdapter log =
31 Logging.getLogger(getContext().system(), this);
33 public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
34 super(shardActor, schemaContext);
35 this.transaction = transaction;
39 public ShardReadTransaction(DOMStoreTransactionChain transactionChain, DOMStoreReadTransaction transaction, ActorRef shardActor, SchemaContext schemaContext) {
40 super(transactionChain, shardActor, schemaContext);
41 this.transaction = transaction;
45 public void handleReceive(Object message) throws Exception {
46 if (ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
47 readData(transaction,ReadData.fromSerializable(message));
49 super.handleReceive(message);
52 protected void closeTransaction(CloseTransaction message) {
54 getSender().tell(new CloseTransactionReply().toSerializable(), getSelf());
55 getSelf().tell(PoisonPill.getInstance(), getSelf());