From fdf93fe2ccc011a53a0972393e378b97817de705 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 21 Dec 2011 20:57:57 +0100 Subject: [PATCH] Removed some unessary dispatcher constants in ActorSystem.Settings. See #1458 --- .../akka/actor/dispatch/ActorModelSpec.scala | 16 +++++++++++----- .../src/test/scala/akka/config/ConfigSpec.scala | 3 --- .../src/main/scala/akka/actor/ActorSystem.scala | 6 ------ .../main/scala/akka/dispatch/Dispatchers.scala | 6 +----- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala index fabdf227cf..20d7b2e1bf 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala @@ -19,6 +19,7 @@ import akka.util.duration._ import akka.event.Logging.Error import com.typesafe.config.Config import java.util.concurrent.atomic.AtomicInteger +import akka.util.Duration object ActorModelSpec { @@ -230,6 +231,11 @@ abstract class ActorModelSpec(config: String) extends AkkaSpec(config) with Defa import ActorModelSpec._ + // FIXME Remove these settings as part of ticket #1563 + val DispatcherThroughput = system.settings.config.getInt("akka.actor.default-dispatcher.throughput") + val DispatcherDefaultShutdown = Duration(system.settings.config.getMilliseconds("akka.actor.default-dispatcher.shutdown-timeout"), TimeUnit.MILLISECONDS) + val DispatcherThroughputDeadlineTime = Duration(system.settings.config.getNanoseconds("akka.actor.default-dispatcher.throughput-deadline-time"), TimeUnit.NANOSECONDS) + def newTestActor(dispatcher: String) = system.actorOf(Props[DispatcherActor].withDispatcher(dispatcher)) protected def registerInterceptedDispatcher(): MessageDispatcherInterceptor @@ -447,9 +453,9 @@ class DispatcherModelSpec extends ActorModelSpec(DispatcherModelSpec.config) { val dispatcherConfigurator = new MessageDispatcherConfigurator(system.settings.config.getConfig("dispatcher"), system.dispatchers.prerequisites) { val instance = { ThreadPoolConfigDispatcherBuilder(config ⇒ - new Dispatcher(system.dispatchers.prerequisites, id, id, system.settings.DispatcherThroughput, - system.settings.DispatcherThroughputDeadlineTime, system.dispatchers.MailboxType, - config, system.settings.DispatcherDefaultShutdown) with MessageDispatcherInterceptor, + new Dispatcher(system.dispatchers.prerequisites, id, id, DispatcherThroughput, + DispatcherThroughputDeadlineTime, UnboundedMailbox(), config, + DispatcherDefaultShutdown) with MessageDispatcherInterceptor, ThreadPoolConfig()).build } override def dispatcher(): MessageDispatcher = instance @@ -509,8 +515,8 @@ class BalancingDispatcherModelSpec extends ActorModelSpec(BalancingDispatcherMod val instance = { ThreadPoolConfigDispatcherBuilder(config ⇒ new BalancingDispatcher(system.dispatchers.prerequisites, id, id, 1, // TODO check why 1 here? (came from old test) - system.settings.DispatcherThroughputDeadlineTime, system.dispatchers.MailboxType, - config, system.settings.DispatcherDefaultShutdown) with MessageDispatcherInterceptor, + DispatcherThroughputDeadlineTime, UnboundedMailbox(), + config, DispatcherDefaultShutdown) with MessageDispatcherInterceptor, ThreadPoolConfig()).build } diff --git a/akka-actor-tests/src/test/scala/akka/config/ConfigSpec.scala b/akka-actor-tests/src/test/scala/akka/config/ConfigSpec.scala index b1349ceedc..5c7f2770c8 100644 --- a/akka-actor-tests/src/test/scala/akka/config/ConfigSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/config/ConfigSpec.scala @@ -35,11 +35,8 @@ class ConfigSpec extends AkkaSpec(ConfigFactory.defaultReference) { getMilliseconds("akka.actor.default-dispatcher.mailbox-push-timeout-time") must equal(10 * 1000) getString("akka.actor.default-dispatcher.mailboxType") must be("") getMilliseconds("akka.actor.default-dispatcher.shutdown-timeout") must equal(1 * 1000) - settings.DispatcherDefaultShutdown must equal(1 second) getInt("akka.actor.default-dispatcher.throughput") must equal(5) - settings.DispatcherThroughput must equal(5) getMilliseconds("akka.actor.default-dispatcher.throughput-deadline-time") must equal(0) - settings.DispatcherThroughputDeadlineTime must equal(Duration.Zero) getBoolean("akka.actor.serialize-messages") must equal(false) settings.SerializeAllMessages must equal(false) diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 129445775d..8c9a3bd5b9 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -88,12 +88,6 @@ object ActorSystem { val FsmDebugEvent = getBoolean("akka.actor.debug.fsm") val DebugEventStream = getBoolean("akka.actor.debug.event-stream") - val DispatcherThroughput = getInt("akka.actor.default-dispatcher.throughput") - val DispatcherDefaultShutdown = Duration(getMilliseconds("akka.actor.default-dispatcher.shutdown-timeout"), MILLISECONDS) - val MailboxCapacity = getInt("akka.actor.default-dispatcher.mailbox-capacity") - val MailboxPushTimeout = Duration(getNanoseconds("akka.actor.default-dispatcher.mailbox-push-timeout-time"), NANOSECONDS) - val DispatcherThroughputDeadlineTime = Duration(getNanoseconds("akka.actor.default-dispatcher.throughput-deadline-time"), NANOSECONDS) - val Home = config.getString("akka.home") match { case "" ⇒ None case x ⇒ Some(x) diff --git a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala index 8c860fe013..0743870542 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Dispatchers.scala @@ -112,7 +112,7 @@ class Dispatchers(val settings: ActorSystem.Settings, val prerequisites: Dispatc } } - // FIXME #1458: Not sure if we should have this, but needed it temporary for ActorModelSpec and DispatcherDocSpec + // FIXME #1563: Remove this method when dispatcher usage is rewritten in ActorModelSpec and CallingThreadDispatcherModelSpec private[akka] def register(id: String, dispatcherConfigurator: MessageDispatcherConfigurator): Unit = { dispatcherConfigurators.putIfAbsent(id, dispatcherConfigurator) } @@ -131,10 +131,6 @@ class Dispatchers(val settings: ActorSystem.Settings, val prerequisites: Dispatc ConfigFactory.parseMap(Map("id" -> id).asJava) } - val MailboxType: MailboxType = - if (settings.MailboxCapacity < 1) UnboundedMailbox() - else BoundedMailbox(settings.MailboxCapacity, settings.MailboxPushTimeout) - /* * Creates of obtains a dispatcher from a Config according to the format below. *