2 * Copyright (c) 2015 Brocade Communications 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.controller.cluster.datastore;
10 import com.google.common.util.concurrent.Futures;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
15 * A {@link DOMStoreThreePhaseCommitCohort} instance given out for empty transactions.
17 final class NoOpDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort {
18 static final NoOpDOMStoreThreePhaseCommitCohort INSTANCE = new NoOpDOMStoreThreePhaseCommitCohort();
20 private static final ListenableFuture<Void> IMMEDIATE_VOID_SUCCESS = Futures.immediateFuture(null);
21 private static final ListenableFuture<Boolean> IMMEDIATE_BOOLEAN_SUCCESS = Futures.immediateFuture(Boolean.TRUE);
23 private NoOpDOMStoreThreePhaseCommitCohort() {
24 // Hidden to prevent instantiation
28 public ListenableFuture<Boolean> canCommit() {
29 return IMMEDIATE_BOOLEAN_SUCCESS;
33 public ListenableFuture<Void> preCommit() {
34 return IMMEDIATE_VOID_SUCCESS;
38 public ListenableFuture<Void> abort() {
39 return IMMEDIATE_VOID_SUCCESS;
43 public ListenableFuture<Void> commit() {
44 return IMMEDIATE_VOID_SUCCESS;