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%2FNoOpTransactionContext.java;h=2094cd2f77ff1a8399f88ce0bb4247603c484cb3;hp=84f07760f53f4a50b7fd3da61b2b3ddeb7f3fe31;hb=4379f102fa0c85abf58f60d81fec9c698582fb1a;hpb=435903c19d8b6113b7204a996ebf8d3154ccab52 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java index 84f07760f5..2094cd2f77 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/NoOpTransactionContext.java @@ -10,8 +10,9 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorSelection; import com.google.common.base.Optional; import com.google.common.util.concurrent.SettableFuture; -import java.util.concurrent.Semaphore; +import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException; import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -23,55 +24,65 @@ final class NoOpTransactionContext extends AbstractTransactionContext { private static final Logger LOG = LoggerFactory.getLogger(NoOpTransactionContext.class); private final Throwable failure; - private final Semaphore operationLimiter; - public NoOpTransactionContext(Throwable failure, TransactionIdentifier identifier, Semaphore operationLimiter) { + public NoOpTransactionContext(Throwable failure, TransactionIdentifier identifier) { super(identifier); this.failure = failure; - this.operationLimiter = operationLimiter; } @Override public void closeTransaction() { - LOG.debug("NoOpTransactionContext {} closeTransaction called", identifier); + LOG.debug("NoOpTransactionContext {} closeTransaction called", getIdentifier()); + } + + @Override + public boolean supportsDirectCommit() { + return true; + } + + @Override + public Future directCommit() { + LOG.debug("Tx {} directCommit called, failure: {}", getIdentifier(), failure); + return akka.dispatch.Futures.failed(failure); } @Override public Future readyTransaction() { - LOG.debug("Tx {} readyTransaction called", identifier); - operationLimiter.release(); + LOG.debug("Tx {} readyTransaction called, failure: {}", getIdentifier(), failure); return akka.dispatch.Futures.failed(failure); } @Override public void deleteData(YangInstanceIdentifier path) { - LOG.debug("Tx {} deleteData called path = {}", identifier, path); - operationLimiter.release(); + LOG.debug("Tx {} deleteData called path = {}", getIdentifier(), path); } @Override public void mergeData(YangInstanceIdentifier path, NormalizedNode data) { - LOG.debug("Tx {} mergeData called path = {}", identifier, path); - operationLimiter.release(); + LOG.debug("Tx {} mergeData called path = {}", getIdentifier(), path); } @Override public void writeData(YangInstanceIdentifier path, NormalizedNode data) { - LOG.debug("Tx {} writeData called path = {}", identifier, path); - operationLimiter.release(); + LOG.debug("Tx {} writeData called path = {}", getIdentifier(), path); } @Override public void readData(final YangInstanceIdentifier path, SettableFuture>> proxyFuture) { - LOG.debug("Tx {} readData called path = {}", identifier, path); - operationLimiter.release(); - proxyFuture.setException(new ReadFailedException("Error reading data for path " + path, failure)); + LOG.debug("Tx {} readData called path = {}", getIdentifier(), path); + + final Throwable t; + if (failure instanceof NoShardLeaderException) { + t = new DataStoreUnavailableException(failure.getMessage(), failure); + } else { + t = failure; + } + proxyFuture.setException(new ReadFailedException("Error reading data for path " + path, t)); } @Override public void dataExists(YangInstanceIdentifier path, SettableFuture proxyFuture) { - LOG.debug("Tx {} dataExists called path = {}", identifier, path); - operationLimiter.release(); + LOG.debug("Tx {} dataExists called path = {}", getIdentifier(), path); proxyFuture.setException(new ReadFailedException("Error checking exists for path " + path, failure)); } }