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