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 akka.actor.ActorSelection;
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.Collections;
14 import java.util.List;
15 import scala.concurrent.Future;
18 * A {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort}
19 * instance given out for empty transactions.
21 final class NoOpDOMStoreThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort {
22 static final NoOpDOMStoreThreePhaseCommitCohort INSTANCE = new NoOpDOMStoreThreePhaseCommitCohort();
24 private static final ListenableFuture<Void> IMMEDIATE_VOID_SUCCESS = Futures.immediateFuture(null);
25 private static final ListenableFuture<Boolean> IMMEDIATE_BOOLEAN_SUCCESS = Futures.immediateFuture(Boolean.TRUE);
27 private NoOpDOMStoreThreePhaseCommitCohort() {
28 // Hidden to prevent instantiation
32 public ListenableFuture<Boolean> canCommit() {
33 return IMMEDIATE_BOOLEAN_SUCCESS;
37 public ListenableFuture<Void> preCommit() {
38 return IMMEDIATE_VOID_SUCCESS;
42 public ListenableFuture<Void> abort() {
43 return IMMEDIATE_VOID_SUCCESS;
47 public ListenableFuture<Void> commit() {
48 return IMMEDIATE_VOID_SUCCESS;
52 List<Future<ActorSelection>> getCohortFutures() {
53 return Collections.emptyList();