Bug 5740: Configure control-aware mailbox 19/57819/5
authorTom Pantelis <tompantelis@gmail.com>
Thu, 25 May 2017 14:18:02 +0000 (10:18 -0400)
committerRobert Varga <nite@hq.sk>
Mon, 5 Jun 2017 14:57:51 +0000 (14:57 +0000)
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 <tompantelis@gmail.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/resources/application.conf
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf

index 1119a32..5959df7 100644 (file)
@@ -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);
index 137ea4a..8c7c9cb 100644 (file)
@@ -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;
 
index 8a3b3e5..b997326 100644 (file)
@@ -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"
         }
     }
 }
index aa689ed..ad18d43 100644 (file)
@@ -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
+}
index a68a0a8..5e61f4d 100644 (file)
@@ -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
       }
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.