Fixed Checkstyle violation errors in mdsal-common-api
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / PostPreCommitStep.java
1 /*
2  * Copyright (c) 2015 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.common.api;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13
14 /**
15  * User implementation of steps following pre-commit from Three-Phase Protocol.
16  *
17  */
18 @Beta
19 public interface PostPreCommitStep extends ThreePhaseCommitStep {
20
21     /**
22      * No-op implementation of {@link #abort()} and {@link #commit()} method, which always success
23      * calls.
24      * This implementation is intended for users which may not need to implement commit and abort
25      * method.
26      *
27      */
28     PostPreCommitStep NOOP = new PostPreCommitStep() {
29
30         @Override
31         public ListenableFuture<?> abort() {
32             return ThreePhaseCommitStep.NOOP_ABORT_FUTURE;
33         }
34
35         @Override
36         public ListenableFuture<?> commit() {
37             return NOOP_COMMIT_FUTURE;
38         }
39     };
40
41     ListenableFuture<?> NOOP_COMMIT_FUTURE = Futures.immediateFuture(null);
42
43     ListenableFuture<? extends PostPreCommitStep> NOOP_FUTURE = Futures.immediateFuture(NOOP);
44
45     /**
46      * Commits cohort transaction.
47      * This callback is invoked by three-phase commit coordinator if associated data transaction
48      * finished pre-commit phase and will be commited.
49      * Implementation should make state, which were derived by implementation from associated data
50      * visible.
51      *
52      * @return Listenable Future which will complete once commit is finished.
53      */
54     ListenableFuture<?> commit();
55
56 }