BUG-5280: move transactions keeping to history
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / DirectTransactionCommitCohort.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.base.Preconditions;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
13
14 /**
15  * An {@link AbstractTransactionCommitCohort} implementation for transactions which contain a single proxy. Since there
16  * is only one proxy,
17  *
18  * @author Robert Varga
19  */
20 final class DirectTransactionCommitCohort extends AbstractTransactionCommitCohort {
21     private final AbstractProxyTransaction proxy;
22
23     DirectTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId,
24         final AbstractProxyTransaction proxy) {
25         super(parent, txId);
26         this.proxy = Preconditions.checkNotNull(proxy);
27     }
28
29     @Override
30     public ListenableFuture<Boolean> canCommit() {
31         return proxy.directCommit();
32     }
33
34     @Override
35     public ListenableFuture<Void> preCommit() {
36         return VOID_FUTURE;
37     }
38
39     @Override
40     public ListenableFuture<Void> abort() {
41         complete();
42         return VOID_FUTURE;
43     }
44
45     @Override
46     public ListenableFuture<Void> commit() {
47         complete();
48         return VOID_FUTURE;
49     }
50 }