API Usability: Introduced type capture for Transaction Factory
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / DOMDataCommitExecutor.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.dom.broker.impl;
9
10 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
11 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14
15 import com.google.common.base.Optional;
16 import com.google.common.util.concurrent.ListenableFuture;
17
18 /**
19  * Executor of Three Phase Commit coordination for
20  * {@link DOMDataWriteTransaction} transactions.
21  *
22  * Implementations are responsible for executing implementation of three-phase
23  * commit protocol on supplied {@link DOMStoreThreePhaseCommitCohort}s.
24  *
25  *
26  */
27 interface DOMDataCommitExecutor {
28
29     /**
30      * Submits supplied transaction to be executed in context of provided
31      * cohorts.
32      *
33      * Transaction is used only as a context, cohorts should be associated with
34      * this transaction.
35      *
36      * @param tx
37      *            Transaction to be used as context for reporting
38      * @param cohort
39      *            DOM Store cohorts representing provided transaction, its
40      *            subtransactoins.
41      * @param listener
42      *            Error listener which should be notified if transaction failed.
43      * @return ListenableFuture which contains RpcResult with
44      *         {@link TransactionStatus#COMMITED} if commit coordination on
45      *         cohorts finished successfully.
46      *
47      */
48     ListenableFuture<RpcResult<TransactionStatus>> submit(DOMDataWriteTransaction tx,
49             Iterable<DOMStoreThreePhaseCommitCohort> cohort, Optional<DOMDataCommitErrorListener> listener);
50
51 }