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 com.google.common.util.concurrent.Futures;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
13
14 /**
15  * A {@link DOMStoreThreePhaseCommitCohort} instance given out for empty transactions.
16  */
17 final class NoOpDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort {
18     static final NoOpDOMStoreThreePhaseCommitCohort INSTANCE = new NoOpDOMStoreThreePhaseCommitCohort();
19
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);
22
23     private NoOpDOMStoreThreePhaseCommitCohort() {
24         // Hidden to prevent instantiation
25     }
26
27     @Override
28     public ListenableFuture<Boolean> canCommit() {
29         return IMMEDIATE_BOOLEAN_SUCCESS;
30     }
31
32     @Override
33     public ListenableFuture<Void> preCommit() {
34         return IMMEDIATE_VOID_SUCCESS;
35     }
36
37     @Override
38     public ListenableFuture<Void> abort() {
39         return IMMEDIATE_VOID_SUCCESS;
40     }
41
42     @Override
43     public ListenableFuture<Void> commit() {
44         return IMMEDIATE_VOID_SUCCESS;
45     }
46 }