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
8 package org.opendaylight.controller.md.sal.common.api.data;
10 import org.opendaylight.yangtools.concepts.Path;
13 * A factory which allocates new transactions to operate on the data
17 * <b>Note:</b> This interface is not intended to be used directly, but rather
18 * via subinterfaces which introduces additional semantics to allocated
21 * <li> {@link AsyncDataBroker}
22 * <li> {@link TransactionChain}
26 * All operations on the data tree are performed via one of the transactions:
28 * <li>Read-Only - allocated using {@link #newReadOnlyTransaction()}
29 * <li>Write-Only - allocated using {@link #newWriteOnlyTransaction()}
30 * <li>Read-Write - allocated using {@link #newReadWriteTransaction()}
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.
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()}.
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.
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.
56 * @see AsyncDataBroker
57 * @see TransactionChain
60 * Type of path (subtree identifier), which represents location in
63 * Type of data (payload), which represents data payload
66 public interface AsyncDataTransactionFactory<P extends Path<P>, D> {
69 * Allocates a new read-only transaction which provides an immutable snapshot of the data tree.
72 * The view of data tree is an immutable snapshot of current data tree state when
73 * transaction was allocated.
75 * @return new read-only transaction
77 AsyncReadOnlyTransaction<P, D> newReadOnlyTransaction();
80 * Allocates new read-write transaction which provides a mutable view of the data
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
91 * @return new read-write transaction
93 AsyncReadWriteTransaction<P, D> newReadWriteTransaction();
96 * Allocates new write-only transaction based on latest state of data
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
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()}.
114 * Exclusivity of writers to particular subtree SHOULD BE enforced by
115 * external locking mechanism.
117 * @return new write-only transaction
119 AsyncWriteTransaction<P, D> newWriteOnlyTransaction();