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%2FLocalTransactionChain.java;h=c995e1150df974d7dfdd1b1c7d9dcaa589be0d14;hp=66109835a7fd5f91dce45a2593f1babe3eb53a2c;hb=HEAD;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionChain.java deleted file mode 100644 index 66109835a7..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionChain.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.cluster.datastore; - -import akka.actor.ActorSelection; -import com.google.common.base.Preconditions; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.mdsal.dom.spi.store.AbstractSnapshotBackedTransactionChain; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; -import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; - -/** - * Transaction chain instantiated on top of a locally-available DataTree. It does not instantiate - * a transaction in the leader and rather chains transactions on top of themselves. - */ -final class LocalTransactionChain extends AbstractSnapshotBackedTransactionChain - implements LocalTransactionFactory { - private static final Throwable ABORTED = new Throwable("Transaction aborted"); - private final TransactionChainProxy parent; - private final ActorSelection leader; - private final DataTree tree; - - LocalTransactionChain(final TransactionChainProxy parent, final ActorSelection leader, final DataTree tree) { - this.parent = Preconditions.checkNotNull(parent); - this.leader = Preconditions.checkNotNull(leader); - this.tree = Preconditions.checkNotNull(tree); - } - - DataTree getDataTree() { - return tree; - } - - @Override - protected TransactionIdentifier nextTransactionIdentifier() { - throw new UnsupportedOperationException(); - } - - @Override - protected boolean getDebugTransactions() { - return false; - } - - @Override - protected DataTreeSnapshot takeSnapshot() { - return tree.takeSnapshot(); - } - - @Override - protected DOMStoreThreePhaseCommitCohort createCohort( - final SnapshotBackedWriteTransaction transaction, - final DataTreeModification modification, - final Exception operationError) { - return new LocalChainThreePhaseCommitCohort(transaction, modification, operationError); - } - - @Override - public DOMStoreReadTransaction newReadOnlyTransaction(TransactionIdentifier identifier) { - return super.newReadOnlyTransaction(identifier); - } - - @Override - public DOMStoreReadWriteTransaction newReadWriteTransaction(TransactionIdentifier identifier) { - return super.newReadWriteTransaction(identifier); - } - - @Override - public DOMStoreWriteTransaction newWriteOnlyTransaction(TransactionIdentifier identifier) { - return super.newWriteOnlyTransaction(identifier); - } - - @SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"}) - @Override - public LocalThreePhaseCommitCohort onTransactionReady(@Nonnull DOMStoreWriteTransaction tx, - @Nullable Exception operationError) { - Preconditions.checkArgument(tx instanceof SnapshotBackedWriteTransaction); - if (operationError != null) { - return new LocalChainThreePhaseCommitCohort((SnapshotBackedWriteTransaction)tx, - operationError); - } - - try { - return (LocalThreePhaseCommitCohort) tx.ready(); - } catch (Exception e) { - // Unfortunately we need to cast to SnapshotBackedWriteTransaction here as it's required by - // LocalThreePhaseCommitCohort and the base class. - return new LocalChainThreePhaseCommitCohort((SnapshotBackedWriteTransaction)tx, e); - } - } - - private class LocalChainThreePhaseCommitCohort extends LocalThreePhaseCommitCohort { - - protected LocalChainThreePhaseCommitCohort(SnapshotBackedWriteTransaction transaction, - DataTreeModification modification, Exception operationError) { - super(parent.getActorUtils(), leader, transaction, modification, operationError); - } - - protected LocalChainThreePhaseCommitCohort(SnapshotBackedWriteTransaction transaction, - Exception operationError) { - super(parent.getActorUtils(), leader, transaction, operationError); - } - - @Override - protected void transactionAborted(SnapshotBackedWriteTransaction transaction) { - onTransactionFailed(transaction, ABORTED); - } - - @Override - protected void transactionCommitted(SnapshotBackedWriteTransaction transaction) { - onTransactionCommited(transaction); - } - } -}