From 7011afc1380ca25ad3de4cc8865f12fe3f5e09cf Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Tue, 14 May 2019 12:56:04 +0200 Subject: [PATCH] Remove PersistAbortTransactionPayload With the metadata tracking disabled for ask based protocol there is no need to track aborts for read only transactions on the backend. JIRA: CONTROLLER-1879 Change-Id: I189ae3231bb2f3c0eaa0bbe21a14342446708c5f Signed-off-by: Tomas Cere --- .../admin/ClusterAdminRpcServiceTest.java | 4 +-- .../cluster/datastore/FrontendMetadata.java | 5 ++- .../controller/cluster/datastore/Shard.java | 28 ++++++++------- .../cluster/datastore/ShardTransaction.java | 2 -- .../PersistAbortTransactionPayload.java | 35 ------------------- ...butedDataStoreRemotingIntegrationTest.java | 4 +-- .../cluster/datastore/ShardTest.java | 7 ++-- 7 files changed, 26 insertions(+), 59 deletions(-) delete mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PersistAbortTransactionPayload.java diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java b/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java index b87c07e186..a29df3f4b6 100644 --- a/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java +++ b/opendaylight/md-sal/sal-cluster-admin-impl/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java @@ -389,8 +389,8 @@ public class ClusterAdminRpcServiceTest { // 2 ServerConfigurationPayload entries, the transaction payload entry plus a purge payload. RaftStateVerifier verifier = raftState -> { - assertEquals("Commit index", 3, raftState.getCommitIndex()); - assertEquals("Last applied index", 3, raftState.getLastApplied()); + assertEquals("Commit index", 5, raftState.getCommitIndex()); + assertEquals("Last applied index", 5, raftState.getLastApplied()); }; verifyRaftState(leaderNode1.configDataStore(), "cars", verifier); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java index f651efa3fa..efb0fdc04b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendMetadata.java @@ -132,7 +132,10 @@ final class FrontendMetadata extends ShardDataTreeMetadata(); + } + knownFrontends.put(frontend, new LeaderFrontendState.Disabled(persistenceId(), clientId, getDataStore())); + persistPayload(clientId, DisableTrackingPayload.create(clientId, datastoreContext.getInitialPayloadSerializedBufferCapacity()), false); } @@ -1032,8 +1032,10 @@ public class Shard extends RaftActor { paused = true; // Tell-based protocol can replay transaction state, so it is safe to blow it up when we are paused. - knownFrontends.values().forEach(LeaderFrontendState::retire); - knownFrontends = ImmutableMap.of(); + if (datastoreContext.isUseTellBasedProtocol()) { + knownFrontends.values().forEach(LeaderFrontendState::retire); + knownFrontends = ImmutableMap.of(); + } store.setRunOnPendingTransactionsComplete(operation); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java index 8961a1a755..87dd5e3e26 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java @@ -22,7 +22,6 @@ import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.DataExists; import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply; -import org.opendaylight.controller.cluster.datastore.messages.PersistAbortTransactionPayload; import org.opendaylight.controller.cluster.datastore.messages.ReadData; import org.opendaylight.controller.cluster.datastore.messages.ReadDataReply; import org.opendaylight.mdsal.common.api.ReadFailedException; @@ -78,7 +77,6 @@ public abstract class ShardTransaction extends AbstractUntypedActorWithMetering private void closeTransaction(final boolean sendReply) { getDOMStoreTransaction().abortFromTransactionActor(); - shardActor.tell(new PersistAbortTransactionPayload(transactionId), ActorRef.noSender()); if (sendReply && returnCloseTransactionReply()) { getSender().tell(new CloseTransactionReply(), getSelf()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PersistAbortTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PersistAbortTransactionPayload.java deleted file mode 100644 index b581ddb9af..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/PersistAbortTransactionPayload.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017 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.messages; - -import com.google.common.base.Preconditions; -import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; - -/** - * A request sent from {@link org.opendaylight.controller.cluster.datastore.ShardTransaction} to - * {@link org.opendaylight.controller.cluster.datastore.Shard} to persist an - * {@link org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload} after the transaction has - * been closed by the frontend and internal backend state has been updated. - * - *

- * Since the two are actors, we cannot perform a direct upcall, as that breaks actor containment and wreaks havoc into - * Akka itself. This class does not need to be serializable, as both actors are guaranteed to be co-located. - * - * @author Robert Varga - */ -public final class PersistAbortTransactionPayload { - private final TransactionIdentifier txId; - - public PersistAbortTransactionPayload(final TransactionIdentifier txId) { - this.txId = Preconditions.checkNotNull(txId); - } - - public TransactionIdentifier getTransactionId() { - return txId; - } -} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java index 3943e7ee56..4028510224 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java @@ -787,10 +787,10 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { // Wait for the commit to be replicated to the follower. MemberNode.verifyRaftState(followerDistributedDataStore, "cars", - raftState -> assertEquals("getLastApplied", 1, raftState.getLastApplied())); + raftState -> assertEquals("getLastApplied", 2, raftState.getLastApplied())); MemberNode.verifyRaftState(followerDistributedDataStore, "people", - raftState -> assertEquals("getLastApplied", 1, raftState.getLastApplied())); + raftState -> assertEquals("getLastApplied", 2, raftState.getLastApplied())); // Prepare, ready and canCommit a WO tx that writes to 2 shards. This will become the current tx in // the leader shard. diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index b3e8de2d9b..9d4381e145 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -551,7 +551,7 @@ public class ShardTest extends AbstractShardTest { verifyOuterListEntry(shard, 1); - verifyLastApplied(shard, 5); + verifyLastApplied(shard, 6); } @Test @@ -1026,9 +1026,8 @@ public class ShardTest extends AbstractShardTest { // Committed transaction count should increase as usual assertEquals(1, shardStats.getCommittedTransactionsCount()); - // Commit index should advance as we do not have an empty - // modification - assertEquals(1, shardStats.getCommitIndex()); + // Commit index should advance 2 to account for disabling metadata + assertEquals(2, shardStats.getCommitIndex()); } @Test -- 2.36.6