Fixed Checkstyle violation errors in mdsal-dom-api module
[mdsal.git] / dom / mdsal-dom-api / src / main / java / org / opendaylight / mdsal / dom / api / DOMDataTreeCursorAwareTransaction.java
1 /*
2  * Copyright (c) 2016 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.util.concurrent.CheckedFuture;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
14 import org.opendaylight.yangtools.concepts.Identifiable;
15
16 /**
17  * Write transaction that provides cursor's with write access to the data tree.
18  */
19 public interface DOMDataTreeCursorAwareTransaction extends DOMDataTreeCursorProvider, Identifiable<Object> {
20
21     /**
22      * Create a {@link DOMDataTreeWriteCursor} anchored at the specified path.
23      * There can only be one cursor open at a time.
24      *
25      * @param path Path at which the cursor is to be anchored
26      * @return write cursor at the desired location.
27      * @throws IllegalStateException when there's an open cursor, or this transaction is closed already.
28      */
29     @Override
30     @Nullable DOMDataTreeWriteCursor createCursor(@Nonnull DOMDataTreeIdentifier path);
31
32     /**
33      * Cancels the transaction.
34      * Transactions can only be cancelled if it was not yet submited.
35      * Invoking cancel() on failed or already canceled will have no effect, and transaction is
36      * considered cancelled.
37      * Invoking cancel() on finished transaction (future returned by {@link #submit()} already
38      * successfully completed) will always fail (return false).
39      *
40      * @return <tt>false</tt> if the task could not be cancelled, typically because it has already
41      *         completed normally; <tt>true</tt> otherwise
42      *
43      */
44     boolean cancel();
45
46     /**
47      * Submits this transaction to be asynchronously applied to update the logical data tree. The
48      * returned CheckedFuture conveys the result of applying the data changes.
49      *
50      * <p>
51      * <b>Note:</b> It is strongly recommended to process the CheckedFuture result in an
52      * asynchronous manner rather than using the blocking get() method.
53      * This call logically seals the transaction, which prevents the client from further changing
54      * data tree using this transaction's cursor. Any subsequent calls to
55      * <code>createCursorCursor(DOMDataTreeIdentifier</code>
56      * or any of the cursor's methods will fail with {@link IllegalStateException}.
57      * The transaction is marked as submitted and enqueued into the shard back-end for
58      * processing.
59      *
60      * @return Checked future informing of success/failure
61      */
62     CheckedFuture<Void, TransactionCommitFailedException> submit();
63 }