Moved the dispatcher/router verification to RoutedActorRef, also checks dispatcher only through the config so we don't trigger creation of dispatcher.
Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
parent
6d962174fe
commit
66600f9c52
3 changed files with 11 additions and 17 deletions
|
|
@ -357,19 +357,7 @@ private[akka] class ActorCell(
|
||||||
case _ ⇒ true
|
case _ ⇒ true
|
||||||
}
|
}
|
||||||
|
|
||||||
private def verifyActorConfiguration(system: ActorSystem, props: Props, actorName: String): Unit = {
|
|
||||||
import akka.config.ConfigurationException
|
|
||||||
import akka.routing.NoRouter
|
|
||||||
// verify that a BalancingDispatcher is not used with a Router
|
|
||||||
if (system.dispatchers.lookup(props.dispatcher).isInstanceOf[BalancingDispatcher] && props.routerConfig != NoRouter)
|
|
||||||
throw new ConfigurationException(
|
|
||||||
"Configuration for actor [" + actorName +
|
|
||||||
"] is invalid - you can not use a 'BalancingDispatcher' together with any type of 'Router'")
|
|
||||||
}
|
|
||||||
|
|
||||||
private def _actorOf(props: Props, name: String): ActorRef = {
|
private def _actorOf(props: Props, name: String): ActorRef = {
|
||||||
verifyActorConfiguration(systemImpl, props, name)
|
|
||||||
|
|
||||||
if (system.settings.SerializeAllCreators && !props.creator.isInstanceOf[NoSerializationVerificationNeeded]) {
|
if (system.settings.SerializeAllCreators && !props.creator.isInstanceOf[NoSerializationVerificationNeeded]) {
|
||||||
val ser = SerializationExtension(system)
|
val ser = SerializationExtension(system)
|
||||||
ser.serialize(props.creator) match {
|
ser.serialize(props.creator) match {
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,9 @@ class Dispatchers(val settings: ActorSystem.Settings, val prerequisites: Dispatc
|
||||||
* Throws: IllegalArgumentException if the value of "type" is not valid
|
* Throws: IllegalArgumentException if the value of "type" is not valid
|
||||||
* IllegalArgumentException if it cannot create the MessageDispatcherConfigurator
|
* IllegalArgumentException if it cannot create the MessageDispatcherConfigurator
|
||||||
*/
|
*/
|
||||||
private[akka] def from(cfg: Config): MessageDispatcher = {
|
private[akka] def from(cfg: Config): MessageDispatcher = configuratorFrom(cfg).dispatcher()
|
||||||
configuratorFrom(cfg).dispatcher()
|
|
||||||
}
|
private[akka] def isBalancingDispatcher(id: String): Boolean = settings.config.hasPath(id) && config(id).getString("type") == "BalancingDispatcher"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a MessageDispatcherConfigurator from a Config.
|
* Creates a MessageDispatcherConfigurator from a Config.
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,17 @@ private[akka] class RoutedActorRef(_system: ActorSystemImpl, _props: Props, _sup
|
||||||
_supervisor,
|
_supervisor,
|
||||||
_path) {
|
_path) {
|
||||||
|
|
||||||
|
// verify that a BalancingDispatcher is not used with a Router
|
||||||
|
if (_system.dispatchers.isBalancingDispatcher(_props.dispatcher) && _props.routerConfig != NoRouter)
|
||||||
|
throw new ConfigurationException(
|
||||||
|
"Configuration for actor [" + _path.toString +
|
||||||
|
"] is invalid - you can not use a 'BalancingDispatcher' together with any type of 'Router'")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CAUTION: RoutedActorRef is PROBLEMATIC
|
* CAUTION: RoutedActorRef is PROBLEMATIC
|
||||||
* ======================================
|
* ======================================
|
||||||
*
|
*
|
||||||
* We are constructing/assembling the children outside of the scope of the
|
* We are constructing/assembling the children outside of the scope of the
|
||||||
* Router actor, inserting them in its childrenRef list, which is not at all
|
* Router actor, inserting them in its childrenRef list, which is not at all
|
||||||
* synchronized. This is done exactly once at start-up, all other accesses
|
* synchronized. This is done exactly once at start-up, all other accesses
|
||||||
* are done from the Router actor. This means that the only thing which is
|
* are done from the Router actor. This means that the only thing which is
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue