Merge "Bug 2933: BidningDOMDataBrokerAdaper implements DataTreeChangeService"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / NoOpDOMStoreThreePhaseCommitCohort.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.controller.cluster.datastore;
9
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;
16
17 /**
18  * A {@link org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort}
19  * instance given out for empty transactions.
20  */
21 final class NoOpDOMStoreThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort {
22     static final NoOpDOMStoreThreePhaseCommitCohort INSTANCE = new NoOpDOMStoreThreePhaseCommitCohort();
23
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);
26
27     private NoOpDOMStoreThreePhaseCommitCohort() {
28         // Hidden to prevent instantiation
29     }
30
31     @Override
32     public ListenableFuture<Boolean> canCommit() {
33         return IMMEDIATE_BOOLEAN_SUCCESS;
34     }
35
36     @Override
37     public ListenableFuture<Void> preCommit() {
38         return IMMEDIATE_VOID_SUCCESS;
39     }
40
41     @Override
42     public ListenableFuture<Void> abort() {
43         return IMMEDIATE_VOID_SUCCESS;
44     }
45
46     @Override
47     public ListenableFuture<Void> commit() {
48         return IMMEDIATE_VOID_SUCCESS;
49     }
50
51     @Override
52     List<Future<ActorSelection>> getCohortFutures() {
53         return Collections.emptyList();
54     }
55 }