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 1119a3260a140888b0645040b66aaa8f65f65d99..5959df768fc6bd3359edfef777331b8bbcc9bb24 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 137ea4a694891eb46292e4ddb6a99aad54e3b657..8c7c9cb7c4a3ed640d5d04c0a58534a99a819abb 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 8a3b3e5f317c1a527215d843e180ec60734d72b8..b997326238b91e76c0cd2e6b19c60f14dd889de0 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 aa689eddf20408af22793a6e70fcf76dca786090..ad18d436118db4e1d69ad570bbcd85ca4341c3ef 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 a68a0a80d1a56748156f23fe1fa1a8c07eac3e40..5e61f4defca9727417cc186a940fda4ea0f18fdf 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
       }
     }