49b281aa3a511bef3b56811ea2f73da2e9a0a443
[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
13 /**
14  * An {@link AbstractTransactionCommitCohort} implementation for transactions which contain a single proxy. Since there
15  * is only one proxy,
16  *
17  * @author Robert Varga
18  */
19 final class DirectTransactionCommitCohort extends AbstractTransactionCommitCohort {
20     private final AbstractProxyTransaction proxy;
21
22     DirectTransactionCommitCohort(final AbstractProxyTransaction proxy) {
23         this.proxy = Preconditions.checkNotNull(proxy);
24     }
25
26     @Override
27     public ListenableFuture<Boolean> canCommit() {
28         return proxy.directCommit();
29     }
30
31     @Override
32     public ListenableFuture<Void> preCommit() {
33         return VOID_FUTURE;
34     }
35
36     @Override
37     public ListenableFuture<Void> abort() {
38         return VOID_FUTURE;
39     }
40
41     @Override
42     public ListenableFuture<Void> commit() {
43         return VOID_FUTURE;
44     }
45 }