Merge "Custom mailbox that is bounded and instrumented."
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / TransactionChainProxy.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 org.opendaylight.controller.cluster.datastore.utils.ActorContext;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
13 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
15 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17
18 import com.google.common.util.concurrent.ListeningExecutorService;
19
20 /**
21  * TransactionChainProxy acts as a proxy for a DOMStoreTransactionChain created on a remote shard
22  */
23 public class TransactionChainProxy implements DOMStoreTransactionChain{
24     private final ActorContext actorContext;
25     private final ListeningExecutorService transactionExecutor;
26     private final SchemaContext schemaContext;
27
28     public TransactionChainProxy(ActorContext actorContext, ListeningExecutorService transactionExecutor,
29             SchemaContext schemaContext) {
30         this.actorContext = actorContext;
31         this.transactionExecutor = transactionExecutor;
32         this.schemaContext = schemaContext;
33     }
34
35     @Override
36     public DOMStoreReadTransaction newReadOnlyTransaction() {
37         return new TransactionProxy(actorContext,
38             TransactionProxy.TransactionType.READ_ONLY, transactionExecutor, schemaContext);
39     }
40
41     @Override
42     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
43         return new TransactionProxy(actorContext,
44             TransactionProxy.TransactionType.WRITE_ONLY, transactionExecutor, schemaContext);
45     }
46
47     @Override
48     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
49         return new TransactionProxy(actorContext,
50             TransactionProxy.TransactionType.READ_WRITE, transactionExecutor, schemaContext);
51     }
52
53     @Override
54     public void close() {
55         // FIXME : The problem here is don't know which shard the transaction chain is to be created on ???
56         throw new UnsupportedOperationException("close - not sure what to do here?");
57     }
58 }