@Beta public interface ReadTransaction extends Transaction, org.opendaylight.yangtools.concepts.Registration
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.submit().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 Future.get()
is
discouraged for most uses and you should use
FluentFuture.addCallback(com.google.common.util.concurrent.FutureCallback,
java.util.concurrent.Executor)
or other functions from Futures
to register
more specific listeners.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this transaction and releases all resources associated with it.
|
<T extends TreeNode> |
read(LogicalDatastoreType store,
InstanceIdentifier<T> path,
BiConsumer<ReadFailedException,T> callback)
Reads data from the provided logical data store located at the provided path.
|
<T extends TreeNode> void read(LogicalDatastoreType store, InstanceIdentifier<T> path, BiConsumer<ReadFailedException,T> callback)
If the target is a subtree, then the whole subtree is read (and will be accessible from the returned data object).
T
- result typestore
- Logical data store from which read should occur.path
- Path which uniquely identifies subtree which client want to
readcallback
- result callbackvoid close()
close
in interface AutoCloseable
close
in interface org.opendaylight.yangtools.concepts.Registration
Copyright © 2019 OpenDaylight. All rights reserved.