Deprecate all MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / AsyncDataTransactionFactory.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 factory which allocates new transactions to operate on the data
14  * tree.
15  *
16  * <p>
17  * <b>Note:</b> This interface is not intended to be used directly, but rather
18  * via subinterfaces which introduces additional semantics to allocated
19  * transactions.
20  * <ul>
21  * <li> {@link AsyncDataBroker}
22  * <li> {@link TransactionChain}
23  * </ul>
24  *
25  * <p>
26  * All operations on the data tree are performed via one of the transactions:
27  * <ul>
28  * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
29  * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
30  * <li>Read-Write - allocated using {@link #newReadWriteTransaction()}
31  * </ul>
32  *
33  * <p>
34  * These transactions provides a stable isolated view of the data tree, which is
35  * guaranteed to be not affected by other concurrent transactions, until
36  * transaction is committed.
37  *
38  * <p>
39  * For a detailed explanation of how transaction are isolated and how transaction-local
40  * changes are committed to global data tree, see
41  * {@link AsyncReadTransaction}, {@link AsyncWriteTransaction},
42  * {@link AsyncReadWriteTransaction} and {@link AsyncWriteTransaction#submit()}.
43  *
44  * <p>
45  * It is strongly recommended to use the type of transaction, which
46  * provides only the minimal capabilities you need. This allows for
47  * optimizations at the data broker / data store level. For example,
48  * implementations may optimize the transaction for reading if they know ahead
49  * of time that you only need to read data - such as not keeping additional meta-data,
50  * which may be required for write transactions.
51  *
52  * <p>
53  * <b>Implementation Note:</b> This interface is not intended to be implemented
54  * by users of MD-SAL, but only to be consumed by them.
55  *
56  * @see AsyncDataBroker
57  * @see TransactionChain
58  *
59  * @param <P>
60  *            Type of path (subtree identifier), which represents location in
61  *            tree
62  * @param <D>
63  *            Type of data (payload), which represents data payload
64  */
65 @Deprecated
66 public interface AsyncDataTransactionFactory<P extends Path<P>, D> {
67
68     /**
69      * Allocates a new read-only transaction which provides an immutable snapshot of the data tree.
70      *
71      * <p>
72      * The view of data tree is an immutable snapshot of current data tree state when
73      * transaction was allocated.
74      *
75      * @return new read-only transaction
76      */
77     AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
78
79     /**
80      * Allocates new read-write transaction which provides a mutable view of the data
81      * tree.
82      *
83      * <p>
84      * Preconditions for mutation of data tree are captured from the snapshot of
85      * data tree state, when the transaction is allocated. If data was
86      * changed during transaction in an incompatible way then the commit of this transaction
87      * will fail. See {@link AsyncWriteTransaction#submit()} for more
88      * details about conflicting and not-conflicting changes and
89      * failure scenarios.
90      *
91      * @return new read-write transaction
92      */
93     AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
94
95     /**
96      * Allocates new write-only transaction based on latest state of data
97      * tree.
98      *
99      * <p>
100      * Preconditions for mutation of data tree are captured from the snapshot of
101      * data tree state, when the transaction is allocated. If data was
102      * changed during transaction in an incompatible way then the commit of this transaction
103      * will fail. See {@link AsyncWriteTransaction#submit()} for more
104      * details about conflicting and not-conflicting changes and
105      * failure scenarios.
106      *
107      * <p>
108      * Since this transaction does not provide a view of the data it SHOULD BE
109      * used only by callers which are exclusive writers (exporters of data)
110      * to the subtree they modify. This prevents optimistic
111      * lock failures as described in {@link AsyncWriteTransaction#submit()}.
112      *
113      * <p>
114      * Exclusivity of writers to particular subtree SHOULD BE enforced by
115      * external locking mechanism.
116      *
117      * @return new write-only transaction
118      */
119     AsyncWriteTransaction<P, D> newWriteOnlyTransaction();
120
121 }