From: Tom Pantelis Date: Thu, 2 Apr 2015 11:30:14 +0000 (+0000) Subject: Merge "Speed up enumeration lookups" X-Git-Tag: release/lithium~320 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e243b5a0744f519a047d226a83fc1234c86de0de;hp=f97618f25dfc073d1de5d883f1794eefdb3e5c16 Merge "Speed up enumeration lookups" --- diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java new file mode 100644 index 0000000000..4c817dd73d --- /dev/null +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/ForwardingDOMStoreThreePhaseCommitCohort.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 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.sal.core.spi.data; + +import com.google.common.annotations.Beta; +import com.google.common.collect.ForwardingObject; +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Abstract base class for {@link DOMStoreThreePhaseCommitCohort} implementations, + * which forward most of their functionality to a backend {@link #delegate()}. + */ +@Beta +public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject implements DOMStoreThreePhaseCommitCohort { + @Override + protected abstract DOMStoreThreePhaseCommitCohort delegate(); + + @Override + public ListenableFuture canCommit() { + return delegate().canCommit(); + } + + @Override + public ListenableFuture preCommit() { + return delegate().preCommit(); + } + + @Override + public ListenableFuture abort() { + return delegate().abort(); + } + + @Override + public ListenableFuture commit() { + return delegate().commit(); + } +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChainedTransactionCommitImpl.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChainedTransactionCommitImpl.java index 5b0f739428..05e3d5cb26 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChainedTransactionCommitImpl.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChainedTransactionCommitImpl.java @@ -12,13 +12,14 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.ForwardingDOMStoreThreePhaseCommitCohort; -final class ChainedTransactionCommitImpl implements DOMStoreThreePhaseCommitCohort { +final class ChainedTransactionCommitImpl extends ForwardingDOMStoreThreePhaseCommitCohort { private final SnapshotBackedWriteTransaction transaction; private final DOMStoreThreePhaseCommitCohort delegate; private final DOMStoreTransactionChainImpl txChain; - protected ChainedTransactionCommitImpl(final SnapshotBackedWriteTransaction transaction, + ChainedTransactionCommitImpl(final SnapshotBackedWriteTransaction transaction, final DOMStoreThreePhaseCommitCohort delegate, final DOMStoreTransactionChainImpl txChain) { this.transaction = Preconditions.checkNotNull(transaction); this.delegate = Preconditions.checkNotNull(delegate); @@ -26,23 +27,13 @@ final class ChainedTransactionCommitImpl implements DOMStoreThreePhaseCommitCoho } @Override - public ListenableFuture canCommit() { - return delegate.canCommit(); - } - - @Override - public ListenableFuture preCommit() { - return delegate.preCommit(); - } - - @Override - public ListenableFuture abort() { - return delegate.abort(); + protected DOMStoreThreePhaseCommitCohort delegate() { + return delegate; } @Override public ListenableFuture commit() { - ListenableFuture commitFuture = delegate.commit(); + ListenableFuture commitFuture = super.commit(); Futures.addCallback(commitFuture, new FutureCallback() { @Override public void onFailure(final Throwable t) { @@ -56,4 +47,5 @@ final class ChainedTransactionCommitImpl implements DOMStoreThreePhaseCommitCoho }); return commitFuture; } + } \ No newline at end of file