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.controller.md.sal.common.api.data;
10 import org.opendaylight.yangtools.concepts.Path;
13 * Marker interface for stateful read view of the data tree.
16 * View of the data tree is a stable point-in-time snapshot of the current data tree state when
17 * the transaction was created. It's state and underlying data tree
18 * is not affected by other concurrently running transactions.
21 * <b>Implementation Note:</b> This interface is not intended to be implemented
22 * by users of MD-SAL, but only to be consumed by them.
24 * <h2>Transaction isolation example</h2>
25 * Lets assume initial state of data tree for <code>PATH</code> is <code>A</code>.
28 * txRead = broker.newReadOnlyTransaction(); // read Transaction is snapshot of data
29 * txWrite = broker.newReadWriteTransactoin(); // concurrent write transaction
31 * txRead.read(OPERATIONAL,PATH).get(); // will return Optional containing A
32 * txWrite = broker.put(OPERATIONAL,PATH,B); // writes B to PATH
34 * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A
36 * txWrite.commit().get(); // data tree is updated, PATH contains B
37 * txRead.read(OPERATIONAL,PATH).get(); // still returns Optional containing A
39 * txAfterCommit = broker.newReadOnlyTransaction(); // read Transaction is snapshot of new state
40 * txAfterCommit.read(OPERATIONAL,PATH).get(); // returns Optional containing B;
44 * <b>Note:</b> example contains blocking calls on future only to illustrate
45 * that action happened after other asynchronous action. Use of blocking call
46 * {@link com.google.common.util.concurrent.ListenableFuture#get()} is discouraged for most
47 * uses and you should use
48 * {@link com.google.common.util.concurrent.Futures#addCallback(com.google.common.util.concurrent.ListenableFuture,
49 * com.google.common.util.concurrent.FutureCallback, java.util.concurrent.Executor)}
50 * or other functions from {@link com.google.common.util.concurrent.Futures} to
51 * register more specific listeners.
54 * Type of path (subtree identifier), which represents location in
57 * Type of data (payload), which represents data payload
60 public interface AsyncReadTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {