X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardDataTreeTransactionChain.java;h=a774d647d3d6c6e8cbecea7eb1b91b5ccfe0e6df;hb=5dbaf1259ead1904536db204bbc742a3359c1eb1;hp=312e11290c88e713827fe2b051d96b667eb633da;hpb=db9a673c114febc785fbd324947ac2c3e3095d06;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java index 312e11290c..a774d647d3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeTransactionChain.java @@ -9,6 +9,8 @@ package org.opendaylight.controller.cluster.datastore; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; +import java.util.Optional; +import java.util.SortedSet; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; @@ -24,6 +26,7 @@ import org.slf4j.LoggerFactory; @NotThreadSafe final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent implements Identifiable { + private static final Logger LOG = LoggerFactory.getLogger(ShardDataTreeTransactionChain.class); private final LocalHistoryIdentifier chainId; private final ShardDataTree dataTree; @@ -54,7 +57,7 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent final DataTreeSnapshot snapshot = getSnapshot(); LOG.debug("Allocated read-only transaction {} snapshot {}", txId, snapshot); - return new ReadOnlyShardDataTreeTransaction(txId, snapshot); + return new ReadOnlyShardDataTreeTransaction(this, txId, snapshot); } ReadWriteShardDataTreeTransaction newReadWriteTransaction(final TransactionIdentifier txId) { @@ -67,26 +70,34 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent void close() { closed = true; + LOG.debug("Closing chain {}", chainId); } @Override - protected void abortTransaction(final AbstractShardDataTreeTransaction transaction) { + void abortFromTransactionActor(final AbstractShardDataTreeTransaction transaction) { if (transaction instanceof ReadWriteShardDataTreeTransaction) { Preconditions.checkState(openTransaction != null, "Attempted to abort transaction %s while none is outstanding", transaction); - LOG.debug("Aborted transaction {}", transaction); + LOG.debug("Aborted open transaction {}", transaction); openTransaction = null; } } @Override - protected ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction) { + void abortTransaction(final AbstractShardDataTreeTransaction transaction, final Runnable callback) { + abortFromTransactionActor(transaction); + dataTree.abortTransaction(transaction, callback); + } + + @Override + ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction, + final Optional> participatingShardNames) { Preconditions.checkState(openTransaction != null, "Attempted to finish transaction %s while none is outstanding", transaction); // dataTree is finalizing ready the transaction, we just record it for the next // transaction in chain - final ShardDataTreeCohort delegate = dataTree.finishTransaction(transaction); + final ShardDataTreeCohort delegate = dataTree.finishTransaction(transaction, participatingShardNames); openTransaction = null; previousTx = transaction; LOG.debug("Committing transaction {}", transaction); @@ -111,7 +122,14 @@ final class ShardDataTreeTransactionChain extends ShardDataTreeTransactionParent } @Override - ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId, final DataTreeModification modification) { - return dataTree.createReadyCohort(txId, modification); + ShardDataTreeCohort createFailedCohort(final TransactionIdentifier txId, final DataTreeModification mod, + final Exception failure) { + return dataTree.createFailedCohort(txId, mod, failure); + } + + @Override + ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId, final DataTreeModification mod, + final Optional> participatingShardNames) { + return dataTree.createReadyCohort(txId, mod, participatingShardNames); } }