X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-common-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fcommon%2Fapi%2Fdata%2FAsyncReadTransaction.java;h=6cf5a5b532d41725ce76f45299536de76c63ece2;hb=18f8f0b852694daf18e8fd034ba576d78499e0ee;hp=1d1d9101ec61c0e403760b6845f80e70de912deb;hpb=2a4c88aa665a45c5394642cb3604603bebf8c0da;p=controller.git diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java index 1d1d9101ec..6cf5a5b532 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java @@ -7,19 +7,66 @@ */ package org.opendaylight.controller.md.sal.common.api.data; -import java.util.concurrent.Future; - import org.opendaylight.yangtools.concepts.Path; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; +/** + * + * Provides a stateful read-only view of the data tree. + * + *
+ * View of the data tree is a stable point-in-time snapshot of the current data tree state when + * the transaction was created. It's state and underlying data tree + * is not affected by other concurrently running transactions. + * + *
+ * Implementation Note: This interface is not intended to be implemented + * by users of MD-SAL, but only to be consumed by them. + * + *
PATH
is A
.
+ *
+ * + * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data + * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction + * + * txRead.read(OPERATIONAL,PATH).get(); // will return Optional containing A + * txWrite = broker.put(OPERATIONAL,PATH,B); // writes B to PATH + * + * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A + * + * txWrite.commit().get(); // data tree is updated, PATH contains B + * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A + * + * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state + * txAfterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B; + *+ * + *
+ * Note: example contains blocking calls on future only to illustrate + * that action happened after other asynchronous action. Use of blocking call + * {@link ListenableFuture#get()} is discouraged for most uses and you should + * use + * {@link com.google.common.util.concurrent.Futures#addCallback(ListenableFuture, com.google.common.util.concurrent.FutureCallback)} + * or other functions from {@link com.google.common.util.concurrent.Futures} to + * register more specific listeners. + * + * @param
+ * Type of path (subtree identifier), which represents location in
+ * tree
+ * @param , D> extends AsyncTransaction {
/**
*
- * Reads data from provided logical data store located at provided path
- *
+ * Reads data from provided logical data store located at the provided path.
+ *
+ * If the target is a subtree, then the whole subtree is read (and will be
+ * accessible from the returned data object).
*
* @param store
* Logical data store from which read should occur.
@@ -28,10 +75,11 @@ public interface AsyncReadTransaction , D> extends AsyncTransac
* read
* @return Listenable Future which contains read result
*
- *
*/
ListenableFuture