From: Tom Pantelis Date: Thu, 2 Apr 2015 11:33:08 +0000 (+0000) Subject: Merge "Split out NoOpDOMStoreThreePhaseCommitCohort" X-Git-Tag: release/lithium~318 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=88158983519dc4e3ed2da18e945ae0f99039fbb4;hp=a1aa0ef4617a0caacb37a259ece3299a008a025c Merge "Split out NoOpDOMStoreThreePhaseCommitCohort" --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpDOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpDOMStoreThreePhaseCommitCohort.java new file mode 100644 index 0000000000..766cf1d578 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpDOMStoreThreePhaseCommitCohort.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015 Brocade Communications 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.datastore; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; + +/** + * A {@link DOMStoreThreePhaseCommitCohort} instance given out for empty transactions. + */ +final class NoOpDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { + static final NoOpDOMStoreThreePhaseCommitCohort INSTANCE = new NoOpDOMStoreThreePhaseCommitCohort(); + + private static final ListenableFuture IMMEDIATE_VOID_SUCCESS = Futures.immediateFuture(null); + private static final ListenableFuture IMMEDIATE_BOOLEAN_SUCCESS = Futures.immediateFuture(Boolean.TRUE); + + private NoOpDOMStoreThreePhaseCommitCohort() { + // Hidden to prevent instantiation + } + + @Override + public ListenableFuture canCommit() { + return IMMEDIATE_BOOLEAN_SUCCESS; + } + + @Override + public ListenableFuture preCommit() { + return IMMEDIATE_VOID_SUCCESS; + } + + @Override + public ListenableFuture abort() { + return IMMEDIATE_VOID_SUCCESS; + } + + @Override + public ListenableFuture commit() { + return IMMEDIATE_VOID_SUCCESS; + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java index 26523395a3..7eabf9e9a6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -18,7 +18,6 @@ import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.util.ArrayList; import java.util.Collection; @@ -764,36 +763,4 @@ public class TransactionProxy extends AbstractDOMStoreTransaction IMMEDIATE_VOID_SUCCESS = - com.google.common.util.concurrent.Futures.immediateFuture(null); - private static final ListenableFuture IMMEDIATE_BOOLEAN_SUCCESS = - com.google.common.util.concurrent.Futures.immediateFuture(Boolean.TRUE); - - private NoOpDOMStoreThreePhaseCommitCohort() { - } - - @Override - public ListenableFuture canCommit() { - return IMMEDIATE_BOOLEAN_SUCCESS; - } - - @Override - public ListenableFuture preCommit() { - return IMMEDIATE_VOID_SUCCESS; - } - - @Override - public ListenableFuture abort() { - return IMMEDIATE_VOID_SUCCESS; - } - - @Override - public ListenableFuture commit() { - return IMMEDIATE_VOID_SUCCESS; - } - } }