#2136 - Making it possible to use balancing dispatcher for routees but not routers, changing the docs and updating the tests

This commit is contained in:
Viktor Klang 2012-05-25 17:42:12 +02:00
parent 52875d3586
commit 021d7fcfeb
6 changed files with 13 additions and 13 deletions

View file

@ -42,27 +42,27 @@ class ActorConfigurationVerificationSpec extends AkkaSpec(ActorConfigurationVeri
"An Actor configured with a BalancingDispatcher" must { "An Actor configured with a BalancingDispatcher" must {
"fail verification with a ConfigurationException if also configured with a RoundRobinRouter" in { "fail verification with a ConfigurationException if also configured with a RoundRobinRouter" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher").withRouter(RoundRobinRouter(2))) system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(2).withDispatcher("balancing-dispatcher")))
} }
} }
"fail verification with a ConfigurationException if also configured with a BroadcastRouter" in { "fail verification with a ConfigurationException if also configured with a BroadcastRouter" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher").withRouter(BroadcastRouter(2))) system.actorOf(Props[TestActor].withRouter(BroadcastRouter(2).withDispatcher("balancing-dispatcher")))
} }
} }
"fail verification with a ConfigurationException if also configured with a RandomRouter" in { "fail verification with a ConfigurationException if also configured with a RandomRouter" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher").withRouter(RandomRouter(2))) system.actorOf(Props[TestActor].withRouter(RandomRouter(2).withDispatcher("balancing-dispatcher")))
} }
} }
"fail verification with a ConfigurationException if also configured with a SmallestMailboxRouter" in { "fail verification with a ConfigurationException if also configured with a SmallestMailboxRouter" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher").withRouter(SmallestMailboxRouter(2))) system.actorOf(Props[TestActor].withRouter(SmallestMailboxRouter(2).withDispatcher("balancing-dispatcher")))
} }
} }
"fail verification with a ConfigurationException if also configured with a ScatterGatherFirstCompletedRouter" in { "fail verification with a ConfigurationException if also configured with a ScatterGatherFirstCompletedRouter" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher").withRouter(ScatterGatherFirstCompletedRouter(nrOfInstances = 2, within = 2 seconds))) system.actorOf(Props[TestActor].withRouter(ScatterGatherFirstCompletedRouter(nrOfInstances = 2, within = 2 seconds).withDispatcher("balancing-dispatcher")))
} }
} }
"not fail verification with a ConfigurationException also not configured with a Router" in { "not fail verification with a ConfigurationException also not configured with a Router" in {

View file

@ -30,7 +30,7 @@ private[akka] class RoutedActorRef(_system: ActorSystemImpl, _props: Props, _sup
_path) { _path) {
// verify that a BalancingDispatcher is not used with a Router // verify that a BalancingDispatcher is not used with a Router
if (_system.dispatchers.isBalancingDispatcher(_props.dispatcher) && _props.routerConfig != NoRouter) if (_props.routerConfig != NoRouter && _system.dispatchers.isBalancingDispatcher(_props.routerConfig.routerDispatcher))
throw new ConfigurationException( throw new ConfigurationException(
"Configuration for actor [" + _path.toString + "Configuration for actor [" + _path.toString +
"] is invalid - you can not use a 'BalancingDispatcher' together with any type of 'Router'") "] is invalid - you can not use a 'BalancingDispatcher' together with any type of 'Router'")

View file

@ -85,7 +85,7 @@ There are 4 different types of message dispatchers:
"thread-pool-executor" or the FQCN of "thread-pool-executor" or the FQCN of
an ``akka.dispatcher.ExecutorServiceConfigurator`` an ``akka.dispatcher.ExecutorServiceConfigurator``
- Note that you can **not** use a ``BalancingDispatcher`` together with any kind of ``Router``, trying to do so will make your actor fail verification. - Note that you can **not** use a ``BalancingDispatcher`` as a **Router Dispatcher**. (You can however use it for the **Routees**)
* CallingThreadDispatcher * CallingThreadDispatcher

View file

@ -380,8 +380,8 @@ The dispatcher for created children of the router will be taken from
makes sense to configure the :class:`BalancingDispatcher` if the precise makes sense to configure the :class:`BalancingDispatcher` if the precise
routing is not so important (i.e. no consistent hashing or round-robin is routing is not so important (i.e. no consistent hashing or round-robin is
required); this enables newly created routees to pick up work immediately by required); this enables newly created routees to pick up work immediately by
stealing it from their siblings. Note that you can **not** use a ``BalancingDispatcher`` stealing it from their siblings. Note that you can **not** use a ``BalancingDispatcher`` as a **Router Dispatcher**.
together with any kind of ``Router``, trying to do so will make your actor fail verification. (You can however use it for the **Routees**)
The “head” router, of course, cannot run on the same balancing dispatcher, The “head” router, of course, cannot run on the same balancing dispatcher,
because it does not process the same messages, hence this special actor does because it does not process the same messages, hence this special actor does

View file

@ -86,7 +86,7 @@ There are 4 different types of message dispatchers:
"thread-pool-executor" or the FQCN of "thread-pool-executor" or the FQCN of
an ``akka.dispatcher.ExecutorServiceConfigurator`` an ``akka.dispatcher.ExecutorServiceConfigurator``
- Note that you can **not** use a ``BalancingDispatcher`` together with any kind of ``Router``, trying to do so will make your actor fail verification. - Note that you can **not** use a ``BalancingDispatcher`` as a **Router Dispatcher**. (You can however use it for the **Routees**)
* CallingThreadDispatcher * CallingThreadDispatcher
@ -114,7 +114,7 @@ And then using it:
.. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#defining-pinned-dispatcher .. includecode:: ../scala/code/docs/dispatcher/DispatcherDocSpec.scala#defining-pinned-dispatcher
Note that ``thread-pool-executor`` configuration as per the above ``my-thread-pool-dispatcher`` exmaple is Note that ``thread-pool-executor`` configuration as per the above ``my-thread-pool-dispatcher`` example is
NOT applicable. This is because every actor will have its own thread pool when using ``PinnedDispatcher``, NOT applicable. This is because every actor will have its own thread pool when using ``PinnedDispatcher``,
and that pool will have only one thread. and that pool will have only one thread.

View file

@ -380,8 +380,8 @@ The dispatcher for created children of the router will be taken from
makes sense to configure the :class:`BalancingDispatcher` if the precise makes sense to configure the :class:`BalancingDispatcher` if the precise
routing is not so important (i.e. no consistent hashing or round-robin is routing is not so important (i.e. no consistent hashing or round-robin is
required); this enables newly created routees to pick up work immediately by required); this enables newly created routees to pick up work immediately by
stealing it from their siblings. Note that you can **not** use a ``BalancingDispatcher`` stealing it from their siblings. Note that you can **not** use a ``BalancingDispatcher`` as a **Router Dispatcher**.
together with any kind of ``Router``, trying to do so will make your actor fail verification. (You can however use it for the **Routees**)
.. note:: .. note::