2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.actor.ActorRef;
12 import akka.actor.Props;
13 import akka.actor.UntypedActor;
14 import akka.japi.Creator;
15 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
16 import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
18 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
21 * The ShardTransactionChain Actor represents a remote TransactionChain
23 public class ShardTransactionChain extends UntypedActor{
25 private final DOMStoreTransactionChain chain;
27 public ShardTransactionChain(DOMStoreTransactionChain chain) {
32 public void onReceive(Object message) throws Exception {
33 if(message instanceof CreateTransaction){
34 DOMStoreReadWriteTransaction transaction = chain.newReadWriteTransaction();
35 ActorRef transactionActor = getContext().actorOf(ShardTransaction.props(transaction));
36 getSender().tell(new CreateTransactionReply(transactionActor.path()), getSelf());
40 public static Props props(final DOMStoreTransactionChain chain){
41 return Props.create(new Creator<ShardTransactionChain>(){
44 public ShardTransactionChain create() throws Exception {
45 return new ShardTransactionChain(chain);