BUG-5280: implement transaction dispatch
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / DirectTransactionCommitCohort.java
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DirectTransactionCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DirectTransactionCommitCohort.java
new file mode 100644 (file)
index 0000000..007ac53
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.databroker.actors.dds;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * An {@link AbstractTransactionCommitCohort} implementation for transactions which contain a single proxy. Since there
+ * is only one proxy,
+ *
+ * @author Robert Varga
+ */
+final class DirectTransactionCommitCohort extends AbstractTransactionCommitCohort {
+    private final AbstractProxyTransaction proxy;
+
+    /**
+     * @param clientTransaction
+     */
+    DirectTransactionCommitCohort(final AbstractProxyTransaction proxy) {
+        this.proxy = Preconditions.checkNotNull(proxy);
+    }
+
+    @Override
+    public ListenableFuture<Boolean> canCommit() {
+        return proxy.directCommit();
+    }
+
+    @Override
+    public ListenableFuture<Void> preCommit() {
+        return VOID_FUTURE;
+    }
+
+    @Override
+    public ListenableFuture<Void> abort() {
+        return VOID_FUTURE;
+    }
+
+    @Override
+    public ListenableFuture<Void> commit() {
+        return VOID_FUTURE;
+    }
+}