Update DOMStoreThreePhaseCommitCohort design
[mdsal.git] / dom / mdsal-dom-spi / src / main / java / org / opendaylight / mdsal / dom / spi / store / DOMStoreThreePhaseCommitCohort.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.mdsal.dom.spi.store;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.mdsal.common.api.CommitInfo;
12 import org.opendaylight.yangtools.yang.common.Empty;
13
14 /**
15  * Interface implemented by the {@link DOMStore} and exposed for each
16  * {@link DOMStoreWriteTransaction} upon its transition to Ready state. The frontend (DOMStore user)
17  * uses this interface to drive the commit procedure across potentially multiple DOMStores using the
18  * Three-Phase-Commit (3PC) Protocol, as described in <a
19  * href="https://en.wikipedia.org/wiki/Three-phase_commit">Three phase Commit</a>.
20  */
21 public interface DOMStoreThreePhaseCommitCohort {
22
23     /**
24      * Sends transaction associated with this three phase commit instance to the participant,
25      * participant votes on the transaction, if the transaction should be committed or aborted.
26      *
27      * @return ListenableFuture with vote of the participant. Vote {@link ListenableFuture#get()} is
28      *         following:
29      *         <ul>
30      *         <li>
31      *         true if transaction is approved by data store.
32      *         <li>false if the transaction is not approved by data store and should be aborted.
33      *         </ul>
34      */
35     ListenableFuture<Boolean> canCommit();
36
37     /**
38      * Initiates a pre-commit phase of associated transaction on datastore.
39      *
40      * <p>
41      * This message is valid only and only if the participant responded
42      * on {@link #canCommit()} call with positive response.
43      *
44      * @return ListenableFuture representing acknowledgment for participant
45      *        that pre-commit message was received and processed.
46      */
47     ListenableFuture<Empty> preCommit();
48
49     /**
50      * Initiates a abort phase of associated transaction on data store.
51      *
52      * @return ListenableFuture representing acknowledgment for participant
53      *        that abort message was received.
54      */
55     ListenableFuture<Empty> abort();
56
57     /**
58      * Initiates a commit phase on of associated transaction on data store.
59      *
60      * @return ListenableFuture representing acknowledgment for participant
61      *        that commit message was received and commit of transaction was
62      *        processed.
63      */
64     ListenableFuture<? extends CommitInfo> commit();
65 }