Enable spotbugs in mdsal-{common,binding,dom}-api
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / ThreePhaseCommitStep.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.ListenableFuture;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
14
15 /**
16  * Common interface for implementing three-phase commit steps.
17  * Actual steps to be implemented are: {@link PostCanCommitStep} and {@link PostPreCommitStep} which
18  * allows to customize pre-commit, commit and abort actions.
19  *
20  */
21 @Beta
22 public interface ThreePhaseCommitStep {
23     @NonNull ListenableFuture<?> NOOP_ABORT_FUTURE = FluentFutures.immediateNullFluentFuture();
24
25     /**
26      * Invoked on transaction aborted.
27      * This callback is invoked by three-phase commit coordinator if associated data transaction
28      * will not be commited and is being aborted.
29      * Implementation MUST rollback any changes, which were introduced by implementation based on
30      * supplied data.
31      *
32      * @return ListenableFuture which will complete once abort is completed.
33      */
34     @NonNull ListenableFuture<?> abort();
35 }