2 * Copyright (c) 2015 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.mdsal.common.api;
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;
16 * User implementation of steps following pre-commit from Three-Phase Protocol.
19 public interface PostPreCommitStep extends ThreePhaseCommitStep {
21 * No-op implementation of {@link #abort()} and {@link #commit()} method, which always success
23 * This implementation is intended for users which may not need to implement commit and abort
27 PostPreCommitStep NOOP = new PostPreCommitStep() {
30 public ListenableFuture<?> abort() {
31 return ThreePhaseCommitStep.NOOP_ABORT_FUTURE;
35 public ListenableFuture<?> commit() {
36 return NOOP_COMMIT_FUTURE;
40 @NonNull ListenableFuture<?> NOOP_COMMIT_FUTURE = FluentFutures.immediateNullFluentFuture();
42 @NonNull ListenableFuture<? extends PostPreCommitStep> NOOP_FUTURE = FluentFutures.immediateFluentFuture(NOOP);
45 * Commits cohort transaction.
46 * This callback is invoked by three-phase commit coordinator if associated data transaction
47 * finished pre-commit phase and will be commited.
48 * Implementation should make state, which were derived by implementation from associated data
51 * @return Listenable Future which will complete once commit is finished.
53 @NonNull ListenableFuture<?> commit();