Removed legacy binding-api concepts.
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / AsyncReadTransaction.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.mdsal.common.api;
9
10 import org.opendaylight.yangtools.concepts.Path;
11
12 /**
13  *
14  * Marker interface for stateful read view of the data tree.
15  *
16  * <p>
17  * View of the data tree is a stable point-in-time snapshot of the current data tree state when the
18  * transaction was created. It's state and underlying data tree is not affected by other
19  * concurrently running transactions.
20  *
21  * <p>
22  * <b>Implementation Note:</b> This interface is not intended to be implemented by users of MD-SAL,
23  * but only to be consumed by them.
24  *
25  * <h2>Transaction isolation example</h2>
26  * Lets assume initial state of data tree for <code>PATH</code> is <code>A</code>.
27  *
28  * <pre>
29  * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data
30  * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction
31  * 
32  * txRead.read(OPERATIONAL, PATH).get(); // will return Optional containing A
33  * txWrite = broker.put(OPERATIONAL, PATH, B); // writes B to PATH
34  * 
35  * txRead.read(OPERATIONAL, PATH).get(); // still returns Optional containing A
36  * 
37  * txWrite.submit().get(); // data tree is updated, PATH contains B
38  * txRead.read(OPERATIONAL, PATH).get(); // still returns Optional containing A
39  * 
40  * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
41  * txAfterCommit.read(OPERATIONAL, PATH).get(); // returns Optional containing B;
42  * </pre>
43  *
44  * <p>
45  * <b>Note:</b> example contains blocking calls on future only to illustrate that action happened
46  * after other asynchronous action. Use of blocking call
47  * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most uses and
48  * you should use
49  * {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture, com.google.common.util.concurrent.FutureCallback)}
50  * or other functions from {@link com.google.common.util.concurrent.Futures} to register more
51  * specific listeners.
52  *
53  * @param <P> Type of path (subtree identifier), which represents location in tree
54  * @param <D> Type of data (payload), which represents data payload
55  *
56  */
57 public interface AsyncReadTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
58
59 }