Merge pull request #1776 from akka/wip-3663-balancing-disp-patriknw
+act #3663 Package BalancingDispatcher for usage in router pool
This commit is contained in:
commit
d4cce379ce
22 changed files with 140 additions and 47 deletions
|
|
@ -140,8 +140,19 @@ akka.actor.deployment {
|
|||
}
|
||||
#//#config-resize-pool
|
||||
|
||||
#//#config-pool-dispatcher
|
||||
akka.actor.deployment {
|
||||
/poolWithDispatcher {
|
||||
router = random-pool
|
||||
nr-of-instances = 5
|
||||
pool-dispatcher {
|
||||
type = BalancingDispatcher
|
||||
}
|
||||
}
|
||||
}
|
||||
#//#config-pool-dispatcher
|
||||
|
||||
router-dispatcher {}
|
||||
workers-dispatcher {}
|
||||
"""
|
||||
|
||||
case class Work(payload: String)
|
||||
|
|
@ -351,10 +362,10 @@ class RouterDocSpec extends AkkaSpec(RouterDocSpec.config) with ImplicitSender {
|
|||
"demonstrate dispatcher" in {
|
||||
//#dispatchers
|
||||
val router: ActorRef = system.actorOf(
|
||||
// “head” will run on "router-dispatcher" dispatcher
|
||||
RoundRobinPool(5, routerDispatcher = "router-dispatcher").props(Props[Worker])
|
||||
// Worker routees will run on "workers-dispatcher" dispatcher
|
||||
.withDispatcher("workers-dispatcher"))
|
||||
// “head” router actor will run on "router-dispatcher" dispatcher
|
||||
// Worker routees will run on "pool-dispatcher" dispatcher
|
||||
RandomPool(5, routerDispatcher = "router-dispatcher").props(Props[Worker]),
|
||||
name = "poolWithDispatcher")
|
||||
//#dispatchers
|
||||
}
|
||||
|
||||
|
|
@ -410,8 +421,8 @@ class RouterDocSpec extends AkkaSpec(RouterDocSpec.config) with ImplicitSender {
|
|||
import akka.actor.{ Address, AddressFromURIString }
|
||||
import akka.remote.routing.RemoteRouterConfig
|
||||
val addresses = Seq(
|
||||
Address("akka", "remotesys", "otherhost", 1234),
|
||||
AddressFromURIString("akka://othersys@anotherhost:1234"))
|
||||
Address("akka.tcp", "remotesys", "otherhost", 1234),
|
||||
AddressFromURIString("akka.tcp://othersys@anotherhost:1234"))
|
||||
val routerRemote = system.actorOf(
|
||||
RemoteRouterConfig(RoundRobinPool(5), addresses).props(Props[Echo]))
|
||||
//#remoteRoutees
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ Once a connection has been established data can be sent to it from any actor in
|
|||
|
||||
Tcp.Write
|
||||
The simplest ``WriteCommand`` implementation which wraps a ``ByteString`` instance and an "ack" event.
|
||||
A ``ByteString`` (as explained in :ref:`this section <ByteString>`) models one or more chunks of immutable
|
||||
A ``ByteString`` (as explained in :ref:`this section <bytestring_scala>`) models one or more chunks of immutable
|
||||
in-memory data with a maximum (total) size of 2 GB (2^31 bytes).
|
||||
|
||||
Tcp.WriteFile
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ nacked messages it may need to keep a buffer of pending messages.
|
|||
the I/O driver has successfully processed the write. The Ack/Nack protocol described here is a means of flow control
|
||||
not error handling. In other words, data may still be lost, even if every write is acknowledged.
|
||||
|
||||
.. _ByteString:
|
||||
.. _bytestring_scala:
|
||||
|
||||
ByteString
|
||||
^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -626,16 +626,24 @@ The deployment section of the configuration is passed to the constructor.
|
|||
Configuring Dispatchers
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The dispatcher for created children of the router will be taken from
|
||||
The dispatcher for created children of the pool will be taken from
|
||||
``Props`` as described in :ref:`dispatchers-scala`. For a pool it
|
||||
makes sense to configure the ``BalancingDispatcher`` if the precise
|
||||
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
|
||||
stealing it from their siblings.
|
||||
|
||||
To make it easy to define the dispatcher of the routees of the pool you can
|
||||
define the dispatcher inline in the deployment section of the config.
|
||||
|
||||
.. includecode:: code/docs/routing/RouterDocSpec.scala#config-pool-dispatcher
|
||||
|
||||
That is the only thing you need to do enable a dedicated dispatcher for a
|
||||
pool.
|
||||
|
||||
.. note::
|
||||
|
||||
If you provide a collection of actors to route to, then they will still use the same dispatcher
|
||||
If you use a group of actors and route to their paths, then they will still use the same dispatcher
|
||||
that was configured for them in their ``Props``, it is not possible to change an actors dispatcher
|
||||
after it has been created.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue