Change DOM read/exists to FluentFuture
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMDataTreeReadTransaction.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.dom.api;
9
10 import com.google.common.util.concurrent.FluentFuture;
11 import java.util.Optional;
12 import org.opendaylight.mdsal.common.api.AsyncReadTransaction;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.mdsal.common.api.ReadFailedException;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * A transaction that provides read access to a logical data store.
20  *
21  * <p>
22  * For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}.
23  */
24 public interface DOMDataTreeReadTransaction extends AsyncReadTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
25
26     /**
27      * Reads data from provided logical data store located at the provided path.
28      *
29      *<p>
30      * If the target is a subtree, then the whole subtree is read (and will be
31      * accessible from the returned data object).
32      *
33      * @param store
34      *            Logical data store from which read should occur.
35      * @param path
36      *            Path which uniquely identifies subtree which client want to
37      *            read
38      * @return a FluentFuture containing the result of the read. The Future blocks until the
39      *         commit operation is complete. Once complete:
40      *         <ul>
41      *         <li>If the data at the supplied path exists, the Future returns an Optional object
42      *         containing the data.</li>
43      *         <li>If the data at the supplied path does not exist, the Future returns
44      *         Optional#absent().</li>
45      *         <li>If the read of the data fails, the Future will fail with a
46      *         {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
47      *         </ul>
48      */
49     FluentFuture<Optional<NormalizedNode<?,?>>> read(LogicalDatastoreType store, YangInstanceIdentifier path);
50
51     /**
52      * Checks if data is available in the logical data store located at provided path.
53      *
54      * <p>
55      * Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
56      * will succeed. It is possible that the data resides in a data store on a remote node and, if that
57      * node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
58      * the data is deleted in between the calls to <code>exists</code> and <code>read</code>
59      *
60      * @param store
61      *            Logical data store from which read should occur.
62      * @param path
63      *            Path which uniquely identifies subtree which client want to
64      *            check existence of
65      * @return a FluentFuture containing the result of the check.
66      *         <ul>
67      *         <li>If the data at the supplied path exists, the Future returns a Boolean
68      *         whose value is true, false otherwise</li>
69      *         <li>If checking for the data fails, the Future will fail with a
70      *         {@link ReadFailedException} or an exception derived from ReadFailedException.</li>
71      *         </ul>
72      */
73     FluentFuture<Boolean> exists(LogicalDatastoreType store, YangInstanceIdentifier path);
74 }