ef9b66a1bcb028233a039203ec02eabc48b5530c
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardTransaction.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.datastore;
10
11 import akka.actor.Props;
12 import akka.actor.UntypedActor;
13 import akka.japi.Creator;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
15
16 /**
17  * The ShardTransaction Actor represents a remote transaction
18  *
19  * The ShardTransaction Actor delegates all actions to DOMDataReadWriteTransaction
20  *
21  * Even though the DOMStore and the DOMStoreTransactionChain implement multiple types of transactions
22  * the ShardTransaction Actor only works with read-write transactions. This is just to keep the logic simple. At this
23  * time there are no known advantages for creating a read-only or write-only transaction which may change over time
24  * at which point we can optimize things in the distributed store as well.
25  */
26 public class ShardTransaction extends UntypedActor {
27
28   private final DOMStoreReadWriteTransaction transaction;
29
30   public ShardTransaction(DOMStoreReadWriteTransaction transaction) {
31     this.transaction = transaction;
32   }
33
34
35   public static Props props(final DOMStoreReadWriteTransaction transaction){
36     return Props.create(new Creator<ShardTransaction>(){
37
38       @Override
39       public ShardTransaction create() throws Exception {
40         return new ShardTransaction(transaction);
41       }
42     });
43   }
44
45   @Override
46   public void onReceive(Object message) throws Exception {
47     throw new UnsupportedOperationException("onReceive");
48   }
49 }