Mechanical code cleanup (sal-common-api)
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / AsyncConfigurationCommitHandler.java
1 /*
2  * Copyright (c) 2014 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.controller.md.sal.common.api.data;
9
10 import org.opendaylight.yangtools.concepts.Path;
11
12 import com.google.common.util.concurrent.CheckedFuture;
13
14 /**
15  * User-supplied participant in three-phase commit of transaction for configuration data tree
16  *
17  * Client-supplied implementation of commit handler for subtree, which
18  * is responsible for processing CAN-COMMIT phase of three-phase commit protocol
19  * and return CommitCohort, which provides access to additional transitions
20  * such as PRE-COMMIT, COMMIT and ABORT.
21  *
22  * @param <P>
23  *            Type of path (subtree identifier), which represents location in
24  *            tree
25  * @param <D>
26  *            Type of data (payload), which represents data payload
27  */
28 public interface AsyncConfigurationCommitHandler<P extends Path<P>, D> {
29
30     /**
31      *
32      * Requests a can commit phase
33      *
34      * Implementations SHOULD NOT do any blocking operation during
35      * processing this callback.
36      *
37      * <b>Implementation Notes</b>
38      * <ul>
39      * <li>Implementation are REQUIRED to use <code>request</code> object for any data related access</li>
40      * <li>Implementations SHOULD NOT use any other state stored outside configuration subtree for validation</li>
41      * <li>Validation should happen asynchronously, outside callback call by updating returned {@link CheckedFuture}
42      *     object.</li>
43      * <li>If validation (CAN_COMMIT) phase:
44      * <ul>
45      * <li><b>is successful</b> - invocation of {@link CheckedFuture#checkedGet()} on returned future MUST
46      *     return {@link AsyncConfigurationCommitCohort} associated with request.</li>
47      * <li><b>is unsuccessful</b> - invocation of {@link CheckedFuture#checkedGet()} must throw instance of {@link DataValidationFailedException}
48      * with human readable explanaition of error condition.
49      * </li>
50      * </ul>
51      * </li>
52      * @param request
53      *            Commit Request submitted by client, which contains
54      *            information about modifications and read-only view as
55      *            if transaction happened.
56      * @return CheckedFuture which contains client-supplied implementation of {@link AsyncConfigurationCommitCohort}
57      *         associated with submitted request, if can commit phase is
58      *         successful, if can commit was unsuccessful, future must fail with
59      *         {@link TransactionCommitFailedException} exception.
60      */
61     CheckedFuture<AsyncConfigurationCommitCohort<P, D>, DataValidationFailedException> canCommit(
62             ConfigurationCommitRequest<P, D> request);
63
64     /**
65      *
66      * Commit Request as was submitted by client code
67      *
68      * Commit Request contains list view of created / updated / removed
69      * path and read-only view of proposed client transaction,
70      * which may be used to retrieve modified or referenced data.
71      *
72      *
73      * @param <P>
74      *            Type of path (subtree identifier), which represents location
75      *            in tree
76      * @param <D>
77      *            Type of data (payload), which represents data payload
78      */
79     interface ConfigurationCommitRequest<P extends Path<P>, D> {
80
81         /**
82          *
83          * Read-only transaction which provides access only to configuration
84          * data tree as if submitted transaction successfully happened and
85          * no other concurrent modifications happened between allocation
86          * of client transactions and write of client transactions.
87          *
88          * Implementations of Commit Handlers are REQUIRED to use this
89          * read-only view to access any data from configuration data tree,
90          * in order to capture them as preconditions for this transaction.
91          *
92          * @return Read-only transaction which provides access only to configuration
93          * data tree as if submitted transaction successfully happened
94          */
95         AsyncReadTransaction<P, D> getReadOnlyView();
96
97         /**
98          *
99          * Returns iteration of paths, to data which was introduced by this transaction.
100          *
101          * @return Iteration of paths, which was introduced by this transaction.
102          */
103         Iterable<P> getCreatedPaths();
104         /**
105          *
106          * Returns iteration of paths, to data which was updated by this transaction.
107          *
108          * @return Iteration of paths, which was updated by this transaction.
109          */
110         Iterable<P> getUpdatedPaths();
111
112         /**
113          *
114          * Returns iteration of paths, to data which was removed by this transaction.
115          *
116          * @return Iteration of paths, which was removed by this transaction.
117          */
118         Iterable<P> getRemovedPaths();
119     }
120
121 }