From 51bf6c7493843ad23f074930b56925162732a8b2 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 25 May 2017 10:18:02 -0400 Subject: [PATCH 1/1] Bug 5740: Configure control-aware mailbox Configured unit tests and production to use a control-aware mailbox for Shard actors. The current code allows for a "shard-dispatcher" to be defined so I added a section in the .conf that specifies the mailbox-type appropriately (ie UnboundedDequeBasedControlAwareMailbox). Change-Id: Ibdb404e1dfcc699471a8e899c491a09500ee04c0 Signed-off-by: Tom Pantelis --- .../AbstractRaftActorIntegrationTest.java | 4 +- .../AbstractLeaderElectionScenarioTest.java | 11 ++-- .../src/test/resources/application.conf | 13 +--- .../main/resources/initial/factory-akka.conf | 11 +++- .../src/test/resources/application.conf | 64 +++++++++++-------- 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java index 1119a3260a..5959df768f 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java @@ -16,6 +16,7 @@ import akka.actor.InvalidActorNameException; import akka.actor.PoisonPill; import akka.actor.Terminated; import akka.dispatch.Dispatchers; +import akka.dispatch.Mailboxes; import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; import akka.util.Timeout; @@ -261,7 +262,8 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest InvalidActorNameException lastEx = null; for (int i = 0; i < 10; i++) { try { - return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId()), id); + return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId()) + .withMailbox(Mailboxes.DefaultMailboxId()), id); } catch (InvalidActorNameException e) { lastEx = e; Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java index 137ea4a694..8c7c9cb7c4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java @@ -15,7 +15,9 @@ import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Props; import akka.actor.Status; +import akka.dispatch.ControlMessage; import akka.dispatch.Dispatchers; +import akka.dispatch.Mailboxes; import akka.pattern.Patterns; import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; @@ -56,7 +58,8 @@ public class AbstractLeaderElectionScenarioTest { CountDownLatch behaviorStateChangeLatch; public static Props props() { - return Props.create(MemberActor.class).withDispatcher(Dispatchers.DefaultDispatcherId()); + return Props.create(MemberActor.class).withDispatcher(Dispatchers.DefaultDispatcherId()) + .withMailbox(Mailboxes.DefaultMailboxId()); } @Override @@ -175,21 +178,21 @@ public class AbstractLeaderElectionScenarioTest { } } - static class SendImmediateHeartBeat { + static class SendImmediateHeartBeat implements ControlMessage { public static final SendImmediateHeartBeat INSTANCE = new SendImmediateHeartBeat(); private SendImmediateHeartBeat() { } } - static class GetBehaviorState { + static class GetBehaviorState implements ControlMessage { public static final GetBehaviorState INSTANCE = new GetBehaviorState(); private GetBehaviorState() { } } - static class SetBehavior { + static class SetBehavior implements ControlMessage { RaftActorBehavior behavior; MockRaftActorContext context; diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf index 8a3b3e5f31..b997326238 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf @@ -9,17 +9,8 @@ akka { # enable to test serialization only. serialize-messages = off - serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" - } - - serialization-bindings { - "org.opendaylight.controller.cluster.common.actor.Monitor" = java - "org.opendaylight.controller.cluster.raft.client.messages.FindLeader" = java - "org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry" = java - "com.google.protobuf.Message" = proto - "com.google.protobuf.GeneratedMessage" = proto + default-mailbox { + mailbox-type="org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" } } } diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf index aa689eddf2..ad18d43611 100644 --- a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf @@ -28,6 +28,15 @@ odl-cluster-data { throughput = 1 } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + + # We use a ControlAwareMailbox so that raft messages that implement ControlMessage + # are given higher priority. + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { loglevel = "INFO" loggers = ["akka.event.slf4j.Slf4jLogger"] @@ -110,4 +119,4 @@ odl-cluster-data { parallelism-max = 4 } } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf index a68a0a80d1..5e61f4defc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf @@ -5,16 +5,6 @@ akka { loggers = ["akka.testkit.TestEventListener", "akka.event.slf4j.Slf4jLogger"] actor { - serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" - } - - serialization-bindings { - "org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification" = java - "com.google.protobuf.Message" = proto - - } } } @@ -51,6 +41,12 @@ test { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -61,13 +57,10 @@ test { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } @@ -112,6 +105,12 @@ Member1 { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -122,13 +121,10 @@ Member1 { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } @@ -172,6 +168,12 @@ Member2 { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -180,13 +182,10 @@ Member2 { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } @@ -230,6 +229,12 @@ Member3 { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -240,13 +245,10 @@ Member3 { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } @@ -290,6 +292,12 @@ Member4 { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -300,13 +308,10 @@ Member4 { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } @@ -350,6 +355,12 @@ Member5 { plugin-dispatcher = "akka.persistence.dispatchers.default-plugin-dispatcher" } + shard-dispatcher { + type = Dispatcher + executor = "default-executor" + mailbox-type = "org.opendaylight.controller.cluster.common.actor.UnboundedDequeBasedControlAwareMailbox" + } + akka { persistence.snapshot-store.plugin = "in-memory-snapshot-store" persistence.journal.plugin = "in-memory-journal" @@ -360,13 +371,10 @@ Member5 { provider = "akka.cluster.ClusterActorRefProvider" serializers { - java = "akka.serialization.JavaSerializer" - proto = "akka.remote.serialization.ProtobufSerializer" readylocal = "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransactionSerializer" } serialization-bindings { - "com.google.protobuf.Message" = proto "org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction" = readylocal } } -- 2.36.6