Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / EmptyTransactionCommitCohort.java
1 /*
2  * Copyright (c) 2016 Cisco 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.databroker.actors.dds;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
12
13 /**
14  * An {@link AbstractTransactionCommitCohort} for use with empty transactions. This relies on the fact that no backends
15  * have been touched, hence all state book-keeping needs to happen only locally and shares fate with the coordinator.
16  *
17  * <p>
18  * Therefore all methods can finish immediately without any effects.
19  *
20  * @author Robert Varga
21  */
22 final class EmptyTransactionCommitCohort extends AbstractTransactionCommitCohort {
23     EmptyTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId) {
24         super(parent, txId);
25     }
26
27     @Override
28     public ListenableFuture<Boolean> canCommit() {
29         return TRUE_FUTURE;
30     }
31
32     @Override
33     public ListenableFuture<Void> preCommit() {
34         return VOID_FUTURE;
35     }
36
37     @Override
38     public ListenableFuture<Void> abort() {
39         complete();
40         return VOID_FUTURE;
41     }
42
43     @Override
44     public ListenableFuture<Void> commit() {
45         complete();
46         return VOID_FUTURE;
47     }
48 }