2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.api;
11 * A transaction that provides a stateful read-only view of the data tree.
14 * View of the data tree is a stable point-in-time snapshot of the current data tree state when the
15 * transaction was created. It's state and underlying data tree is not affected by other
16 * concurrently running transactions.
19 * <b>Implementation Note:</b> This interface is not intended to be implemented by users of MD-SAL,
20 * but only to be consumed by them.
22 * <h2>Transaction isolation example</h2>
23 * Lets assume initial state of data tree for <code>PATH</code> is <code>A</code>.
26 * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data
27 * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction
28 * txRead.read(OPERATIONAL, PATH).get(); // will return Optional containing A
29 * txWrite = broker.put(OPERATIONAL, PATH, B); // writes B to PATH
30 * txRead.read(OPERATIONAL, PATH).get(); // still returns Optional containing A
31 * txWrite.submit().get(); // data tree is updated, PATH contains B
32 * txRead.read(OPERATIONAL, PATH).get(); // still returns Optional containing A
33 * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
34 * txAfterCommit.read(OPERATIONAL, PATH).get(); // returns Optional containing B;
38 * <b>Note:</b> example contains blocking calls on future only to illustrate that action happened after other
39 * asynchronous action. Use of blocking call {@link com.google.common.util.concurrent.FluentFuture#get()} is
40 * discouraged for most uses and you should use
41 * {@link com.google.common.util.concurrent.FluentFuture#addCallback(com.google.common.util.concurrent.FutureCallback,
42 * java.util.concurrent.Executor)} or other functions from {@link com.google.common.util.concurrent.Futures} to register
43 * more specific listeners.
45 public interface ReadTransaction extends Transaction, AutoCloseable, ReadOperations {
47 * Closes this transaction and releases all resources associated with it.