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.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
15 * User implementation of steps following pre-commit from Three-Phase Protocol.
19 public interface PostPreCommitStep extends ThreePhaseCommitStep {
22 * No-op implementation of {@link #abort()} and {@link #commit()} method, which always success
24 * This implementation is intended for users which may not need to implement commit and abort
28 PostPreCommitStep NOOP = new PostPreCommitStep() {
31 public ListenableFuture<?> abort() {
32 return ThreePhaseCommitStep.NOOP_ABORT_FUTURE;
36 public ListenableFuture<?> commit() {
37 return NOOP_COMMIT_FUTURE;
41 ListenableFuture<?> NOOP_COMMIT_FUTURE = Futures.immediateFuture(null);
43 ListenableFuture<? extends PostPreCommitStep> NOOP_FUTURE = Futures.immediateFuture(NOOP);
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
52 * @return Listenable Future which will complete once commit is finished.
54 ListenableFuture<?> commit();