X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FLocalTransactionContext.java;h=5435bb548d5c58e91e2f20d07dc7895f97755df8;hp=9cf5312c1efccb687a87b05c96612e39d8344a39;hb=HEAD;hpb=461173ce10acbd8597b8f4c6ccb6c98c7a99447c diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java deleted file mode 100644 index 9cf5312c1e..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 akka.actor.ActorSelection; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.controller.cluster.datastore.messages.AbstractRead; -import org.opendaylight.controller.cluster.datastore.modification.AbstractModification; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; -import scala.concurrent.Future; - -/** - * Processes front-end transaction operations locally before being committed to the destination shard. - * Instances of this class are used when the destination shard is local to the caller. - * - * @author Thomas Pantelis - */ -abstract class LocalTransactionContext extends AbstractTransactionContext { - private final DOMStoreTransaction txDelegate; - private final LocalTransactionReadySupport readySupport; - private Exception operationError; - - LocalTransactionContext(final DOMStoreTransaction txDelegate, final TransactionIdentifier identifier, - final LocalTransactionReadySupport readySupport) { - super(identifier); - this.txDelegate = Preconditions.checkNotNull(txDelegate); - this.readySupport = readySupport; - } - - protected abstract DOMStoreWriteTransaction getWriteDelegate(); - - protected abstract DOMStoreReadTransaction getReadDelegate(); - - @Override - @SuppressWarnings("checkstyle:IllegalCatch") - public void executeModification(final AbstractModification modification, final Boolean havePermit) { - incrementModificationCount(); - if (operationError == null) { - try { - modification.apply(getWriteDelegate()); - } catch (Exception e) { - operationError = e; - } - } - } - - @Override - public void executeRead(final AbstractRead readCmd, final SettableFuture proxyFuture, - final Boolean havePermit) { - Futures.addCallback(readCmd.apply(getReadDelegate()), new FutureCallback() { - @Override - public void onSuccess(final T result) { - proxyFuture.set(result); - } - - @Override - public void onFailure(final Throwable failure) { - proxyFuture.setException(failure); - } - }, MoreExecutors.directExecutor()); - } - - private LocalThreePhaseCommitCohort ready() { - logModificationCount(); - return readySupport.onTransactionReady(getWriteDelegate(), operationError); - } - - @Override - public Future readyTransaction(final Boolean havePermit) { - final LocalThreePhaseCommitCohort cohort = ready(); - return cohort.initiateCoordinatedCommit(); - } - - @Override - public Future directCommit(final Boolean havePermit) { - final LocalThreePhaseCommitCohort cohort = ready(); - return cohort.initiateDirectCommit(); - } - - @Override - public void closeTransaction() { - txDelegate.close(); - } -}