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%2FShard.java;h=334bd8e2d2cc43de963999feb088dd872d6b5c11;hb=26a9c9959de71fc874f84ed9bf5b314ba125657c;hp=dbcbd3d02eff96f393e389d6b92ee5487b83ce18;hpb=a6af137c30470b86d4bc624d4c48cb686495a182;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index dbcbd3d02e..334bd8e2d2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -5,7 +5,6 @@ * 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.ActorRef; @@ -107,7 +106,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailed import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; -import scala.concurrent.duration.Duration; import scala.concurrent.duration.FiniteDuration; /** @@ -788,9 +786,16 @@ public class Shard extends RaftActor { } private void closeTransactionChain(final CloseTransactionChain closeTransactionChain) { - final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier(); - store.closeTransactionChain(id, null); - store.purgeTransactionChain(id, null); + if (isLeader()) { + final LocalHistoryIdentifier id = closeTransactionChain.getIdentifier(); + // FIXME: CONTROLLER-1628: stage purge once no transactions are present + store.closeTransactionChain(id, null); + store.purgeTransactionChain(id, null); + } else if (getLeader() != null) { + getLeader().forward(closeTransactionChain, getContext()); + } else { + LOG.warn("{}: Could not close transaction {}", persistenceId(), closeTransactionChain.getIdentifier()); + } } @SuppressWarnings("checkstyle:IllegalCatch") @@ -858,7 +863,7 @@ public class Shard extends RaftActor { if (txCommitTimeoutCheckSchedule == null) { // Schedule a message to be periodically sent to check if the current in-progress // transaction should be expired and aborted. - FiniteDuration period = Duration.create(transactionCommitTimeout / 3, TimeUnit.MILLISECONDS); + FiniteDuration period = FiniteDuration.create(transactionCommitTimeout / 3, TimeUnit.MILLISECONDS); txCommitTimeoutCheckSchedule = getContext().system().scheduler().schedule( period, period, getSelf(), TX_COMMIT_TIMEOUT_CHECK_MESSAGE, getContext().dispatcher(), ActorRef.noSender());