940559ef895bf9cec406eee2fbe73a7617da581a
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / TransactionChain.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 package org.opendaylight.controller.md.sal.common.api.data;
9
10 import org.opendaylight.yangtools.concepts.Path;
11
12 /**
13  * A chain of transactions. Transactions in a chain need to be committed in sequence and each
14  * transaction should see the effects of previous transactions as if they happened. A chain
15  * makes no guarantees of atomicity, in fact transactions are committed as soon as possible.
16  *
17  */
18 public interface TransactionChain<P extends Path<P>, D> extends AutoCloseable, AsyncDataTransactionFactory<P, D> {
19
20     /**
21      * Create a new read only transaction which will continue the chain.
22      * The previous read-write transaction has to be either COMMITED or CANCELLED.
23      *
24      * @return New transaction in the chain.
25      * @throws IllegalStateException if the previous transaction was not COMMITED
26      *    or CANCELLED.
27      * @throws TransactionChainClosedException if the chain has been closed.
28      */
29     @Override
30     public AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
31
32
33     /**
34      * Create a new read write transaction which will continue the chain.
35      * The previous read-write transaction has to be either COMMITED or CANCELLED.
36      *
37      * @return New transaction in the chain.
38      * @throws IllegalStateException if the previous transaction was not COMMITTED
39      *    or CANCELLED.
40      * @throws TransactionChainClosedException if the chain has been closed.
41      */
42     @Override
43     public AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
44
45     @Override
46     void close();
47 }
48