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;
12 import com.google.common.util.concurrent.CheckedFuture;
15 * User-supplied participant in three-phase commit of transaction for configuration data tree
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.
23 * Type of path (subtree identifier), which represents location in
26 * Type of data (payload), which represents data payload
28 public interface AsyncConfigurationCommitHandler<P extends Path<P>, D> {
32 * Requests a can commit phase
34 * Implementations SHOULD NOT do any blocking operation during
35 * processing this callback.
37 * <b>Implementation Notes</b>
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}
43 * <li>If validation (CAN_COMMIT) phase:
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.
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.
61 CheckedFuture<AsyncConfigurationCommitCohort<P, D>, DataValidationFailedException> canCommit(
62 ConfigurationCommitRequest<P, D> request);
66 * Commit Request as was submitted by client code
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.
74 * Type of path (subtree identifier), which represents location
77 * Type of data (payload), which represents data payload
79 interface ConfigurationCommitRequest<P extends Path<P>, D> {
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.
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.
92 * @return Read-only transaction which provides access only to configuration
93 * data tree as if submitted transaction successfully happened
95 AsyncReadTransaction<P, D> getReadOnlyView();
99 * Returns iteration of paths, to data which was introduced by this transaction.
101 * @return Iteration of paths, which was introduced by this transaction.
103 Iterable<P> getCreatedPaths();
106 * Returns iteration of paths, to data which was updated by this transaction.
108 * @return Iteration of paths, which was updated by this transaction.
110 Iterable<P> getUpdatedPaths();
114 * Returns iteration of paths, to data which was removed by this transaction.
116 * @return Iteration of paths, which was removed by this transaction.
118 Iterable<P> getRemovedPaths();