Merge branch 'master' into wip-sync-artery-patriknw

This commit is contained in:
Patrik Nordwall 2016-06-03 11:09:17 +02:00
commit 839ec5f167
757 changed files with 9166 additions and 6642 deletions

View file

@ -5,6 +5,10 @@
package akka.actor; package akka.actor;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static java.util.stream.Collectors.toCollection;
import java.util.ArrayList;
import java.util.stream.IntStream;
import akka.testkit.TestActors; import akka.testkit.TestActors;
import org.junit.Test; import org.junit.Test;
@ -144,6 +148,30 @@ public class ActorCreationTest extends JUnitSuite {
} }
} }
public static class Issue20537Reproducer extends UntypedActor {
static final class ReproducerCreator implements Creator<Issue20537Reproducer> {
final boolean create;
private ReproducerCreator(boolean create) {
this.create = create;
}
@Override
public Issue20537Reproducer create() throws Exception {
return new Issue20537Reproducer(create);
}
}
public Issue20537Reproducer(boolean create) {
}
@Override
public void onReceive(Object message) throws Exception {
}
}
@Test @Test
public void testWrongAnonymousInPlaceCreator() { public void testWrongAnonymousInPlaceCreator() {
try { try {
@ -287,5 +315,18 @@ public class ActorCreationTest extends JUnitSuite {
assertEquals(UntypedTestActor.class, p.actorClass()); assertEquals(UntypedTestActor.class, p.actorClass());
} }
@Test
public void testIssue20537Reproducer() {
final Issue20537Reproducer.ReproducerCreator creator = new Issue20537Reproducer.ReproducerCreator(false);
final Props p = Props.create(creator);
assertEquals(Issue20537Reproducer.class, p.actorClass());
ArrayList<Props> pList = IntStream.range(0, 4).mapToObj(i -> Props.create(creator))
.collect(toCollection(ArrayList::new));
for (Props each : pList) {
assertEquals(Issue20537Reproducer.class, each.actorClass());
}
}
} }

View file

@ -63,7 +63,7 @@ public class JavaFutureTests extends JUnitSuite {
}, system.dispatcher()); }, system.dispatcher());
cf.success("foo"); cf.success("foo");
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(Await.result(f, timeout), "foo"); assertEquals(Await.result(f, timeout), "foo");
} }
@ -81,7 +81,7 @@ public class JavaFutureTests extends JUnitSuite {
Throwable exception = new NullPointerException(); Throwable exception = new NullPointerException();
cf.failure(exception); cf.failure(exception);
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(f.value().get().failed().get(), exception); assertEquals(f.value().get().failed().get(), exception);
} }
@ -97,7 +97,7 @@ public class JavaFutureTests extends JUnitSuite {
}, system.dispatcher()); }, system.dispatcher());
cf.success("foo"); cf.success("foo");
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(Await.result(f, timeout), "foo"); assertEquals(Await.result(f, timeout), "foo");
} }
@ -113,7 +113,7 @@ public class JavaFutureTests extends JUnitSuite {
},system.dispatcher()); },system.dispatcher());
cf.success("foo"); cf.success("foo");
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(Await.result(f, timeout), "foo"); assertEquals(Await.result(f, timeout), "foo");
} }
@ -135,7 +135,7 @@ public class JavaFutureTests extends JUnitSuite {
assertEquals(Await.result(f, timeout), "1000"); assertEquals(Await.result(f, timeout), "1000");
assertEquals(Await.result(r, timeout).intValue(), 1000); assertEquals(Await.result(r, timeout).intValue(), 1000);
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
} }
@Test @Test
@ -151,7 +151,7 @@ public class JavaFutureTests extends JUnitSuite {
}), system.dispatcher()); }), system.dispatcher());
cf.success("foo"); cf.success("foo");
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(Await.result(f, timeout), "foo"); assertEquals(Await.result(f, timeout), "foo");
assertEquals(Await.result(r, timeout), "foo"); assertEquals(Await.result(r, timeout), "foo");
} }

View file

@ -3,6 +3,7 @@ package akka.event;
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.ActorSystem; import akka.actor.ActorSystem;
import akka.actor.Props; import akka.actor.Props;
import akka.testkit.AkkaJUnitActorSystemResource;
import akka.testkit.JavaTestKit; import akka.testkit.JavaTestKit;
import akka.event.Logging.Error; import akka.event.Logging.Error;
import akka.event.ActorWithMDC.Log; import akka.event.ActorWithMDC.Log;
@ -10,6 +11,8 @@ import static akka.event.Logging.*;
import com.typesafe.config.Config; import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory; import com.typesafe.config.ConfigFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.scalatest.junit.JUnitSuite; import org.scalatest.junit.JUnitSuite;
import scala.concurrent.duration.Duration; import scala.concurrent.duration.Duration;
@ -30,9 +33,19 @@ public class LoggingAdapterTest extends JUnitSuite {
"akka.actor.serialize-messages = off" "akka.actor.serialize-messages = off"
); );
@Rule
public AkkaJUnitActorSystemResource actorSystemResource =
new AkkaJUnitActorSystemResource("LoggingAdapterTest", config);
private ActorSystem system = null;
@Before
public void beforeEach() {
system = actorSystemResource.getSystem();
}
@Test @Test
public void mustFormatMessage() { public void mustFormatMessage() {
final ActorSystem system = ActorSystem.create("test-system", config);
final LoggingAdapter log = Logging.getLogger(system, this); final LoggingAdapter log = Logging.getLogger(system, this);
new LogJavaTestKit(system) {{ new LogJavaTestKit(system) {{
system.eventStream().subscribe(getRef(), LogEvent.class); system.eventStream().subscribe(getRef(), LogEvent.class);
@ -66,7 +79,6 @@ public class LoggingAdapterTest extends JUnitSuite {
@Test @Test
public void mustCallMdcForEveryLog() throws Exception { public void mustCallMdcForEveryLog() throws Exception {
final ActorSystem system = ActorSystem.create("test-system", config);
new LogJavaTestKit(system) {{ new LogJavaTestKit(system) {{
system.eventStream().subscribe(getRef(), LogEvent.class); system.eventStream().subscribe(getRef(), LogEvent.class);
ActorRef ref = system.actorOf(Props.create(ActorWithMDC.class)); ActorRef ref = system.actorOf(Props.create(ActorWithMDC.class));
@ -86,7 +98,6 @@ public class LoggingAdapterTest extends JUnitSuite {
@Test @Test
public void mustSupportMdcNull() throws Exception { public void mustSupportMdcNull() throws Exception {
final ActorSystem system = ActorSystem.create("test-system", config);
new LogJavaTestKit(system) {{ new LogJavaTestKit(system) {{
system.eventStream().subscribe(getRef(), LogEvent.class); system.eventStream().subscribe(getRef(), LogEvent.class);
ActorRef ref = system.actorOf(Props.create(ActorWithMDC.class)); ActorRef ref = system.actorOf(Props.create(ActorWithMDC.class));
@ -131,6 +142,7 @@ public class LoggingAdapterTest extends JUnitSuite {
void expectLog(final Object level, final String message, final Throwable cause, final String mdc) { void expectLog(final Object level, final String message, final Throwable cause, final String mdc) {
new ExpectMsg<Void>(Duration.create(3, TimeUnit.SECONDS), "LogEvent") { new ExpectMsg<Void>(Duration.create(3, TimeUnit.SECONDS), "LogEvent") {
@Override
protected Void match(Object event) { protected Void match(Object event) {
LogEvent log = (LogEvent) event; LogEvent log = (LogEvent) event;
assertEquals(message, log.message()); assertEquals(message, log.message());

View file

@ -101,7 +101,8 @@ class ActorLifeCycleSpec extends AkkaSpec("akka.actor.serialize-messages=off") w
"not invoke preRestart and postRestart when never restarted using OneForOneStrategy" in { "not invoke preRestart and postRestart when never restarted using OneForOneStrategy" in {
val id = newUuid().toString val id = newUuid().toString
val supervisor = system.actorOf(Props(classOf[Supervisor], val supervisor = system.actorOf(Props(
classOf[Supervisor],
OneForOneStrategy(maxNrOfRetries = 3)(List(classOf[Exception])))) OneForOneStrategy(maxNrOfRetries = 3)(List(classOf[Exception]))))
val gen = new AtomicInteger(0) val gen = new AtomicInteger(0)
val props = Props(classOf[LifeCycleTestActor], testActor, id, gen) val props = Props(classOf[LifeCycleTestActor], testActor, id, gen)

View file

@ -249,14 +249,14 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
val lookname = looker.path.elements.mkString("", "/", "/") val lookname = looker.path.elements.mkString("", "/", "/")
for ( for (
(l, r) Seq( (l, r) Seq(
LookupString("a/b/c") -> empty(lookname + "a/b/c"), LookupString("a/b/c") empty(lookname + "a/b/c"),
LookupString("") -> system.deadLetters, LookupString("") system.deadLetters,
LookupString("akka://all-systems/Nobody") -> system.deadLetters, LookupString("akka://all-systems/Nobody") system.deadLetters,
LookupPath(system / "hallo") -> empty("user/hallo"), LookupPath(system / "hallo") empty("user/hallo"),
LookupPath(looker.path child "hallo") -> empty(lookname + "hallo"), // test Java API LookupPath(looker.path child "hallo") empty(lookname + "hallo"), // test Java API
LookupPath(looker.path descendant Seq("a", "b").asJava) -> empty(lookname + "a/b"), // test Java API LookupPath(looker.path descendant Seq("a", "b").asJava) empty(lookname + "a/b"), // test Java API
LookupElems(Seq()) -> system.deadLetters, LookupElems(Seq()) system.deadLetters,
LookupElems(Seq("a")) -> empty(lookname + "a")) LookupElems(Seq("a")) empty(lookname + "a"))
) checkOne(looker, l, r) ) checkOne(looker, l, r)
} }
for (looker all) check(looker) for (looker all) check(looker)

View file

@ -210,7 +210,8 @@ object ActorMailboxSpec {
final case class MCBoundedMailbox(val capacity: Int, val pushTimeOut: FiniteDuration) final case class MCBoundedMailbox(val capacity: Int, val pushTimeOut: FiniteDuration)
extends MailboxType with ProducesMessageQueue[MCBoundedMessageQueueSemantics] { extends MailboxType with ProducesMessageQueue[MCBoundedMessageQueueSemantics] {
def this(settings: ActorSystem.Settings, config: Config) = this(config.getInt("mailbox-capacity"), def this(settings: ActorSystem.Settings, config: Config) = this(
config.getInt("mailbox-capacity"),
config.getNanosDuration("mailbox-push-timeout-time")) config.getNanosDuration("mailbox-push-timeout-time"))
final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue =
@ -241,23 +242,29 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
} }
"get an unbounded deque message queue when it is only configured on the props" in { "get an unbounded deque message queue when it is only configured on the props" in {
checkMailboxQueue(Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"), checkMailboxQueue(
Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"default-override-from-props", UnboundedDeqMailboxTypes) "default-override-from-props", UnboundedDeqMailboxTypes)
} }
"get an bounded message queue when it's only configured with RequiresMailbox" in { "get an bounded message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(Props[BoundedQueueReportingActor], checkMailboxQueue(
Props[BoundedQueueReportingActor],
"default-override-from-trait", BoundedMailboxTypes) "default-override-from-trait", BoundedMailboxTypes)
} }
"get an unbounded deque message queue when it's only mixed with Stash" in { "get an unbounded deque message queue when it's only mixed with Stash" in {
checkMailboxQueue(Props[StashQueueReportingActor], checkMailboxQueue(
Props[StashQueueReportingActor],
"default-override-from-stash", UnboundedDeqMailboxTypes) "default-override-from-stash", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props(new StashQueueReportingActor), checkMailboxQueue(
Props(new StashQueueReportingActor),
"default-override-from-stash2", UnboundedDeqMailboxTypes) "default-override-from-stash2", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props(classOf[StashQueueReportingActorWithParams], 17, "hello"), checkMailboxQueue(
Props(classOf[StashQueueReportingActorWithParams], 17, "hello"),
"default-override-from-stash3", UnboundedDeqMailboxTypes) "default-override-from-stash3", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props(new StashQueueReportingActorWithParams(17, "hello")), checkMailboxQueue(
Props(new StashQueueReportingActorWithParams(17, "hello")),
"default-override-from-stash4", UnboundedDeqMailboxTypes) "default-override-from-stash4", UnboundedDeqMailboxTypes)
} }
@ -278,12 +285,14 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
} }
"get an bounded control aware message queue when it's only configured with RequiresMailbox" in { "get an bounded control aware message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(Props[BoundedControlAwareQueueReportingActor], checkMailboxQueue(
Props[BoundedControlAwareQueueReportingActor],
"default-override-from-trait-bounded-control-aware", BoundedControlAwareMailboxTypes) "default-override-from-trait-bounded-control-aware", BoundedControlAwareMailboxTypes)
} }
"get an unbounded control aware message queue when it's only configured with RequiresMailbox" in { "get an unbounded control aware message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(Props[UnboundedControlAwareQueueReportingActor], checkMailboxQueue(
Props[UnboundedControlAwareQueueReportingActor],
"default-override-from-trait-unbounded-control-aware", UnboundedControlAwareMailboxTypes) "default-override-from-trait-unbounded-control-aware", UnboundedControlAwareMailboxTypes)
} }
@ -317,7 +326,8 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
} }
"get an unbounded message queue overriding configuration on the props" in { "get an unbounded message queue overriding configuration on the props" in {
checkMailboxQueue(Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"), checkMailboxQueue(
Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"bounded-unbounded-override-props", UnboundedMailboxTypes) "bounded-unbounded-override-props", UnboundedMailboxTypes)
} }
@ -401,17 +411,20 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
} }
"get an unbounded message queue with a balancing dispatcher" in { "get an unbounded message queue with a balancing dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor].withDispatcher("balancing-dispatcher"), checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("balancing-dispatcher"),
"unbounded-balancing", UnboundedMailboxTypes) "unbounded-balancing", UnboundedMailboxTypes)
} }
"get a bounded message queue with a balancing bounded dispatcher" in { "get a bounded message queue with a balancing bounded dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor].withDispatcher("balancing-bounded-dispatcher"), checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("balancing-bounded-dispatcher"),
"bounded-balancing", BoundedMailboxTypes) "bounded-balancing", BoundedMailboxTypes)
} }
"get a bounded message queue with a requiring balancing bounded dispatcher" in { "get a bounded message queue with a requiring balancing bounded dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor].withDispatcher("requiring-balancing-bounded-dispatcher"), checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("requiring-balancing-bounded-dispatcher"),
"requiring-bounded-balancing", BoundedMailboxTypes) "requiring-bounded-balancing", BoundedMailboxTypes)
} }
} }

View file

@ -65,7 +65,8 @@ class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTim
asked.correlationId should ===(selection) asked.correlationId should ===(selection)
implicit val ec = system.dispatcher implicit val ec = system.dispatcher
val resolved = Await.result(selection.resolveOne(timeout.duration).mapTo[ActorRef] recover { case _ null }, val resolved = Await.result(
selection.resolveOne(timeout.duration).mapTo[ActorRef] recover { case _ null },
timeout.duration) timeout.duration)
Option(resolved) should ===(result) Option(resolved) should ===(result)
@ -248,11 +249,11 @@ class ActorSelectionSpec extends AkkaSpec("akka.loglevel=DEBUG") with DefaultTim
val lookname = looker.path.elements.mkString("", "/", "/") val lookname = looker.path.elements.mkString("", "/", "/")
for ( for (
(l, r) Seq( (l, r) Seq(
SelectString("a/b/c") -> None, SelectString("a/b/c") None,
SelectString("akka://all-systems/Nobody") -> None, SelectString("akka://all-systems/Nobody") None,
SelectPath(system / "hallo") -> None, SelectPath(system / "hallo") None,
SelectPath(looker.path child "hallo") -> None, // test Java API SelectPath(looker.path child "hallo") None, // test Java API
SelectPath(looker.path descendant Seq("a", "b").asJava) -> None) // test Java API SelectPath(looker.path descendant Seq("a", "b").asJava) None) // test Java API
) checkOne(looker, l, r) ) checkOne(looker, l, r)
} }
for (looker all) check(looker) for (looker all) check(looker)

View file

@ -273,7 +273,8 @@ class ActorSystemSpec extends AkkaSpec(ActorSystemSpec.config) with ImplicitSend
} }
"allow configuration of guardian supervisor strategy" in { "allow configuration of guardian supervisor strategy" in {
implicit val system = ActorSystem("Stop", implicit val system = ActorSystem(
"Stop",
ConfigFactory.parseString("akka.actor.guardian-supervisor-strategy=akka.actor.StoppingSupervisorStrategy") ConfigFactory.parseString("akka.actor.guardian-supervisor-strategy=akka.actor.StoppingSupervisorStrategy")
.withFallback(AkkaSpec.testConf)) .withFallback(AkkaSpec.testConf))
val a = system.actorOf(Props(new Actor { val a = system.actorOf(Props(new Actor {
@ -293,7 +294,8 @@ class ActorSystemSpec extends AkkaSpec(ActorSystemSpec.config) with ImplicitSend
} }
"shut down when /user escalates" in { "shut down when /user escalates" in {
implicit val system = ActorSystem("Stop", implicit val system = ActorSystem(
"Stop",
ConfigFactory.parseString("akka.actor.guardian-supervisor-strategy=\"akka.actor.ActorSystemSpec$Strategy\"") ConfigFactory.parseString("akka.actor.guardian-supervisor-strategy=\"akka.actor.ActorSystemSpec$Strategy\"")
.withFallback(AkkaSpec.testConf)) .withFallback(AkkaSpec.testConf))
val a = system.actorOf(Props(new Actor { val a = system.actorOf(Props(new Actor {

View file

@ -8,12 +8,11 @@ import java.util.concurrent.atomic.AtomicInteger
import akka.testkit.EventFilter import akka.testkit.EventFilter
import akka.testkit.TestKit._ import akka.testkit.TestKit._
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import org.scalatest.{Matchers, WordSpec} import org.scalatest.{ Matchers, WordSpec }
import org.scalatest.junit.JUnitSuiteLike import org.scalatest.junit.JUnitSuiteLike
import scala.util.control.NoStackTrace import scala.util.control.NoStackTrace
class JavaExtensionSpec extends JavaExtension with JUnitSuiteLike class JavaExtensionSpec extends JavaExtension with JUnitSuiteLike
object TestExtension extends ExtensionId[TestExtension] with ExtensionIdProvider { object TestExtension extends ExtensionId[TestExtension] with ExtensionIdProvider {
@ -52,7 +51,6 @@ class FailingTestExtension(val system: ExtendedActorSystem) extends Extension {
throw new FailingTestExtension.TestException throw new FailingTestExtension.TestException
} }
class ExtensionSpec extends WordSpec with Matchers { class ExtensionSpec extends WordSpec with Matchers {
"The ActorSystem extensions support" should { "The ActorSystem extensions support" should {
@ -83,9 +81,8 @@ class ExtensionSpec extends WordSpec with Matchers {
shutdownActorSystem(system) shutdownActorSystem(system)
} }
"fail the actor system if an extension listed in akka.extensions fails to start" in { "fail the actor system if an extension listed in akka.extensions fails to start" in {
intercept[RuntimeException]{ intercept[RuntimeException] {
val system = ActorSystem("failing", ConfigFactory.parseString( val system = ActorSystem("failing", ConfigFactory.parseString(
""" """
akka.extensions = ["akka.actor.FailingTestExtension"] akka.extensions = ["akka.actor.FailingTestExtension"]
@ -134,7 +131,6 @@ class ExtensionSpec extends WordSpec with Matchers {
} }
} }
} }
} }

View file

@ -34,6 +34,7 @@ object FSMActorSpec {
class Lock(code: String, timeout: FiniteDuration, latches: Latches) extends Actor with FSM[LockState, CodeState] { class Lock(code: String, timeout: FiniteDuration, latches: Latches) extends Actor with FSM[LockState, CodeState] {
import latches._ import latches._
import FSM.`→`
startWith(Locked, CodeState("", code)) startWith(Locked, CodeState("", code))
@ -71,7 +72,7 @@ object FSMActorSpec {
} }
onTransition { onTransition {
case Locked -> Open transitionLatch.open case Locked Open transitionLatch.open
} }
// verify that old-style does still compile // verify that old-style does still compile
@ -98,8 +99,9 @@ object FSMActorSpec {
final case class CodeState(soFar: String, code: String) final case class CodeState(soFar: String, code: String)
} }
class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with ImplicitSender { class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" true)) with ImplicitSender {
import FSMActorSpec._ import FSMActorSpec._
import FSM.`→`
val timeout = Timeout(2 seconds) val timeout = Timeout(2 seconds)
@ -222,7 +224,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
case Event("stop", _) stop() case Event("stop", _) stop()
} }
onTransition { onTransition {
case "not-started" -> "started" case "not-started" "started"
for (timerName timerNames) setTimer(timerName, (), 10 seconds, false) for (timerName timerNames) setTimer(timerName, (), 10 seconds, false)
} }
onTermination { onTermination {
@ -250,8 +252,8 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
"log events and transitions if asked to do so" in { "log events and transitions if asked to do so" in {
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
val config = ConfigFactory.parseMap(Map("akka.loglevel" -> "DEBUG", "akka.actor.serialize-messages" -> "off", val config = ConfigFactory.parseMap(Map("akka.loglevel" "DEBUG", "akka.actor.serialize-messages" "off",
"akka.actor.debug.fsm" -> true).asJava).withFallback(system.settings.config) "akka.actor.debug.fsm" true).asJava).withFallback(system.settings.config)
val fsmEventSystem = ActorSystem("fsmEvent", config) val fsmEventSystem = ActorSystem("fsmEvent", config)
try { try {
new TestKit(fsmEventSystem) { new TestKit(fsmEventSystem) {

View file

@ -129,7 +129,8 @@ class FSMTimingSpec extends AkkaSpec with ImplicitSender {
} }
"notify unhandled messages" taggedAs TimingTest in { "notify unhandled messages" taggedAs TimingTest in {
filterEvents(EventFilter.warning("unhandled event Tick in state TestUnhandled", source = fsm.path.toString, occurrences = 1), filterEvents(
EventFilter.warning("unhandled event Tick in state TestUnhandled", source = fsm.path.toString, occurrences = 1),
EventFilter.warning("unhandled event Unhandled(test) in state TestUnhandled", source = fsm.path.toString, occurrences = 1)) { EventFilter.warning("unhandled event Unhandled(test) in state TestUnhandled", source = fsm.path.toString, occurrences = 1)) {
fsm ! TestUnhandled fsm ! TestUnhandled
within(3 second) { within(3 second) {
@ -208,7 +209,7 @@ object FSMTimingSpec {
goto(Initial) goto(Initial)
} }
onTransition { onTransition {
case Initial -> TestSingleTimerResubmit setTimer("blah", Tick, 500.millis.dilated) case Initial TestSingleTimerResubmit setTimer("blah", Tick, 500.millis.dilated)
} }
when(TestSingleTimerResubmit) { when(TestSingleTimerResubmit) {
case Event(Tick, _) case Event(Tick, _)

View file

@ -9,6 +9,7 @@ import scala.concurrent.duration._
import scala.language.postfixOps import scala.language.postfixOps
object FSMTransitionSpec { object FSMTransitionSpec {
import FSM.`→`
class Supervisor extends Actor { class Supervisor extends Actor {
def receive = { case _ } def receive = { case _ }
@ -20,7 +21,7 @@ object FSMTransitionSpec {
case Event("stay", _) stay() case Event("stay", _) stay()
case Event(_, _) goto(0) case Event(_, _) goto(0)
} }
onTransition { case from -> to target ! (from -> to) } onTransition { case from to target ! (from to) }
initialize() initialize()
} }
@ -50,8 +51,8 @@ object FSMTransitionSpec {
case _ goto(1) case _ goto(1)
} }
onTransition { onTransition {
case 0 -> 1 target ! ((stateData, nextStateData)) case 0 1 target ! ((stateData, nextStateData))
case 1 -> 1 target ! ((stateData, nextStateData)) case 1 1 target ! ((stateData, nextStateData))
} }
} }
@ -64,16 +65,17 @@ object FSMTransitionSpec {
class FSMTransitionSpec extends AkkaSpec with ImplicitSender { class FSMTransitionSpec extends AkkaSpec with ImplicitSender {
import FSMTransitionSpec._ import FSMTransitionSpec._
import FSM.`→`
"A FSM transition notifier" must { "A FSM transition notifier" must {
"not trigger onTransition for stay" in { "not trigger onTransition for stay" in {
val fsm = system.actorOf(Props(new SendAnyTransitionFSM(testActor))) val fsm = system.actorOf(Props(new SendAnyTransitionFSM(testActor)))
expectMsg(0 -> 0) // caused by initialize(), OK. expectMsg(0 0) // caused by initialize(), OK.
fsm ! "stay" // no transition event fsm ! "stay" // no transition event
expectNoMsg(500.millis) expectNoMsg(500.millis)
fsm ! "goto" // goto(current state) fsm ! "goto" // goto(current state)
expectMsg(0 -> 0) expectMsg(0 0)
} }
"notify listeners" in { "notify listeners" in {
@ -150,7 +152,7 @@ class FSMTransitionSpec extends AkkaSpec with ImplicitSender {
case Event("switch", _) goto(1) using sender() case Event("switch", _) goto(1) using sender()
} }
onTransition { onTransition {
case x -> y nextStateData ! (x -> y) case x y nextStateData ! (x y)
} }
when(1) { when(1) {
case Event("test", _) case Event("test", _)

View file

@ -26,6 +26,8 @@ import java.lang.System.identityHashCode
import akka.util.Helpers.ConfigOps import akka.util.Helpers.ConfigOps
object SupervisorHierarchySpec { object SupervisorHierarchySpec {
import FSM.`→`
class FireWorkerException(msg: String) extends Exception(msg) class FireWorkerException(msg: String) extends Exception(msg)
/** /**
@ -79,7 +81,8 @@ object SupervisorHierarchySpec {
extends DispatcherConfigurator(config, prerequisites) { extends DispatcherConfigurator(config, prerequisites) {
private val instance: MessageDispatcher = private val instance: MessageDispatcher =
new Dispatcher(this, new Dispatcher(
this,
config.getString("id"), config.getString("id"),
config.getInt("throughput"), config.getInt("throughput"),
config.getNanosDuration("throughput-deadline-time"), config.getNanosDuration("throughput-deadline-time"),
@ -467,7 +470,7 @@ object SupervisorHierarchySpec {
} }
onTransition { onTransition {
case Init -> Stress case Init Stress
self ! Work self ! Work
idleChildren = children idleChildren = children
activeChildren = children activeChildren = children
@ -532,7 +535,7 @@ object SupervisorHierarchySpec {
} }
onTransition { onTransition {
case Stress -> Finishing ignoreFailConstr = true case Stress Finishing ignoreFailConstr = true
} }
when(Finishing) { when(Finishing) {
@ -546,7 +549,7 @@ object SupervisorHierarchySpec {
} }
onTransition { onTransition {
case _ -> LastPing case _ LastPing
idleChildren foreach (_ ! "ping") idleChildren foreach (_ ! "ping")
pingChildren ++= idleChildren pingChildren ++= idleChildren
idleChildren = Vector.empty idleChildren = Vector.empty
@ -563,7 +566,7 @@ object SupervisorHierarchySpec {
} }
onTransition { onTransition {
case _ -> Stopping case _ Stopping
ignoreNotResumedLogs = false ignoreNotResumedLogs = false
hierarchy ! PingOfDeath hierarchy ! PingOfDeath
} }
@ -596,7 +599,7 @@ object SupervisorHierarchySpec {
stop stop
} }
case Event(StateTimeout, _) case Event(StateTimeout, _)
errors :+= self -> ErrorLog("timeout while Stopping", Vector.empty) errors :+= self ErrorLog("timeout while Stopping", Vector.empty)
println(system.asInstanceOf[ActorSystemImpl].printTree) println(system.asInstanceOf[ActorSystemImpl].printTree)
getErrors(hierarchy, 10) getErrors(hierarchy, 10)
printErrors() printErrors()
@ -604,7 +607,7 @@ object SupervisorHierarchySpec {
testActor ! "timeout in Stopping" testActor ! "timeout in Stopping"
stop stop
case Event(e: ErrorLog, _) case Event(e: ErrorLog, _)
errors :+= sender() -> e errors :+= sender() e
goto(Failed) goto(Failed)
} }
@ -630,7 +633,7 @@ object SupervisorHierarchySpec {
when(Failed, stateTimeout = 5.seconds.dilated) { when(Failed, stateTimeout = 5.seconds.dilated) {
case Event(e: ErrorLog, _) case Event(e: ErrorLog, _)
if (!e.msg.startsWith("not resumed") || !ignoreNotResumedLogs) if (!e.msg.startsWith("not resumed") || !ignoreNotResumedLogs)
errors :+= sender() -> e errors :+= sender() e
stay stay
case Event(Terminated(r), _) if r == hierarchy case Event(Terminated(r), _) if r == hierarchy
printErrors() printErrors()
@ -650,8 +653,8 @@ object SupervisorHierarchySpec {
target match { target match {
case l: LocalActorRef case l: LocalActorRef
l.underlying.actor match { l.underlying.actor match {
case h: Hierarchy errors :+= target -> ErrorLog("forced", h.log) case h: Hierarchy errors :+= target ErrorLog("forced", h.log)
case _ errors :+= target -> ErrorLog("fetched", stateCache.get(target.path).log) case _ errors :+= target ErrorLog("fetched", stateCache.get(target.path).log)
} }
if (depth > 0) { if (depth > 0) {
l.underlying.children foreach (getErrors(_, depth - 1)) l.underlying.children foreach (getErrors(_, depth - 1))
@ -663,8 +666,8 @@ object SupervisorHierarchySpec {
target match { target match {
case l: LocalActorRef case l: LocalActorRef
l.underlying.actor match { l.underlying.actor match {
case h: Hierarchy errors :+= target -> ErrorLog("forced", h.log) case h: Hierarchy errors :+= target ErrorLog("forced", h.log)
case _ errors :+= target -> ErrorLog("fetched", stateCache.get(target.path).log) case _ errors :+= target ErrorLog("fetched", stateCache.get(target.path).log)
} }
if (target != hierarchy) getErrorsUp(l.getParent) if (target != hierarchy) getErrorsUp(l.getParent)
} }
@ -693,7 +696,7 @@ object SupervisorHierarchySpec {
case Event(e: ErrorLog, _) case Event(e: ErrorLog, _)
if (e.msg.startsWith("not resumed")) stay if (e.msg.startsWith("not resumed")) stay
else { else {
errors :+= sender() -> e errors :+= sender() e
// dont stop the hierarchy, that is going to happen all by itself and in the right order // dont stop the hierarchy, that is going to happen all by itself and in the right order
goto(Failed) goto(Failed)
} }

View file

@ -58,7 +58,7 @@ class SupervisorMiscSpec extends AkkaSpec(SupervisorMiscSpec.config) with Defaul
countDownLatch.await(10, TimeUnit.SECONDS) countDownLatch.await(10, TimeUnit.SECONDS)
Seq("actor1" -> actor1, "actor2" -> actor2, "actor3" -> actor3, "actor4" -> actor4) map { Seq("actor1" actor1, "actor2" actor2, "actor3" actor3, "actor4" actor4) map {
case (id, ref) (id, ref ? "status") case (id, ref) (id, ref ? "status")
} foreach { } foreach {
case (id, f) (id, Await.result(f, timeout.duration)) should ===((id, "OK")) case (id, f) (id, Await.result(f, timeout.duration)) should ===((id, "OK"))

View file

@ -16,9 +16,10 @@ object UidClashTest {
@volatile var oldActor: ActorRef = _ @volatile var oldActor: ActorRef = _
private[akka] class EvilCollidingActorRef(override val provider: ActorRefProvider, private[akka] class EvilCollidingActorRef(
override val path: ActorPath, override val provider: ActorRefProvider,
val eventStream: EventStream) extends MinimalActorRef { override val path: ActorPath,
val eventStream: EventStream) extends MinimalActorRef {
//Ignore everything //Ignore everything
override def isTerminated: Boolean = true override def isTerminated: Boolean = true

View file

@ -181,13 +181,13 @@ object ActorModelSpec {
dispatcher.asInstanceOf[MessageDispatcherInterceptor].getStats(actorRef) dispatcher.asInstanceOf[MessageDispatcherInterceptor].getStats(actorRef)
def assertRefDefaultZero(actorRef: ActorRef, dispatcher: MessageDispatcher = null)( def assertRefDefaultZero(actorRef: ActorRef, dispatcher: MessageDispatcher = null)(
suspensions: Long = 0, suspensions: Long = 0,
resumes: Long = 0, resumes: Long = 0,
registers: Long = 0, registers: Long = 0,
unregisters: Long = 0, unregisters: Long = 0,
msgsReceived: Long = 0, msgsReceived: Long = 0,
msgsProcessed: Long = 0, msgsProcessed: Long = 0,
restarts: Long = 0)(implicit system: ActorSystem) { restarts: Long = 0)(implicit system: ActorSystem) {
assertRef(actorRef, dispatcher)( assertRef(actorRef, dispatcher)(
suspensions, suspensions,
resumes, resumes,
@ -199,13 +199,13 @@ object ActorModelSpec {
} }
def assertRef(actorRef: ActorRef, dispatcher: MessageDispatcher = null)( def assertRef(actorRef: ActorRef, dispatcher: MessageDispatcher = null)(
suspensions: Long = statsFor(actorRef, dispatcher).suspensions.get(), suspensions: Long = statsFor(actorRef, dispatcher).suspensions.get(),
resumes: Long = statsFor(actorRef, dispatcher).resumes.get(), resumes: Long = statsFor(actorRef, dispatcher).resumes.get(),
registers: Long = statsFor(actorRef, dispatcher).registers.get(), registers: Long = statsFor(actorRef, dispatcher).registers.get(),
unregisters: Long = statsFor(actorRef, dispatcher).unregisters.get(), unregisters: Long = statsFor(actorRef, dispatcher).unregisters.get(),
msgsReceived: Long = statsFor(actorRef, dispatcher).msgsReceived.get(), msgsReceived: Long = statsFor(actorRef, dispatcher).msgsReceived.get(),
msgsProcessed: Long = statsFor(actorRef, dispatcher).msgsProcessed.get(), msgsProcessed: Long = statsFor(actorRef, dispatcher).msgsProcessed.get(),
restarts: Long = statsFor(actorRef, dispatcher).restarts.get())(implicit system: ActorSystem) { restarts: Long = statsFor(actorRef, dispatcher).restarts.get())(implicit system: ActorSystem) {
val stats = statsFor(actorRef, Option(dispatcher).getOrElse(actorRef.asInstanceOf[ActorRefWithCell].underlying.asInstanceOf[ActorCell].dispatcher)) val stats = statsFor(actorRef, Option(dispatcher).getOrElse(actorRef.asInstanceOf[ActorRefWithCell].underlying.asInstanceOf[ActorCell].dispatcher))
val deadline = System.currentTimeMillis + 1000 val deadline = System.currentTimeMillis + 1000
try { try {
@ -218,7 +218,8 @@ object ActorModelSpec {
await(deadline)(stats.restarts.get() == restarts) await(deadline)(stats.restarts.get() == restarts)
} catch { } catch {
case e: Throwable case e: Throwable
system.eventStream.publish(Error(e, system.eventStream.publish(Error(
e,
Option(dispatcher).toString, Option(dispatcher).toString,
(Option(dispatcher) getOrElse this).getClass, (Option(dispatcher) getOrElse this).getClass,
"actual: " + stats + ", required: InterceptorStats(susp=" + suspensions + "actual: " + stats + ", required: InterceptorStats(susp=" + suspensions +
@ -529,7 +530,8 @@ object DispatcherModelSpec {
import akka.util.Helpers.ConfigOps import akka.util.Helpers.ConfigOps
private val instance: MessageDispatcher = private val instance: MessageDispatcher =
new Dispatcher(this, new Dispatcher(
this,
config.getString("id"), config.getString("id"),
config.getInt("throughput"), config.getInt("throughput"),
config.getNanosDuration("throughput-deadline-time"), config.getNanosDuration("throughput-deadline-time"),
@ -602,7 +604,8 @@ object BalancingDispatcherModelSpec {
import akka.util.Helpers.ConfigOps import akka.util.Helpers.ConfigOps
override protected def create(mailboxType: MailboxType): BalancingDispatcher = override protected def create(mailboxType: MailboxType): BalancingDispatcher =
new BalancingDispatcher(this, new BalancingDispatcher(
this,
config.getString("id"), config.getString("id"),
config.getInt("throughput"), config.getInt("throughput"),
config.getNanosDuration("throughput-deadline-time"), config.getNanosDuration("throughput-deadline-time"),

View file

@ -104,15 +104,15 @@ class DispatchersSpec extends AkkaSpec(DispatchersSpec.config) with ImplicitSend
def ofType[T <: MessageDispatcher: ClassTag]: (MessageDispatcher) Boolean = _.getClass == implicitly[ClassTag[T]].runtimeClass def ofType[T <: MessageDispatcher: ClassTag]: (MessageDispatcher) Boolean = _.getClass == implicitly[ClassTag[T]].runtimeClass
def typesAndValidators: Map[String, (MessageDispatcher) Boolean] = Map( def typesAndValidators: Map[String, (MessageDispatcher) Boolean] = Map(
"PinnedDispatcher" -> ofType[PinnedDispatcher], "PinnedDispatcher" ofType[PinnedDispatcher],
"Dispatcher" -> ofType[Dispatcher]) "Dispatcher" ofType[Dispatcher])
def validTypes = typesAndValidators.keys.toList def validTypes = typesAndValidators.keys.toList
val defaultDispatcherConfig = settings.config.getConfig("akka.actor.default-dispatcher") val defaultDispatcherConfig = settings.config.getConfig("akka.actor.default-dispatcher")
lazy val allDispatchers: Map[String, MessageDispatcher] = { lazy val allDispatchers: Map[String, MessageDispatcher] = {
validTypes.map(t (t, from(ConfigFactory.parseMap(Map(tipe -> t, id -> t).asJava). validTypes.map(t (t, from(ConfigFactory.parseMap(Map(tipe t, id t).asJava).
withFallback(defaultDispatcherConfig)))).toMap withFallback(defaultDispatcherConfig)))).toMap
} }
@ -150,7 +150,7 @@ class DispatchersSpec extends AkkaSpec(DispatchersSpec.config) with ImplicitSend
"throw ConfigurationException if type does not exist" in { "throw ConfigurationException if type does not exist" in {
intercept[ConfigurationException] { intercept[ConfigurationException] {
from(ConfigFactory.parseMap(Map(tipe -> "typedoesntexist", id -> "invalid-dispatcher").asJava). from(ConfigFactory.parseMap(Map(tipe "typedoesntexist", id "invalid-dispatcher").asJava).
withFallback(defaultDispatcherConfig)) withFallback(defaultDispatcherConfig))
} }
} }

View file

@ -125,55 +125,57 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn
q.hasMessages should ===(false) q.hasMessages should ===(false)
} }
def testEnqueueDequeue(config: MailboxType, def testEnqueueDequeue(
enqueueN: Int = 10000, config: MailboxType,
dequeueN: Int = 10000, enqueueN: Int = 10000,
parallel: Boolean = true): Unit = within(10 seconds) { dequeueN: Int = 10000,
parallel: Boolean = true): Unit = within(10 seconds) {
val q = factory(config) val q = factory(config)
ensureInitialMailboxState(config, q) ensureInitialMailboxState(config, q)
EventFilter.warning(pattern = ".*received dead letter from Actor.*MailboxSpec/deadLetters.*", EventFilter.warning(
pattern = ".*received dead letter from Actor.*MailboxSpec/deadLetters.*",
occurrences = (enqueueN - dequeueN)) intercept { occurrences = (enqueueN - dequeueN)) intercept {
def createProducer(fromNum: Int, toNum: Int): Future[Vector[Envelope]] = spawn { def createProducer(fromNum: Int, toNum: Int): Future[Vector[Envelope]] = spawn {
val messages = Vector() ++ (for (i fromNum to toNum) yield createMessageInvocation(i)) val messages = Vector() ++ (for (i fromNum to toNum) yield createMessageInvocation(i))
for (i messages) q.enqueue(testActor, i) for (i messages) q.enqueue(testActor, i)
messages messages
}
val producers = {
val step = 500
val ps = for (i (1 to enqueueN by step).toList) yield createProducer(i, Math.min(enqueueN, i + step - 1))
if (parallel == false)
ps foreach { Await.ready(_, remainingOrDefault) }
ps
}
def createConsumer: Future[Vector[Envelope]] = spawn {
var r = Vector[Envelope]()
while (producers.exists(_.isCompleted == false) || q.hasMessages)
Option(q.dequeue) foreach { message r = r :+ message }
r
}
val consumers = List.fill(maxConsumers)(createConsumer)
val ps = producers.map(Await.result(_, remainingOrDefault))
val cs = consumers.map(Await.result(_, remainingOrDefault))
ps.map(_.size).sum should ===(enqueueN) //Must have produced 1000 messages
cs.map(_.size).sum should ===(dequeueN) //Must have consumed all produced messages
//No message is allowed to be consumed by more than one consumer
cs.flatten.distinct.size should ===(dequeueN)
//All consumed messages should have been produced
(cs.flatten diff ps.flatten).size should ===(0)
//The ones that were produced and not consumed
(ps.flatten diff cs.flatten).size should ===(enqueueN - dequeueN)
} }
val producers = {
val step = 500
val ps = for (i (1 to enqueueN by step).toList) yield createProducer(i, Math.min(enqueueN, i + step - 1))
if (parallel == false)
ps foreach { Await.ready(_, remainingOrDefault) }
ps
}
def createConsumer: Future[Vector[Envelope]] = spawn {
var r = Vector[Envelope]()
while (producers.exists(_.isCompleted == false) || q.hasMessages)
Option(q.dequeue) foreach { message r = r :+ message }
r
}
val consumers = List.fill(maxConsumers)(createConsumer)
val ps = producers.map(Await.result(_, remainingOrDefault))
val cs = consumers.map(Await.result(_, remainingOrDefault))
ps.map(_.size).sum should ===(enqueueN) //Must have produced 1000 messages
cs.map(_.size).sum should ===(dequeueN) //Must have consumed all produced messages
//No message is allowed to be consumed by more than one consumer
cs.flatten.distinct.size should ===(dequeueN)
//All consumed messages should have been produced
(cs.flatten diff ps.flatten).size should ===(0)
//The ones that were produced and not consumed
(ps.flatten diff cs.flatten).size should ===(enqueueN - dequeueN)
}
} }
} }

View file

@ -10,8 +10,8 @@ import org.scalatest.BeforeAndAfterEach
import akka.testkit._ import akka.testkit._
import scala.concurrent.duration._ import scala.concurrent.duration._
import akka.actor.{ Props, Actor, ActorRef, ActorSystem, PoisonPill} import akka.actor.{ Props, Actor, ActorRef, ActorSystem, PoisonPill }
import akka.japi.{ Procedure} import akka.japi.{ Procedure }
import com.typesafe.config.{ Config, ConfigFactory } import com.typesafe.config.{ Config, ConfigFactory }
object EventBusSpec { object EventBusSpec {

View file

@ -117,10 +117,10 @@ object LoggerSpec {
override def mdc(currentMessage: Any): MDC = { override def mdc(currentMessage: Any): MDC = {
reqId += 1 reqId += 1
val always = Map("requestId" -> reqId) val always = Map("requestId" reqId)
val cmim = "Current Message in MDC" val cmim = "Current Message in MDC"
val perMessage = currentMessage match { val perMessage = currentMessage match {
case `cmim` Map[String, Any]("currentMsg" -> cmim, "currentMsgLength" -> cmim.length) case `cmim` Map[String, Any]("currentMsg" cmim, "currentMsgLength" cmim.length)
case _ Map() case _ Map()
} }
always ++ perMessage always ++ perMessage

View file

@ -28,9 +28,9 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterAll {
akka.loglevel=DEBUG akka.loglevel=DEBUG
akka.actor.serialize-messages = off # debug noise from serialization akka.actor.serialize-messages = off # debug noise from serialization
""").withFallback(AkkaSpec.testConf) """).withFallback(AkkaSpec.testConf)
val appLogging = ActorSystem("logging", ConfigFactory.parseMap(Map("akka.actor.debug.receive" -> true).asJava).withFallback(config)) val appLogging = ActorSystem("logging", ConfigFactory.parseMap(Map("akka.actor.debug.receive" true).asJava).withFallback(config))
val appAuto = ActorSystem("autoreceive", ConfigFactory.parseMap(Map("akka.actor.debug.autoreceive" -> true).asJava).withFallback(config)) val appAuto = ActorSystem("autoreceive", ConfigFactory.parseMap(Map("akka.actor.debug.autoreceive" true).asJava).withFallback(config))
val appLifecycle = ActorSystem("lifecycle", ConfigFactory.parseMap(Map("akka.actor.debug.lifecycle" -> true).asJava).withFallback(config)) val appLifecycle = ActorSystem("lifecycle", ConfigFactory.parseMap(Map("akka.actor.debug.lifecycle" true).asJava).withFallback(config))
val filter = TestEvent.Mute(EventFilter.custom { val filter = TestEvent.Mute(EventFilter.custom {
case _: Logging.Debug true case _: Logging.Debug true

View file

@ -360,11 +360,10 @@ class TcpConnectionSpec extends AkkaSpec("""
"respect pull mode" in new EstablishedConnectionTest(pullMode = true) { "respect pull mode" in new EstablishedConnectionTest(pullMode = true) {
// override config to decrease default buffer size // override config to decrease default buffer size
val config = def config =
ConfigFactory.load( ConfigFactory.parseString("akka.io.tcp.direct-buffer-size = 1k")
ConfigFactory.parseString("akka.io.tcp.direct-buffer-size = 1k") .withFallback(AkkaSpec.testConf)
.withFallback(AkkaSpec.testConf)) override implicit lazy val system: ActorSystem = ActorSystem("respectPullModeTest", config)
override implicit def system: ActorSystem = ActorSystem("respectPullModeTest", config)
try run { try run {
val maxBufferSize = 1 * 1024 val maxBufferSize = 1 * 1024
@ -402,7 +401,7 @@ class TcpConnectionSpec extends AkkaSpec("""
connectionHandler.expectMsgType[Received].data.decodeString("ASCII") should ===(vs) connectionHandler.expectMsgType[Received].data.decodeString("ASCII") should ===(vs)
} }
finally system.terminate() finally shutdown(system)
} }
"close the connection and reply with `Closed` upon reception of a `Close` command" in "close the connection and reply with `Closed` upon reception of a `Close` command" in
@ -887,10 +886,11 @@ class TcpConnectionSpec extends AkkaSpec("""
def setServerSocketOptions() = () def setServerSocketOptions() = ()
def createConnectionActor(serverAddress: InetSocketAddress = serverAddress, def createConnectionActor(
options: immutable.Seq[SocketOption] = Nil, serverAddress: InetSocketAddress = serverAddress,
timeout: Option[FiniteDuration] = None, options: immutable.Seq[SocketOption] = Nil,
pullMode: Boolean = false): TestActorRef[TcpOutgoingConnection] = { timeout: Option[FiniteDuration] = None,
pullMode: Boolean = false): TestActorRef[TcpOutgoingConnection] = {
val ref = createConnectionActorWithoutRegistration(serverAddress, options, timeout, pullMode) val ref = createConnectionActorWithoutRegistration(serverAddress, options, timeout, pullMode)
ref ! newChannelRegistration ref ! newChannelRegistration
ref ref
@ -902,10 +902,11 @@ class TcpConnectionSpec extends AkkaSpec("""
def disableInterest(op: Int): Unit = interestCallReceiver.ref ! -op def disableInterest(op: Int): Unit = interestCallReceiver.ref ! -op
} }
def createConnectionActorWithoutRegistration(serverAddress: InetSocketAddress = serverAddress, def createConnectionActorWithoutRegistration(
options: immutable.Seq[SocketOption] = Nil, serverAddress: InetSocketAddress = serverAddress,
timeout: Option[FiniteDuration] = None, options: immutable.Seq[SocketOption] = Nil,
pullMode: Boolean = false): TestActorRef[TcpOutgoingConnection] = timeout: Option[FiniteDuration] = None,
pullMode: Boolean = false): TestActorRef[TcpOutgoingConnection] =
TestActorRef( TestActorRef(
new TcpOutgoingConnection(Tcp(system), this, userHandler.ref, new TcpOutgoingConnection(Tcp(system), this, userHandler.ref,
Connect(serverAddress, options = options, timeout = timeout, pullMode = pullMode)) { Connect(serverAddress, options = options, timeout = timeout, pullMode = pullMode)) {
@ -932,8 +933,8 @@ class TcpConnectionSpec extends AkkaSpec("""
abstract class EstablishedConnectionTest( abstract class EstablishedConnectionTest(
keepOpenOnPeerClosed: Boolean = false, keepOpenOnPeerClosed: Boolean = false,
useResumeWriting: Boolean = true, useResumeWriting: Boolean = true,
pullMode: Boolean = false) pullMode: Boolean = false)
extends UnacceptedConnectionTest(pullMode) { extends UnacceptedConnectionTest(pullMode) {
// lazy init since potential exceptions should not be triggered in the constructor but during execution of `run` // lazy init since potential exceptions should not be triggered in the constructor but during execution of `run`
@ -1075,7 +1076,7 @@ class TcpConnectionSpec extends AkkaSpec("""
} }
val interestsNames = val interestsNames =
Seq(OP_ACCEPT -> "accepting", OP_CONNECT -> "connecting", OP_READ -> "reading", OP_WRITE -> "writing") Seq(OP_ACCEPT "accepting", OP_CONNECT "connecting", OP_READ "reading", OP_WRITE "writing")
def interestsDesc(interests: Int): String = def interestsDesc(interests: Int): String =
interestsNames.filter(i (i._1 & interests) != 0).map(_._2).mkString(", ") interestsNames.filter(i (i._1 & interests) != 0).map(_._2).mkString(", ")

View file

@ -185,11 +185,11 @@ class TcpIntegrationSpec extends AkkaSpec("""
} }
def chitchat( def chitchat(
clientHandler: TestProbe, clientHandler: TestProbe,
clientConnection: ActorRef, clientConnection: ActorRef,
serverHandler: TestProbe, serverHandler: TestProbe,
serverConnection: ActorRef, serverConnection: ActorRef,
rounds: Int = 100) = { rounds: Int = 100) = {
val testData = ByteString(0) val testData = ByteString(0)
(1 to rounds) foreach { _ (1 to rounds) foreach { _

View file

@ -213,7 +213,7 @@ class AskSpec extends AkkaSpec {
val act = system.actorOf(Props(new Actor { val act = system.actorOf(Props(new Actor {
def receive = { def receive = {
case msg p.ref ! sender() -> msg case msg p.ref ! sender() msg
} }
})) }))

View file

@ -44,9 +44,10 @@ object MetricsBasedResizerSpec {
var msgs: Set[TestLatch] = Set() var msgs: Set[TestLatch] = Set()
def mockSend(await: Boolean, def mockSend(
l: TestLatch = TestLatch(), await: Boolean,
routeeIdx: Int = Random.nextInt(routees.length)): Latches = { l: TestLatch = TestLatch(),
routeeIdx: Int = Random.nextInt(routees.length)): Latches = {
val target = routees(routeeIdx) val target = routees(routeeIdx)
val first = TestLatch() val first = TestLatch()
val latches = Latches(first, l) val latches = Latches(first, l)

View file

@ -50,7 +50,7 @@ class RandomSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
val counter = new AtomicInteger val counter = new AtomicInteger
var replies = Map.empty[Int, Int] var replies = Map.empty[Int, Int]
for (i 0 until connectionCount) { for (i 0 until connectionCount) {
replies = replies + (i -> 0) replies = replies + (i 0)
} }
val actor = system.actorOf(RandomPool(connectionCount).props(routeeProps = val actor = system.actorOf(RandomPool(connectionCount).props(routeeProps =
@ -65,7 +65,7 @@ class RandomSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
for (i 0 until iterationCount) { for (i 0 until iterationCount) {
for (k 0 until connectionCount) { for (k 0 until connectionCount) {
val id = Await.result((actor ? "hit").mapTo[Int], timeout.duration) val id = Await.result((actor ? "hit").mapTo[Int], timeout.duration)
replies = replies + (id -> (replies(id) + 1)) replies = replies + (id (replies(id) + 1))
} }
} }

View file

@ -64,7 +64,7 @@ class RoundRobinSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
for (_ 1 to iterationCount; _ 1 to connectionCount) { for (_ 1 to iterationCount; _ 1 to connectionCount) {
val id = Await.result((actor ? "hit").mapTo[Int], timeout.duration) val id = Await.result((actor ? "hit").mapTo[Int], timeout.duration)
replies = replies + (id -> (replies(id) + 1)) replies = replies + (id (replies(id) + 1))
} }
counter.get should ===(connectionCount) counter.get should ===(connectionCount)
@ -138,7 +138,7 @@ class RoundRobinSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
for (_ 1 to iterationCount; _ 1 to connectionCount) { for (_ 1 to iterationCount; _ 1 to connectionCount) {
val id = Await.result((actor ? "hit").mapTo[String], timeout.duration) val id = Await.result((actor ? "hit").mapTo[String], timeout.duration)
replies = replies + (id -> (replies(id) + 1)) replies = replies + (id (replies(id) + 1))
} }
actor ! akka.routing.Broadcast("end") actor ! akka.routing.Broadcast("end")
@ -184,7 +184,7 @@ class RoundRobinSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
for (_ 1 to iterationCount; _ 1 to connectionCount) { for (_ 1 to iterationCount; _ 1 to connectionCount) {
val id = Await.result((actor ? "hit").mapTo[String], timeout.duration) val id = Await.result((actor ? "hit").mapTo[String], timeout.duration)
replies = replies + (id -> (replies(id) + 1)) replies = replies + (id (replies(id) + 1))
} }
watch(actor) watch(actor)

View file

@ -342,7 +342,8 @@ class SerializationCompatibilitySpec extends AkkaSpec(SerializationTests.mostlyR
"be preserved for the Create SystemMessage" in { "be preserved for the Create SystemMessage" in {
// Using null as the cause to avoid a large serialized message and JDK differences // Using null as the cause to avoid a large serialized message and JDK differences
verify(Create(Some(null)), verify(
Create(Some(null)),
if (scala.util.Properties.versionNumberString.startsWith("2.10.")) { if (scala.util.Properties.versionNumberString.startsWith("2.10.")) {
"aced00057372001b616b6b612e64697370617463682e7379736d73672e4372656174650000000000" + "aced00057372001b616b6b612e64697370617463682e7379736d73672e4372656174650000000000" +
"0000010200014c00076661696c75726574000e4c7363616c612f4f7074696f6e3b78707372000a73" + "0000010200014c00076661696c75726574000e4c7363616c612f4f7074696f6e3b78707372000a73" +
@ -356,53 +357,62 @@ class SerializationCompatibilitySpec extends AkkaSpec(SerializationTests.mostlyR
}) })
} }
"be preserved for the Recreate SystemMessage" in { "be preserved for the Recreate SystemMessage" in {
verify(Recreate(null), verify(
Recreate(null),
"aced00057372001d616b6b612e64697370617463682e7379736d73672e5265637265617465000000" + "aced00057372001d616b6b612e64697370617463682e7379736d73672e5265637265617465000000" +
"00000000010200014c000563617573657400154c6a6176612f6c616e672f5468726f7761626c653b" + "00000000010200014c000563617573657400154c6a6176612f6c616e672f5468726f7761626c653b" +
"787070") "787070")
} }
"be preserved for the Suspend SystemMessage" in { "be preserved for the Suspend SystemMessage" in {
verify(Suspend(), verify(
Suspend(),
"aced00057372001c616b6b612e64697370617463682e7379736d73672e53757370656e6400000000" + "aced00057372001c616b6b612e64697370617463682e7379736d73672e53757370656e6400000000" +
"000000010200007870") "000000010200007870")
} }
"be preserved for the Resume SystemMessage" in { "be preserved for the Resume SystemMessage" in {
verify(Resume(null), verify(
Resume(null),
"aced00057372001b616b6b612e64697370617463682e7379736d73672e526573756d650000000000" + "aced00057372001b616b6b612e64697370617463682e7379736d73672e526573756d650000000000" +
"0000010200014c000f63617573656442794661696c7572657400154c6a6176612f6c616e672f5468" + "0000010200014c000f63617573656442794661696c7572657400154c6a6176612f6c616e672f5468" +
"726f7761626c653b787070") "726f7761626c653b787070")
} }
"be preserved for the Terminate SystemMessage" in { "be preserved for the Terminate SystemMessage" in {
verify(Terminate(), verify(
Terminate(),
"aced00057372001e616b6b612e64697370617463682e7379736d73672e5465726d696e6174650000" + "aced00057372001e616b6b612e64697370617463682e7379736d73672e5465726d696e6174650000" +
"0000000000010200007870") "0000000000010200007870")
} }
"be preserved for the Supervise SystemMessage" in { "be preserved for the Supervise SystemMessage" in {
verify(Supervise(null, true), verify(
Supervise(null, true),
"aced00057372001e616b6b612e64697370617463682e7379736d73672e5375706572766973650000" + "aced00057372001e616b6b612e64697370617463682e7379736d73672e5375706572766973650000" +
"0000000000010200025a00056173796e634c00056368696c647400154c616b6b612f6163746f722f" + "0000000000010200025a00056173796e634c00056368696c647400154c616b6b612f6163746f722f" +
"4163746f725265663b78700170") "4163746f725265663b78700170")
} }
"be preserved for the Watch SystemMessage" in { "be preserved for the Watch SystemMessage" in {
verify(Watch(null, null), verify(
Watch(null, null),
"aced00057372001a616b6b612e64697370617463682e7379736d73672e5761746368000000000000" + "aced00057372001a616b6b612e64697370617463682e7379736d73672e5761746368000000000000" +
"00010200024c00077761746368656574001d4c616b6b612f6163746f722f496e7465726e616c4163" + "00010200024c00077761746368656574001d4c616b6b612f6163746f722f496e7465726e616c4163" +
"746f725265663b4c00077761746368657271007e000178707070") "746f725265663b4c00077761746368657271007e000178707070")
} }
"be preserved for the Unwatch SystemMessage" in { "be preserved for the Unwatch SystemMessage" in {
verify(Unwatch(null, null), verify(
Unwatch(null, null),
"aced00057372001c616b6b612e64697370617463682e7379736d73672e556e776174636800000000" + "aced00057372001c616b6b612e64697370617463682e7379736d73672e556e776174636800000000" +
"000000010200024c0007776174636865657400154c616b6b612f6163746f722f4163746f72526566" + "000000010200024c0007776174636865657400154c616b6b612f6163746f722f4163746f72526566" +
"3b4c00077761746368657271007e000178707070") "3b4c00077761746368657271007e000178707070")
} }
"be preserved for the NoMessage SystemMessage" in { "be preserved for the NoMessage SystemMessage" in {
verify(NoMessage, verify(
NoMessage,
"aced00057372001f616b6b612e64697370617463682e7379736d73672e4e6f4d6573736167652400" + "aced00057372001f616b6b612e64697370617463682e7379736d73672e4e6f4d6573736167652400" +
"000000000000010200007870") "000000000000010200007870")
} }
"be preserved for the Failed SystemMessage" in { "be preserved for the Failed SystemMessage" in {
// Using null as the cause to avoid a large serialized message and JDK differences // Using null as the cause to avoid a large serialized message and JDK differences
verify(Failed(null, cause = null, uid = 0), verify(
Failed(null, cause = null, uid = 0),
"aced00057372001b616b6b612e64697370617463682e7379736d73672e4661696c65640000000000" + "aced00057372001b616b6b612e64697370617463682e7379736d73672e4661696c65640000000000" +
"0000010200034900037569644c000563617573657400154c6a6176612f6c616e672f5468726f7761" + "0000010200034900037569644c000563617573657400154c6a6176612f6c616e672f5468726f7761" +
"626c653b4c00056368696c647400154c616b6b612f6163746f722f4163746f725265663b78700000" + "626c653b4c00056368696c647400154c616b6b612f6163746f722f4163746f725265663b78700000" +

View file

@ -121,7 +121,7 @@ class ByteStringSpec extends WordSpec with Matchers with Checkers {
val (bsAIt, bsBIt) = (a.iterator, b.iterator) val (bsAIt, bsBIt) = (a.iterator, b.iterator)
val (vecAIt, vecBIt) = (Vector(a: _*).iterator.buffered, Vector(b: _*).iterator.buffered) val (vecAIt, vecBIt) = (Vector(a: _*).iterator.buffered, Vector(b: _*).iterator.buffered)
(body(bsAIt, bsBIt) == body(vecAIt, vecBIt)) && (body(bsAIt, bsBIt) == body(vecAIt, vecBIt)) &&
(!strict || (bsAIt.toSeq -> bsBIt.toSeq) == (vecAIt.toSeq -> vecBIt.toSeq)) (!strict || (bsAIt.toSeq bsBIt.toSeq) == (vecAIt.toSeq vecBIt.toSeq))
} }
def likeVecBld(body: Builder[Byte, _] Unit): Boolean = { def likeVecBld(body: Builder[Byte, _] Unit): Boolean = {

View file

@ -15,16 +15,16 @@ class PrettyDurationSpec extends FlatSpec with Matchers {
import scala.concurrent.duration._ import scala.concurrent.duration._
val cases: Seq[(Duration, String)] = val cases: Seq[(Duration, String)] =
9.nanos -> "9.000 ns" :: 9.nanos "9.000 ns" ::
95.nanos -> "95.00 ns" :: 95.nanos "95.00 ns" ::
999.nanos -> "999.0 ns" :: 999.nanos "999.0 ns" ::
1000.nanos -> "1.000 μs" :: 1000.nanos "1.000 μs" ::
9500.nanos -> "9.500 μs" :: 9500.nanos "9.500 μs" ::
9500.micros -> "9.500 ms" :: 9500.micros "9.500 ms" ::
9500.millis -> "9.500 s" :: 9500.millis "9.500 s" ::
95.seconds -> "1.583 min" :: 95.seconds "1.583 min" ::
95.minutes -> "1.583 h" :: 95.minutes "1.583 h" ::
95.hours -> "3.958 d" :: 95.hours "3.958 d" ::
Nil Nil
cases foreach { cases foreach {

View file

@ -66,9 +66,10 @@ abstract class AbstractFSM[S, D] extends FSM[S, D] {
* @param stateTimeout default state timeout for this state * @param stateTimeout default state timeout for this state
* @param stateFunctionBuilder partial function builder describing response to input * @param stateFunctionBuilder partial function builder describing response to input
*/ */
final def when(stateName: S, final def when(
stateTimeout: FiniteDuration, stateName: S,
stateFunctionBuilder: FSMStateFunctionBuilder[S, D]): Unit = stateTimeout: FiniteDuration,
stateFunctionBuilder: FSMStateFunctionBuilder[S, D]): Unit =
when(stateName, stateTimeout)(stateFunctionBuilder.build()) when(stateName, stateTimeout)(stateFunctionBuilder.build())
/** /**

View file

@ -87,7 +87,7 @@ private[akka] trait AbstractProps {
if (i == declaredConstructors.length) false if (i == declaredConstructors.length) false
else { else {
val c = declaredConstructors(i) val c = declaredConstructors(i)
if (c.getParameterCount >= 1 && c.getParameterTypes()(i) == enclosingClass) if (c.getParameterCount >= 1 && c.getParameterTypes()(0) == enclosingClass)
true true
else else
loop(i + 1) // recur loop(i + 1) // recur

View file

@ -96,7 +96,7 @@ final case class ActorIdentity(correlationId: Any, ref: Option[ActorRef]) {
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class Terminated private[akka] (@BeanProperty actor: ActorRef)( final case class Terminated private[akka] (@BeanProperty actor: ActorRef)(
@BeanProperty val existenceConfirmed: Boolean, @BeanProperty val existenceConfirmed: Boolean,
@BeanProperty val addressTerminated: Boolean) @BeanProperty val addressTerminated: Boolean)
extends AutoReceivedMessage with PossiblyHarmful with DeadLetterSuppression extends AutoReceivedMessage with PossiblyHarmful with DeadLetterSuppression
/** /**
@ -189,7 +189,8 @@ object ActorInitializationException {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class PreRestartException private[akka] (actor: ActorRef, cause: Throwable, originalCause: Throwable, messageOption: Option[Any]) final case class PreRestartException private[akka] (actor: ActorRef, cause: Throwable, originalCause: Throwable, messageOption: Option[Any])
extends ActorInitializationException(actor, extends ActorInitializationException(
actor,
"exception in preRestart(" + "exception in preRestart(" +
(if (originalCause == null) "null" else originalCause.getClass) + ", " + (if (originalCause == null) "null" else originalCause.getClass) + ", " +
(messageOption match { case Some(m: AnyRef) m.getClass; case _ "None" }) + (messageOption match { case Some(m: AnyRef) m.getClass; case _ "None" }) +
@ -205,7 +206,8 @@ final case class PreRestartException private[akka] (actor: ActorRef, cause: Thro
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class PostRestartException private[akka] (actor: ActorRef, cause: Throwable, originalCause: Throwable) final case class PostRestartException private[akka] (actor: ActorRef, cause: Throwable, originalCause: Throwable)
extends ActorInitializationException(actor, extends ActorInitializationException(
actor,
"exception post restart (" + (if (originalCause == null) "null" else originalCause.getClass) + ")", cause) "exception post restart (" + (if (originalCause == null) "null" else originalCause.getClass) + ")", cause)
/** /**

View file

@ -372,11 +372,11 @@ private[akka] object ActorCell {
* for! (waves hand) * for! (waves hand)
*/ */
private[akka] class ActorCell( private[akka] class ActorCell(
val system: ActorSystemImpl, val system: ActorSystemImpl,
val self: InternalActorRef, val self: InternalActorRef,
final val props: Props, // Must be final so that it can be properly cleared in clearActorCellFields final val props: Props, // Must be final so that it can be properly cleared in clearActorCellFields
val dispatcher: MessageDispatcher, val dispatcher: MessageDispatcher,
val parent: InternalActorRef) val parent: InternalActorRef)
extends UntypedActorContext with AbstractActorContext with Cell extends UntypedActorContext with AbstractActorContext with Cell
with dungeon.ReceiveTimeout with dungeon.ReceiveTimeout
with dungeon.Children with dungeon.Children
@ -598,7 +598,8 @@ private[akka] class ActorCell(
case NonFatal(e) case NonFatal(e)
clearOutActorIfNonNull() clearOutActorIfNonNull()
e match { e match {
case i: InstantiationException throw ActorInitializationException(self, case i: InstantiationException throw ActorInitializationException(
self,
"""exception during creation, this problem is likely to occur because the class of the Actor you tried to create is either, """exception during creation, this problem is likely to occur because the class of the Actor you tried to create is either,
a non-static inner class (in which case make it a static inner class or use Props(new ...) or Props( new Creator ... ) a non-static inner class (in which case make it a static inner class or use Props(new ...) or Props( new Creator ... )
or is missing an appropriate, reachable no-args constructor. or is missing an appropriate, reachable no-args constructor.

View file

@ -254,7 +254,8 @@ sealed trait ActorPath extends Comparable[ActorPath] with Serializable {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class RootActorPath(address: Address, name: String = "/") extends ActorPath { final case class RootActorPath(address: Address, name: String = "/") extends ActorPath {
require(name.length == 1 || name.indexOf('/', 1) == -1, require(
name.length == 1 || name.indexOf('/', 1) == -1,
"/ may only exist at the beginning of the root actors name, " + "/ may only exist at the beginning of the root actors name, " +
"it is a path separator and is not legal in ActorPath names: [%s]" format name) "it is a path separator and is not legal in ActorPath names: [%s]" format name)
require(name.indexOf('#') == -1, "# is a fragment separator and is not legal in ActorPath names: [%s]" format name) require(name.indexOf('#') == -1, "# is a fragment separator and is not legal in ActorPath names: [%s]" format name)

View file

@ -302,11 +302,11 @@ private[akka] case object Nobody extends MinimalActorRef {
* INTERNAL API * INTERNAL API
*/ */
private[akka] class LocalActorRef private[akka] ( private[akka] class LocalActorRef private[akka] (
_system: ActorSystemImpl, _system: ActorSystemImpl,
_props: Props, _props: Props,
_dispatcher: MessageDispatcher, _dispatcher: MessageDispatcher,
_mailboxType: MailboxType, _mailboxType: MailboxType,
_supervisor: InternalActorRef, _supervisor: InternalActorRef,
override val path: ActorPath) override val path: ActorPath)
extends ActorRefWithCell with LocalRef { extends ActorRefWithCell with LocalRef {
@ -518,9 +518,10 @@ private[akka] object DeadLetterActorRef {
* *
* INTERNAL API * INTERNAL API
*/ */
private[akka] class EmptyLocalActorRef(override val provider: ActorRefProvider, private[akka] class EmptyLocalActorRef(
override val path: ActorPath, override val provider: ActorRefProvider,
val eventStream: EventStream) extends MinimalActorRef { override val path: ActorPath,
val eventStream: EventStream) extends MinimalActorRef {
@deprecated("Use context.watch(actor) and receive Terminated(actor)", "2.2") @deprecated("Use context.watch(actor) and receive Terminated(actor)", "2.2")
override private[akka] def isTerminated = true override private[akka] def isTerminated = true
@ -570,9 +571,10 @@ private[akka] class EmptyLocalActorRef(override val provider: ActorRefProvider,
* *
* INTERNAL API * INTERNAL API
*/ */
private[akka] class DeadLetterActorRef(_provider: ActorRefProvider, private[akka] class DeadLetterActorRef(
_path: ActorPath, _provider: ActorRefProvider,
_eventStream: EventStream) extends EmptyLocalActorRef(_provider, _path, _eventStream) { _path: ActorPath,
_eventStream: EventStream) extends EmptyLocalActorRef(_provider, _path, _eventStream) {
override def !(message: Any)(implicit sender: ActorRef = this): Unit = message match { override def !(message: Any)(implicit sender: ActorRef = this): Unit = message match {
case null throw new InvalidMessageException("Message is null") case null throw new InvalidMessageException("Message is null")
@ -601,10 +603,10 @@ private[akka] class DeadLetterActorRef(_provider: ActorRefProvider,
* INTERNAL API * INTERNAL API
*/ */
private[akka] class VirtualPathContainer( private[akka] class VirtualPathContainer(
override val provider: ActorRefProvider, override val provider: ActorRefProvider,
override val path: ActorPath, override val path: ActorPath,
override val getParent: InternalActorRef, override val getParent: InternalActorRef,
val log: LoggingAdapter) extends MinimalActorRef { val log: LoggingAdapter) extends MinimalActorRef {
private val children = new ConcurrentHashMap[String, InternalActorRef] private val children = new ConcurrentHashMap[String, InternalActorRef]
@ -705,10 +707,11 @@ private[akka] class VirtualPathContainer(
* When using the watch() feature you must ensure that upon reception of the * When using the watch() feature you must ensure that upon reception of the
* Terminated message the watched actorRef is unwatch()ed. * Terminated message the watched actorRef is unwatch()ed.
*/ */
private[akka] final class FunctionRef(override val path: ActorPath, private[akka] final class FunctionRef(
override val provider: ActorRefProvider, override val path: ActorPath,
val eventStream: EventStream, override val provider: ActorRefProvider,
f: (ActorRef, Any) Unit) extends MinimalActorRef { val eventStream: EventStream,
f: (ActorRef, Any) Unit) extends MinimalActorRef {
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = { override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = {
f(sender, message) f(sender, message)

View file

@ -105,14 +105,14 @@ trait ActorRefProvider {
* the latter can be suppressed by setting ``lookupDeploy`` to ``false``. * the latter can be suppressed by setting ``lookupDeploy`` to ``false``.
*/ */
def actorOf( def actorOf(
system: ActorSystemImpl, system: ActorSystemImpl,
props: Props, props: Props,
supervisor: InternalActorRef, supervisor: InternalActorRef,
path: ActorPath, path: ActorPath,
systemService: Boolean, systemService: Boolean,
deploy: Option[Deploy], deploy: Option[Deploy],
lookupDeploy: Boolean, lookupDeploy: Boolean,
async: Boolean): InternalActorRef async: Boolean): InternalActorRef
/** /**
* INTERNAL API * INTERNAL API
@ -475,20 +475,22 @@ private[akka] object LocalActorRefProvider {
* Depending on this class is not supported, only the [[ActorRefProvider]] interface is supported. * Depending on this class is not supported, only the [[ActorRefProvider]] interface is supported.
*/ */
private[akka] class LocalActorRefProvider private[akka] ( private[akka] class LocalActorRefProvider private[akka] (
_systemName: String, _systemName: String,
override val settings: ActorSystem.Settings, override val settings: ActorSystem.Settings,
val eventStream: EventStream, val eventStream: EventStream,
val dynamicAccess: DynamicAccess, val dynamicAccess: DynamicAccess,
override val deployer: Deployer, override val deployer: Deployer,
_deadLetters: Option[ActorPath InternalActorRef]) _deadLetters: Option[ActorPath InternalActorRef])
extends ActorRefProvider { extends ActorRefProvider {
// this is the constructor needed for reflectively instantiating the provider // this is the constructor needed for reflectively instantiating the provider
def this(_systemName: String, def this(
settings: ActorSystem.Settings, _systemName: String,
eventStream: EventStream, settings: ActorSystem.Settings,
dynamicAccess: DynamicAccess) = eventStream: EventStream,
this(_systemName, dynamicAccess: DynamicAccess) =
this(
_systemName,
settings, settings,
eventStream, eventStream,
dynamicAccess, dynamicAccess,
@ -776,7 +778,8 @@ private[akka] class LocalActorRefProvider private[akka] (
if (!system.dispatchers.hasDispatcher(r.routerDispatcher)) if (!system.dispatchers.hasDispatcher(r.routerDispatcher))
throw new ConfigurationException(s"Dispatcher [${p.dispatcher}] not configured for router of $path") throw new ConfigurationException(s"Dispatcher [${p.dispatcher}] not configured for router of $path")
val routerProps = Props(p.deploy.copy(dispatcher = p.routerConfig.routerDispatcher), val routerProps = Props(
p.deploy.copy(dispatcher = p.routerConfig.routerDispatcher),
classOf[RoutedActorCell.RouterActorCreator], Vector(p.routerConfig)) classOf[RoutedActorCell.RouterActorCreator], Vector(p.routerConfig))
val routeeProps = p.withRouter(NoRouter) val routeeProps = p.withRouter(NoRouter)

View file

@ -218,7 +218,8 @@ object ActorSelection {
if (matchingChildren.isEmpty && !sel.wildcardFanOut) if (matchingChildren.isEmpty && !sel.wildcardFanOut)
emptyRef.tell(sel, sender) emptyRef.tell(sel, sender)
else { else {
val m = sel.copy(elements = iter.toVector, val m = sel.copy(
elements = iter.toVector,
wildcardFanOut = sel.wildcardFanOut || matchingChildren.size > 1) wildcardFanOut = sel.wildcardFanOut || matchingChildren.size > 1)
matchingChildren.foreach(c deliverSelection(c.asInstanceOf[InternalActorRef], sender, m)) matchingChildren.foreach(c deliverSelection(c.asInstanceOf[InternalActorRef], sender, m))
} }
@ -253,8 +254,8 @@ trait ScalaActorSelection {
*/ */
@SerialVersionUID(2L) // it has protobuf serialization in akka-remote @SerialVersionUID(2L) // it has protobuf serialization in akka-remote
private[akka] final case class ActorSelectionMessage( private[akka] final case class ActorSelectionMessage(
msg: Any, msg: Any,
elements: immutable.Iterable[SelectionPathElement], elements: immutable.Iterable[SelectionPathElement],
wildcardFanOut: Boolean) wildcardFanOut: Boolean)
extends AutoReceivedMessage with PossiblyHarmful { extends AutoReceivedMessage with PossiblyHarmful {

View file

@ -505,11 +505,11 @@ abstract class ExtendedActorSystem extends ActorSystem {
} }
private[akka] class ActorSystemImpl( private[akka] class ActorSystemImpl(
val name: String, val name: String,
applicationConfig: Config, applicationConfig: Config,
classLoader: ClassLoader, classLoader: ClassLoader,
defaultExecutionContext: Option[ExecutionContext], defaultExecutionContext: Option[ExecutionContext],
val guardianProps: Option[Props]) extends ExtendedActorSystem { val guardianProps: Option[Props]) extends ExtendedActorSystem {
if (!name.matches("""^[a-zA-Z0-9][a-zA-Z0-9-_]*$""")) if (!name.matches("""^[a-zA-Z0-9][a-zA-Z0-9-_]*$"""))
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -593,7 +593,7 @@ private[akka] class ActorSystemImpl(
eventStream.startStdoutLogger(settings) eventStream.startStdoutLogger(settings)
val logFilter: LoggingFilter = { val logFilter: LoggingFilter = {
val arguments = Vector(classOf[Settings] -> settings, classOf[EventStream] -> eventStream) val arguments = Vector(classOf[Settings] settings, classOf[EventStream] eventStream)
dynamicAccess.createInstanceFor[LoggingFilter](LoggingFilter, arguments).get dynamicAccess.createInstanceFor[LoggingFilter](LoggingFilter, arguments).get
} }
@ -603,10 +603,10 @@ private[akka] class ActorSystemImpl(
val provider: ActorRefProvider = try { val provider: ActorRefProvider = try {
val arguments = Vector( val arguments = Vector(
classOf[String] -> name, classOf[String] name,
classOf[Settings] -> settings, classOf[Settings] settings,
classOf[EventStream] -> eventStream, classOf[EventStream] eventStream,
classOf[DynamicAccess] -> dynamicAccess) classOf[DynamicAccess] dynamicAccess)
dynamicAccess.createInstanceFor[ActorRefProvider](ProviderClass, arguments).get dynamicAccess.createInstanceFor[ActorRefProvider](ProviderClass, arguments).get
} catch { } catch {
@ -698,9 +698,9 @@ private[akka] class ActorSystemImpl(
*/ */
protected def createScheduler(): Scheduler = protected def createScheduler(): Scheduler =
dynamicAccess.createInstanceFor[Scheduler](settings.SchedulerClass, immutable.Seq( dynamicAccess.createInstanceFor[Scheduler](settings.SchedulerClass, immutable.Seq(
classOf[Config] -> settings.config, classOf[Config] settings.config,
classOf[LoggingAdapter] -> log, classOf[LoggingAdapter] log,
classOf[ThreadFactory] -> threadFactory.withName(threadFactory.name + "-scheduler"))).get classOf[ThreadFactory] threadFactory.withName(threadFactory.name + "-scheduler"))).get
//#create-scheduler //#create-scheduler
/* /*
@ -767,12 +767,12 @@ private[akka] class ActorSystemImpl(
def loadExtensions(key: String, throwOnLoadFail: Boolean): Unit = { def loadExtensions(key: String, throwOnLoadFail: Boolean): Unit = {
immutableSeq(settings.config.getStringList(key)) foreach { fqcn immutableSeq(settings.config.getStringList(key)) foreach { fqcn
dynamicAccess.getObjectFor[AnyRef](fqcn) recoverWith { case _ dynamicAccess.createInstanceFor[AnyRef](fqcn, Nil) } match { dynamicAccess.getObjectFor[AnyRef](fqcn) recoverWith { case _ dynamicAccess.createInstanceFor[AnyRef](fqcn, Nil) } match {
case Success(p: ExtensionIdProvider) registerExtension(p.lookup()) case Success(p: ExtensionIdProvider) registerExtension(p.lookup())
case Success(p: ExtensionId[_]) registerExtension(p) case Success(p: ExtensionId[_]) registerExtension(p)
case Success(other) case Success(other)
if (!throwOnLoadFail) log.error("[{}] is not an 'ExtensionIdProvider' or 'ExtensionId', skipping...", fqcn) if (!throwOnLoadFail) log.error("[{}] is not an 'ExtensionIdProvider' or 'ExtensionId', skipping...", fqcn)
else throw new RuntimeException(s"[$fqcn] is not an 'ExtensionIdProvider' or 'ExtensionId'") else throw new RuntimeException(s"[$fqcn] is not an 'ExtensionIdProvider' or 'ExtensionId'")
case Failure(problem) case Failure(problem)
if (!throwOnLoadFail) log.error(problem, "While trying to load extension [{}], skipping...", fqcn) if (!throwOnLoadFail) log.error(problem, "While trying to load extension [{}], skipping...", fqcn)
else throw new RuntimeException(s"While trying to load extension [$fqcn]", problem) else throw new RuntimeException(s"While trying to load extension [$fqcn]", problem)
} }

View file

@ -35,12 +35,12 @@ object Deploy {
*/ */
@SerialVersionUID(2L) @SerialVersionUID(2L)
final case class Deploy( final case class Deploy(
path: String = "", path: String = "",
config: Config = ConfigFactory.empty, config: Config = ConfigFactory.empty,
routerConfig: RouterConfig = NoRouter, routerConfig: RouterConfig = NoRouter,
scope: Scope = NoScopeGiven, scope: Scope = NoScopeGiven,
dispatcher: String = Deploy.NoDispatcherGiven, dispatcher: String = Deploy.NoDispatcherGiven,
mailbox: String = Deploy.NoMailboxGiven) { mailbox: String = Deploy.NoMailboxGiven) {
/** /**
* Java API to create a Deploy with the given RouterConfig * Java API to create a Deploy with the given RouterConfig
@ -137,7 +137,7 @@ private[akka] class Deployer(val settings: ActorSystem.Settings, val dynamicAcce
protected val default = config.getConfig("default") protected val default = config.getConfig("default")
val routerTypeMapping: Map[String, String] = val routerTypeMapping: Map[String, String] =
settings.config.getConfig("akka.actor.router.type-mapping").root.unwrapped.asScala.collect { settings.config.getConfig("akka.actor.router.type-mapping").root.unwrapped.asScala.collect {
case (key, value: String) (key -> value) case (key, value: String) (key value)
}.toMap }.toMap
config.root.asScala flatMap { config.root.asScala flatMap {
@ -198,8 +198,8 @@ private[akka] class Deployer(val settings: ActorSystem.Settings, val dynamicAcce
s"[${args(0)._1.getName}] and optional [${args(1)._1.getName}] parameter", cause) s"[${args(0)._1.getName}] and optional [${args(1)._1.getName}] parameter", cause)
// first try with Config param, and then with Config and DynamicAccess parameters // first try with Config param, and then with Config and DynamicAccess parameters
val args1 = List(classOf[Config] -> deployment2) val args1 = List(classOf[Config] deployment2)
val args2 = List(classOf[Config] -> deployment2, classOf[DynamicAccess] -> dynamicAccess) val args2 = List(classOf[Config] deployment2, classOf[DynamicAccess] dynamicAccess)
dynamicAccess.createInstanceFor[RouterConfig](fqn, args1).recover({ dynamicAccess.createInstanceFor[RouterConfig](fqn, args1).recover({
case e @ (_: IllegalArgumentException | _: ConfigException) throw e case e @ (_: IllegalArgumentException | _: ConfigException) throw e
case e: NoSuchMethodException case e: NoSuchMethodException

View file

@ -150,5 +150,5 @@ abstract class ExtensionKey[T <: Extension](implicit m: ClassTag[T]) extends Ext
def this(clazz: Class[T]) = this()(ClassTag(clazz)) def this(clazz: Class[T]) = this()(ClassTag(clazz))
override def lookup(): ExtensionId[T] = this override def lookup(): ExtensionId[T] = this
def createExtension(system: ExtendedActorSystem): T = system.dynamicAccess.createInstanceFor[T](m.runtimeClass, List(classOf[ExtendedActorSystem] -> system)).get def createExtension(system: ExtendedActorSystem): T = system.dynamicAccess.createInstanceFor[T](m.runtimeClass, List(classOf[ExtendedActorSystem] system)).get
} }

View file

@ -110,9 +110,10 @@ object FSM {
* This extractor is just convenience for matching a (S, S) pair, including a * This extractor is just convenience for matching a (S, S) pair, including a
* reminder what the new state is. * reminder what the new state is.
*/ */
object -> { object `->` {
def unapply[S](in: (S, S)) = Some(in) def unapply[S](in: (S, S)) = Some(in)
} }
val `→` = `->`
/** /**
* Log Entry of the [[akka.actor.LoggingFSM]], can be obtained by calling `getLog`. * Log Entry of the [[akka.actor.LoggingFSM]], can be obtained by calling `getLog`.
@ -319,7 +320,7 @@ trait FSM[S, D] extends Actor with Listeners with ActorLogging {
* This extractor is just convenience for matching a (S, S) pair, including a * This extractor is just convenience for matching a (S, S) pair, including a
* reminder what the new state is. * reminder what the new state is.
*/ */
val -> = FSM.-> val `->` = FSM.`->`
/** /**
* This case object is received in case of a state timeout. * This case object is received in case of a state timeout.

View file

@ -380,9 +380,9 @@ abstract class SupervisorStrategy {
* @param loggingEnabled the strategy logs the failure if this is enabled (true), by default it is enabled * @param loggingEnabled the strategy logs the failure if this is enabled (true), by default it is enabled
*/ */
case class AllForOneStrategy( case class AllForOneStrategy(
maxNrOfRetries: Int = -1, maxNrOfRetries: Int = -1,
withinTimeRange: Duration = Duration.Inf, withinTimeRange: Duration = Duration.Inf,
override val loggingEnabled: Boolean = true)(val decider: SupervisorStrategy.Decider) override val loggingEnabled: Boolean = true)(val decider: SupervisorStrategy.Decider)
extends SupervisorStrategy { extends SupervisorStrategy {
import SupervisorStrategy._ import SupervisorStrategy._
@ -458,9 +458,9 @@ case class AllForOneStrategy(
* @param loggingEnabled the strategy logs the failure if this is enabled (true), by default it is enabled * @param loggingEnabled the strategy logs the failure if this is enabled (true), by default it is enabled
*/ */
case class OneForOneStrategy( case class OneForOneStrategy(
maxNrOfRetries: Int = -1, maxNrOfRetries: Int = -1,
withinTimeRange: Duration = Duration.Inf, withinTimeRange: Duration = Duration.Inf,
override val loggingEnabled: Boolean = true)(val decider: SupervisorStrategy.Decider) override val loggingEnabled: Boolean = true)(val decider: SupervisorStrategy.Decider)
extends SupervisorStrategy { extends SupervisorStrategy {
/** /**

View file

@ -34,9 +34,10 @@ import akka.dispatch.AbstractNodeQueue
* scheduled possibly one tick later than they could be (if checking that * scheduled possibly one tick later than they could be (if checking that
* now() + delay &lt;= nextTick were done). * now() + delay &lt;= nextTick were done).
*/ */
class LightArrayRevolverScheduler(config: Config, class LightArrayRevolverScheduler(
log: LoggingAdapter, config: Config,
threadFactory: ThreadFactory) log: LoggingAdapter,
threadFactory: ThreadFactory)
extends Scheduler with Closeable { extends Scheduler with Closeable {
import Helpers.Requiring import Helpers.Requiring
@ -88,9 +89,10 @@ class LightArrayRevolverScheduler(config: Config,
} }
} }
override def schedule(initialDelay: FiniteDuration, override def schedule(
delay: FiniteDuration, initialDelay: FiniteDuration,
runnable: Runnable)(implicit executor: ExecutionContext): Cancellable = { delay: FiniteDuration,
runnable: Runnable)(implicit executor: ExecutionContext): Cancellable = {
checkMaxDelay(roundUp(delay).toNanos) checkMaxDelay(roundUp(delay).toNanos)
val preparedEC = executor.prepare() val preparedEC = executor.prepare()
try new AtomicReference[Cancellable](InitialRepeatMarker) with Cancellable { self try new AtomicReference[Cancellable](InitialRepeatMarker) with Cancellable { self
@ -221,7 +223,7 @@ class LightArrayRevolverScheduler(config: Config,
time - start + // calculate the nanos since timer start time - start + // calculate the nanos since timer start
(ticks * tickNanos) + // adding the desired delay (ticks * tickNanos) + // adding the desired delay
tickNanos - 1 // rounding up tickNanos - 1 // rounding up
) / tickNanos).toInt // and converting to slot number ) / tickNanos).toInt // and converting to slot number
// tick is an Int that will wrap around, but toInt of futureTick gives us modulo operations // tick is an Int that will wrap around, but toInt of futureTick gives us modulo operations
// and the difference (offset) will be correct in any case // and the difference (offset) will be correct in any case
val offset = futureTick - tick val offset = futureTick - tick

View file

@ -24,12 +24,12 @@ import scala.util.control.NonFatal
* and swap out the cell ref. * and swap out the cell ref.
*/ */
private[akka] class RepointableActorRef( private[akka] class RepointableActorRef(
val system: ActorSystemImpl, val system: ActorSystemImpl,
val props: Props, val props: Props,
val dispatcher: MessageDispatcher, val dispatcher: MessageDispatcher,
val mailboxType: MailboxType, val mailboxType: MailboxType,
val supervisor: InternalActorRef, val supervisor: InternalActorRef,
val path: ActorPath) val path: ActorPath)
extends ActorRefWithCell with RepointableRef { extends ActorRefWithCell with RepointableRef {
import AbstractActorRef.{ cellOffset, lookupOffset } import AbstractActorRef.{ cellOffset, lookupOffset }
@ -176,10 +176,11 @@ private[akka] class RepointableActorRef(
protected def writeReplace(): AnyRef = SerializedActorRef(this) protected def writeReplace(): AnyRef = SerializedActorRef(this)
} }
private[akka] class UnstartedCell(val systemImpl: ActorSystemImpl, private[akka] class UnstartedCell(
val self: RepointableActorRef, val systemImpl: ActorSystemImpl,
val props: Props, val self: RepointableActorRef,
val supervisor: InternalActorRef) extends Cell { val props: Props,
val supervisor: InternalActorRef) extends Cell {
/* /*
* This lock protects all accesses to this cells queues. It also ensures * This lock protects all accesses to this cells queues. It also ensures

View file

@ -42,10 +42,11 @@ trait Scheduler {
*/ */
final def schedule( final def schedule(
initialDelay: FiniteDuration, initialDelay: FiniteDuration,
interval: FiniteDuration, interval: FiniteDuration,
receiver: ActorRef, receiver: ActorRef,
message: Any)(implicit executor: ExecutionContext, message: Any)(implicit
sender: ActorRef = Actor.noSender): Cancellable = executor: ExecutionContext,
sender: ActorRef = Actor.noSender): Cancellable =
schedule(initialDelay, interval, new Runnable { schedule(initialDelay, interval, new Runnable {
def run = { def run = {
receiver ! message receiver ! message
@ -71,8 +72,9 @@ trait Scheduler {
*/ */
final def schedule( final def schedule(
initialDelay: FiniteDuration, initialDelay: FiniteDuration,
interval: FiniteDuration)(f: Unit)( interval: FiniteDuration)(f: Unit)(
implicit executor: ExecutionContext): Cancellable = implicit
executor: ExecutionContext): Cancellable =
schedule(initialDelay, interval, new Runnable { override def run = f }) schedule(initialDelay, interval, new Runnable { override def run = f })
/** /**
@ -93,8 +95,8 @@ trait Scheduler {
*/ */
def schedule( def schedule(
initialDelay: FiniteDuration, initialDelay: FiniteDuration,
interval: FiniteDuration, interval: FiniteDuration,
runnable: Runnable)(implicit executor: ExecutionContext): Cancellable runnable: Runnable)(implicit executor: ExecutionContext): Cancellable
/** /**
* Schedules a message to be sent once with a delay, i.e. a time period that has * Schedules a message to be sent once with a delay, i.e. a time period that has
@ -103,10 +105,11 @@ trait Scheduler {
* Java & Scala API * Java & Scala API
*/ */
final def scheduleOnce( final def scheduleOnce(
delay: FiniteDuration, delay: FiniteDuration,
receiver: ActorRef, receiver: ActorRef,
message: Any)(implicit executor: ExecutionContext, message: Any)(implicit
sender: ActorRef = Actor.noSender): Cancellable = executor: ExecutionContext,
sender: ActorRef = Actor.noSender): Cancellable =
scheduleOnce(delay, new Runnable { scheduleOnce(delay, new Runnable {
override def run = receiver ! message override def run = receiver ! message
}) })
@ -118,7 +121,8 @@ trait Scheduler {
* Scala API * Scala API
*/ */
final def scheduleOnce(delay: FiniteDuration)(f: Unit)( final def scheduleOnce(delay: FiniteDuration)(f: Unit)(
implicit executor: ExecutionContext): Cancellable = implicit
executor: ExecutionContext): Cancellable =
scheduleOnce(delay, new Runnable { override def run = f }) scheduleOnce(delay, new Runnable { override def run = f })
/** /**
@ -128,7 +132,7 @@ trait Scheduler {
* Java & Scala API * Java & Scala API
*/ */
def scheduleOnce( def scheduleOnce(
delay: FiniteDuration, delay: FiniteDuration,
runnable: Runnable)(implicit executor: ExecutionContext): Cancellable runnable: Runnable)(implicit executor: ExecutionContext): Cancellable
/** /**

View file

@ -523,11 +523,11 @@ object TypedProps {
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class TypedProps[T <: AnyRef] protected[TypedProps] ( final case class TypedProps[T <: AnyRef] protected[TypedProps] (
interfaces: immutable.Seq[Class[_]], interfaces: immutable.Seq[Class[_]],
creator: () T, creator: () T,
dispatcher: String = TypedProps.defaultDispatcherId, dispatcher: String = TypedProps.defaultDispatcherId,
deploy: Deploy = Props.defaultDeploy, deploy: Deploy = Props.defaultDeploy,
timeout: Option[Timeout] = TypedProps.defaultTimeout, timeout: Option[Timeout] = TypedProps.defaultTimeout,
loader: Option[ClassLoader] = TypedProps.defaultLoader) { loader: Option[ClassLoader] = TypedProps.defaultLoader) {
/** /**
* Uses the supplied class as the factory for the TypedActor implementation, * Uses the supplied class as the factory for the TypedActor implementation,
@ -536,7 +536,8 @@ final case class TypedProps[T <: AnyRef] protected[TypedProps] (
* appended in the sequence of interfaces. * appended in the sequence of interfaces.
*/ */
def this(implementation: Class[T]) = def this(implementation: Class[T]) =
this(interfaces = TypedProps.extractInterfaces(implementation), this(
interfaces = TypedProps.extractInterfaces(implementation),
creator = instantiator(implementation)) creator = instantiator(implementation))
/** /**
@ -546,7 +547,8 @@ final case class TypedProps[T <: AnyRef] protected[TypedProps] (
* appended in the sequence of interfaces. * appended in the sequence of interfaces.
*/ */
def this(interface: Class[_ >: T], implementation: Creator[T]) = def this(interface: Class[_ >: T], implementation: Creator[T]) =
this(interfaces = TypedProps.extractInterfaces(interface), this(
interfaces = TypedProps.extractInterfaces(interface),
creator = implementation.create _) creator = implementation.create _)
/** /**
@ -556,7 +558,8 @@ final case class TypedProps[T <: AnyRef] protected[TypedProps] (
* appended in the sequence of interfaces. * appended in the sequence of interfaces.
*/ */
def this(interface: Class[_ >: T], implementation: Class[T]) = def this(interface: Class[_ >: T], implementation: Class[T]) =
this(interfaces = TypedProps.extractInterfaces(interface), this(
interfaces = TypedProps.extractInterfaces(interface),
creator = instantiator(implementation)) creator = instantiator(implementation))
/** /**

View file

@ -62,7 +62,8 @@ private[akka] trait Dispatch { this: ActorCell ⇒
if (req isInstance mbox.messageQueue) Create(None) if (req isInstance mbox.messageQueue) Create(None)
else { else {
val gotType = if (mbox.messageQueue == null) "null" else mbox.messageQueue.getClass.getName val gotType = if (mbox.messageQueue == null) "null" else mbox.messageQueue.getClass.getName
Create(Some(ActorInitializationException(self, Create(Some(ActorInitializationException(
self,
s"Actor [$self] requires mailbox type [$req] got [$gotType]"))) s"Actor [$self] requires mailbox type [$req] got [$gotType]")))
} }
case _ Create(None) case _ Create(None)

View file

@ -324,8 +324,8 @@ abstract class MessageDispatcherConfigurator(_config: Config, val prerequisites:
case "thread-pool-executor" new ThreadPoolExecutorConfigurator(config.getConfig("thread-pool-executor"), prerequisites) case "thread-pool-executor" new ThreadPoolExecutorConfigurator(config.getConfig("thread-pool-executor"), prerequisites)
case fqcn case fqcn
val args = List( val args = List(
classOf[Config] -> config, classOf[Config] config,
classOf[DispatcherPrerequisites] -> prerequisites) classOf[DispatcherPrerequisites] prerequisites)
prerequisites.dynamicAccess.createInstanceFor[ExecutorServiceConfigurator](fqcn, args).recover({ prerequisites.dynamicAccess.createInstanceFor[ExecutorServiceConfigurator](fqcn, args).recover({
case exception throw new IllegalArgumentException( case exception throw new IllegalArgumentException(
("""Cannot instantiate ExecutorServiceConfigurator ("executor = [%s]"), defined in [%s], ("""Cannot instantiate ExecutorServiceConfigurator ("executor = [%s]"), defined in [%s],
@ -379,14 +379,16 @@ object ForkJoinExecutorConfigurator {
/** /**
* INTERNAL AKKA USAGE ONLY * INTERNAL AKKA USAGE ONLY
*/ */
final class AkkaForkJoinPool(parallelism: Int, final class AkkaForkJoinPool(
threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory, parallelism: Int,
unhandledExceptionHandler: Thread.UncaughtExceptionHandler, threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory,
asyncMode: Boolean) unhandledExceptionHandler: Thread.UncaughtExceptionHandler,
asyncMode: Boolean)
extends ForkJoinPool(parallelism, threadFactory, unhandledExceptionHandler, asyncMode) with LoadMetrics { extends ForkJoinPool(parallelism, threadFactory, unhandledExceptionHandler, asyncMode) with LoadMetrics {
def this(parallelism: Int, def this(
threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory, parallelism: Int,
unhandledExceptionHandler: Thread.UncaughtExceptionHandler) = this(parallelism, threadFactory, unhandledExceptionHandler, asyncMode = true) threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory,
unhandledExceptionHandler: Thread.UncaughtExceptionHandler) = this(parallelism, threadFactory, unhandledExceptionHandler, asyncMode = true)
override def execute(r: Runnable): Unit = override def execute(r: Runnable): Unit =
if (r ne null) if (r ne null)
@ -427,9 +429,10 @@ class ForkJoinExecutorConfigurator(config: Config, prerequisites: DispatcherPrer
case x throw new IllegalStateException("The prerequisites for the ForkJoinExecutorConfigurator is a ForkJoinPool.ForkJoinWorkerThreadFactory!") case x throw new IllegalStateException("The prerequisites for the ForkJoinExecutorConfigurator is a ForkJoinPool.ForkJoinWorkerThreadFactory!")
} }
class ForkJoinExecutorServiceFactory(val threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory, class ForkJoinExecutorServiceFactory(
val parallelism: Int, val threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory,
val asyncMode: Boolean) extends ExecutorServiceFactory { val parallelism: Int,
val asyncMode: Boolean) extends ExecutorServiceFactory {
def this(threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory, parallelism: Int) = this(threadFactory, parallelism, asyncMode = true) def this(threadFactory: ForkJoinPool.ForkJoinWorkerThreadFactory, parallelism: Int) = this(threadFactory, parallelism, asyncMode = true)
def createExecutorService: ExecutorService = new AkkaForkJoinPool(parallelism, threadFactory, MonitorableThreadFactory.doNothing, asyncMode) def createExecutorService: ExecutorService = new AkkaForkJoinPool(parallelism, threadFactory, MonitorableThreadFactory.doNothing, asyncMode)
} }

View file

@ -30,14 +30,14 @@ import scala.concurrent.duration.FiniteDuration
*/ */
@deprecated("Use BalancingPool instead of BalancingDispatcher", "2.3") @deprecated("Use BalancingPool instead of BalancingDispatcher", "2.3")
class BalancingDispatcher( class BalancingDispatcher(
_configurator: MessageDispatcherConfigurator, _configurator: MessageDispatcherConfigurator,
_id: String, _id: String,
throughput: Int, throughput: Int,
throughputDeadlineTime: Duration, throughputDeadlineTime: Duration,
_mailboxType: MailboxType, _mailboxType: MailboxType,
_executorServiceFactoryProvider: ExecutorServiceFactoryProvider, _executorServiceFactoryProvider: ExecutorServiceFactoryProvider,
_shutdownTimeout: FiniteDuration, _shutdownTimeout: FiniteDuration,
attemptTeamWork: Boolean) attemptTeamWork: Boolean)
extends Dispatcher(_configurator, _id, throughput, throughputDeadlineTime, _executorServiceFactoryProvider, _shutdownTimeout) { extends Dispatcher(_configurator, _id, throughput, throughputDeadlineTime, _executorServiceFactoryProvider, _shutdownTimeout) {
/** /**

View file

@ -26,12 +26,12 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater
* Larger values (or zero or negative) increase throughput, smaller values increase fairness * Larger values (or zero or negative) increase throughput, smaller values increase fairness
*/ */
class Dispatcher( class Dispatcher(
_configurator: MessageDispatcherConfigurator, _configurator: MessageDispatcherConfigurator,
val id: String, val id: String,
val throughput: Int, val throughput: Int,
val throughputDeadlineTime: Duration, val throughputDeadlineTime: Duration,
executorServiceFactoryProvider: ExecutorServiceFactoryProvider, executorServiceFactoryProvider: ExecutorServiceFactoryProvider,
val shutdownTimeout: FiniteDuration) val shutdownTimeout: FiniteDuration)
extends MessageDispatcher(_configurator) { extends MessageDispatcher(_configurator) {
import configurator.prerequisites._ import configurator.prerequisites._

View file

@ -30,12 +30,12 @@ trait DispatcherPrerequisites {
* INTERNAL API * INTERNAL API
*/ */
private[akka] final case class DefaultDispatcherPrerequisites( private[akka] final case class DefaultDispatcherPrerequisites(
val threadFactory: ThreadFactory, val threadFactory: ThreadFactory,
val eventStream: EventStream, val eventStream: EventStream,
val scheduler: Scheduler, val scheduler: Scheduler,
val dynamicAccess: DynamicAccess, val dynamicAccess: DynamicAccess,
val settings: ActorSystem.Settings, val settings: ActorSystem.Settings,
val mailboxes: Mailboxes, val mailboxes: Mailboxes,
val defaultExecutionContext: Option[ExecutionContext]) extends DispatcherPrerequisites val defaultExecutionContext: Option[ExecutionContext]) extends DispatcherPrerequisites
object Dispatchers { object Dispatchers {
@ -135,13 +135,13 @@ class Dispatchers(val settings: ActorSystem.Settings, val prerequisites: Dispatc
def simpleName = id.substring(id.lastIndexOf('.') + 1) def simpleName = id.substring(id.lastIndexOf('.') + 1)
idConfig(id) idConfig(id)
.withFallback(appConfig) .withFallback(appConfig)
.withFallback(ConfigFactory.parseMap(Map("name" -> simpleName).asJava)) .withFallback(ConfigFactory.parseMap(Map("name" simpleName).asJava))
.withFallback(defaultDispatcherConfig) .withFallback(defaultDispatcherConfig)
} }
private def idConfig(id: String): Config = { private def idConfig(id: String): Config = {
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
ConfigFactory.parseMap(Map("id" -> id).asJava) ConfigFactory.parseMap(Map("id" id).asJava)
} }
/** /**
@ -180,7 +180,7 @@ class Dispatchers(val settings: ActorSystem.Settings, val prerequisites: Dispatc
classOf[BalancingDispatcherConfigurator].getName) classOf[BalancingDispatcherConfigurator].getName)
case "PinnedDispatcher" new PinnedDispatcherConfigurator(cfg, prerequisites) case "PinnedDispatcher" new PinnedDispatcherConfigurator(cfg, prerequisites)
case fqn case fqn
val args = List(classOf[Config] -> cfg, classOf[DispatcherPrerequisites] -> prerequisites) val args = List(classOf[Config] cfg, classOf[DispatcherPrerequisites] prerequisites)
prerequisites.dynamicAccess.createInstanceFor[MessageDispatcherConfigurator](fqn, args).recover({ prerequisites.dynamicAccess.createInstanceFor[MessageDispatcherConfigurator](fqn, args).recover({
case exception case exception
throw new ConfigurationException( throw new ConfigurationException(
@ -288,7 +288,8 @@ class PinnedDispatcherConfigurator(config: Config, prerequisites: DispatcherPrer
case e: ThreadPoolExecutorConfigurator e.threadPoolConfig case e: ThreadPoolExecutorConfigurator e.threadPoolConfig
case other case other
prerequisites.eventStream.publish( prerequisites.eventStream.publish(
Warning("PinnedDispatcherConfigurator", Warning(
"PinnedDispatcherConfigurator",
this.getClass, this.getClass,
"PinnedDispatcher [%s] not configured to use ThreadPoolExecutor, falling back to default config.".format( "PinnedDispatcher [%s] not configured to use ThreadPoolExecutor, falling back to default config.".format(
config.getString("id")))) config.getString("id"))))

View file

@ -9,7 +9,7 @@ import akka.japi.{ Function ⇒ JFunc, Option ⇒ JOption, Procedure }
import scala.concurrent.{ Future, Promise, ExecutionContext, ExecutionContextExecutor, ExecutionContextExecutorService } import scala.concurrent.{ Future, Promise, ExecutionContext, ExecutionContextExecutor, ExecutionContextExecutorService }
import java.lang.{ Iterable JIterable } import java.lang.{ Iterable JIterable }
import java.util.{ LinkedList JLinkedList } import java.util.{ LinkedList JLinkedList }
import java.util.concurrent.{ Executor, ExecutorService, Callable} import java.util.concurrent.{ Executor, ExecutorService, Callable }
import scala.util.{ Try, Success, Failure } import scala.util.{ Try, Success, Failure }
import java.util.concurrent.CompletionStage import java.util.concurrent.CompletionStage
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture

View file

@ -54,7 +54,7 @@ private[akka] object Mailbox {
* INTERNAL API * INTERNAL API
*/ */
private[akka] abstract class Mailbox(val messageQueue: MessageQueue) private[akka] abstract class Mailbox(val messageQueue: MessageQueue)
extends ForkJoinTask[Unit] with SystemMessageQueue with Runnable { extends ForkJoinTask[Unit] with SystemMessageQueue with Runnable {
import Mailbox._ import Mailbox._
@ -248,7 +248,7 @@ private[akka] abstract class Mailbox(val messageQueue: MessageQueue)
* Process the messages in the mailbox * Process the messages in the mailbox
*/ */
@tailrec private final def processMailbox( @tailrec private final def processMailbox(
left: Int = java.lang.Math.max(dispatcher.throughput, 1), left: Int = java.lang.Math.max(dispatcher.throughput, 1),
deadlineNs: Long = if (dispatcher.isThroughputDeadlineTimeDefined == true) System.nanoTime + dispatcher.throughputDeadlineTime.toNanos else 0L): Unit = deadlineNs: Long = if (dispatcher.isThroughputDeadlineTimeDefined == true) System.nanoTime + dispatcher.throughputDeadlineTime.toNanos else 0L): Unit =
if (shouldProcessMessage) { if (shouldProcessMessage) {
val next = dequeue() val next = dequeue()
@ -391,7 +391,7 @@ class NodeMessageQueue extends AbstractNodeQueue[Envelope] with MessageQueue wit
* Discards overflowing messages into DeadLetters. * Discards overflowing messages into DeadLetters.
*/ */
class BoundedNodeMessageQueue(capacity: Int) extends AbstractBoundedNodeQueue[Envelope](capacity) class BoundedNodeMessageQueue(capacity: Int) extends AbstractBoundedNodeQueue[Envelope](capacity)
with MessageQueue with BoundedMessageQueueSemantics with MultipleConsumerSemantics { with MessageQueue with BoundedMessageQueueSemantics with MultipleConsumerSemantics {
final def pushTimeOut: Duration = Duration.Undefined final def pushTimeOut: Duration = Duration.Undefined
final def enqueue(receiver: ActorRef, handle: Envelope): Unit = final def enqueue(receiver: ActorRef, handle: Envelope): Unit =
@ -654,10 +654,11 @@ case class NonBlockingBoundedMailbox(val capacity: Int) extends MailboxType with
* BoundedMailbox is the default bounded MailboxType used by Akka Actors. * BoundedMailbox is the default bounded MailboxType used by Akka Actors.
*/ */
final case class BoundedMailbox(val capacity: Int, override val pushTimeOut: FiniteDuration) final case class BoundedMailbox(val capacity: Int, override val pushTimeOut: FiniteDuration)
extends MailboxType with ProducesMessageQueue[BoundedMailbox.MessageQueue] extends MailboxType with ProducesMessageQueue[BoundedMailbox.MessageQueue]
with ProducesPushTimeoutSemanticsMailbox { with ProducesPushTimeoutSemanticsMailbox {
def this(settings: ActorSystem.Settings, config: Config) = this(config.getInt("mailbox-capacity"), def this(settings: ActorSystem.Settings, config: Config) = this(
config.getInt("mailbox-capacity"),
config.getNanosDuration("mailbox-push-timeout-time")) config.getNanosDuration("mailbox-push-timeout-time"))
if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative") if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative")
@ -669,7 +670,7 @@ final case class BoundedMailbox(val capacity: Int, override val pushTimeOut: Fin
object BoundedMailbox { object BoundedMailbox {
class MessageQueue(capacity: Int, final val pushTimeOut: FiniteDuration) class MessageQueue(capacity: Int, final val pushTimeOut: FiniteDuration)
extends LinkedBlockingQueue[Envelope](capacity) with BoundedQueueBasedMessageQueue { extends LinkedBlockingQueue[Envelope](capacity) with BoundedQueueBasedMessageQueue {
final def queue: BlockingQueue[Envelope] = this final def queue: BlockingQueue[Envelope] = this
} }
} }
@ -679,7 +680,7 @@ object BoundedMailbox {
* Extend this class and provide the Comparator in the constructor. * Extend this class and provide the Comparator in the constructor.
*/ */
class UnboundedPriorityMailbox(val cmp: Comparator[Envelope], val initialCapacity: Int) class UnboundedPriorityMailbox(val cmp: Comparator[Envelope], val initialCapacity: Int)
extends MailboxType with ProducesMessageQueue[UnboundedPriorityMailbox.MessageQueue] { extends MailboxType with ProducesMessageQueue[UnboundedPriorityMailbox.MessageQueue] {
def this(cmp: Comparator[Envelope]) = this(cmp, 11) def this(cmp: Comparator[Envelope]) = this(cmp, 11)
final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue =
new UnboundedPriorityMailbox.MessageQueue(initialCapacity, cmp) new UnboundedPriorityMailbox.MessageQueue(initialCapacity, cmp)
@ -687,7 +688,7 @@ class UnboundedPriorityMailbox(val cmp: Comparator[Envelope], val initialCapacit
object UnboundedPriorityMailbox { object UnboundedPriorityMailbox {
class MessageQueue(initialCapacity: Int, cmp: Comparator[Envelope]) class MessageQueue(initialCapacity: Int, cmp: Comparator[Envelope])
extends PriorityBlockingQueue[Envelope](initialCapacity, cmp) with UnboundedQueueBasedMessageQueue { extends PriorityBlockingQueue[Envelope](initialCapacity, cmp) with UnboundedQueueBasedMessageQueue {
final def queue: Queue[Envelope] = this final def queue: Queue[Envelope] = this
} }
} }
@ -697,8 +698,8 @@ object UnboundedPriorityMailbox {
* Extend this class and provide the Comparator in the constructor. * Extend this class and provide the Comparator in the constructor.
*/ */
class BoundedPriorityMailbox( final val cmp: Comparator[Envelope], final val capacity: Int, override final val pushTimeOut: Duration) class BoundedPriorityMailbox( final val cmp: Comparator[Envelope], final val capacity: Int, override final val pushTimeOut: Duration)
extends MailboxType with ProducesMessageQueue[BoundedPriorityMailbox.MessageQueue] extends MailboxType with ProducesMessageQueue[BoundedPriorityMailbox.MessageQueue]
with ProducesPushTimeoutSemanticsMailbox { with ProducesPushTimeoutSemanticsMailbox {
if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative") if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative")
if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null") if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null")
@ -709,8 +710,8 @@ class BoundedPriorityMailbox( final val cmp: Comparator[Envelope], final val cap
object BoundedPriorityMailbox { object BoundedPriorityMailbox {
class MessageQueue(capacity: Int, cmp: Comparator[Envelope], val pushTimeOut: Duration) class MessageQueue(capacity: Int, cmp: Comparator[Envelope], val pushTimeOut: Duration)
extends BoundedBlockingQueue[Envelope](capacity, new PriorityQueue[Envelope](11, cmp)) extends BoundedBlockingQueue[Envelope](capacity, new PriorityQueue[Envelope](11, cmp))
with BoundedQueueBasedMessageQueue { with BoundedQueueBasedMessageQueue {
final def queue: BlockingQueue[Envelope] = this final def queue: BlockingQueue[Envelope] = this
} }
} }
@ -721,7 +722,7 @@ object BoundedPriorityMailbox {
* Extend this class and provide the Comparator in the constructor. * Extend this class and provide the Comparator in the constructor.
*/ */
class UnboundedStablePriorityMailbox(val cmp: Comparator[Envelope], val initialCapacity: Int) class UnboundedStablePriorityMailbox(val cmp: Comparator[Envelope], val initialCapacity: Int)
extends MailboxType with ProducesMessageQueue[UnboundedStablePriorityMailbox.MessageQueue] { extends MailboxType with ProducesMessageQueue[UnboundedStablePriorityMailbox.MessageQueue] {
def this(cmp: Comparator[Envelope]) = this(cmp, 11) def this(cmp: Comparator[Envelope]) = this(cmp, 11)
final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = final override def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue =
new UnboundedStablePriorityMailbox.MessageQueue(initialCapacity, cmp) new UnboundedStablePriorityMailbox.MessageQueue(initialCapacity, cmp)
@ -729,7 +730,7 @@ class UnboundedStablePriorityMailbox(val cmp: Comparator[Envelope], val initialC
object UnboundedStablePriorityMailbox { object UnboundedStablePriorityMailbox {
class MessageQueue(initialCapacity: Int, cmp: Comparator[Envelope]) class MessageQueue(initialCapacity: Int, cmp: Comparator[Envelope])
extends StablePriorityBlockingQueue[Envelope](initialCapacity, cmp) with UnboundedQueueBasedMessageQueue { extends StablePriorityBlockingQueue[Envelope](initialCapacity, cmp) with UnboundedQueueBasedMessageQueue {
final def queue: Queue[Envelope] = this final def queue: Queue[Envelope] = this
} }
} }
@ -740,8 +741,8 @@ object UnboundedStablePriorityMailbox {
* Extend this class and provide the Comparator in the constructor. * Extend this class and provide the Comparator in the constructor.
*/ */
class BoundedStablePriorityMailbox( final val cmp: Comparator[Envelope], final val capacity: Int, override final val pushTimeOut: Duration) class BoundedStablePriorityMailbox( final val cmp: Comparator[Envelope], final val capacity: Int, override final val pushTimeOut: Duration)
extends MailboxType with ProducesMessageQueue[BoundedStablePriorityMailbox.MessageQueue] extends MailboxType with ProducesMessageQueue[BoundedStablePriorityMailbox.MessageQueue]
with ProducesPushTimeoutSemanticsMailbox { with ProducesPushTimeoutSemanticsMailbox {
if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative") if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedMailbox can not be negative")
if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null") if (pushTimeOut eq null) throw new IllegalArgumentException("The push time-out for BoundedMailbox can not be null")
@ -752,8 +753,8 @@ class BoundedStablePriorityMailbox( final val cmp: Comparator[Envelope], final v
object BoundedStablePriorityMailbox { object BoundedStablePriorityMailbox {
class MessageQueue(capacity: Int, cmp: Comparator[Envelope], val pushTimeOut: Duration) class MessageQueue(capacity: Int, cmp: Comparator[Envelope], val pushTimeOut: Duration)
extends BoundedBlockingQueue[Envelope](capacity, new StablePriorityQueue[Envelope](11, cmp)) extends BoundedBlockingQueue[Envelope](capacity, new StablePriorityQueue[Envelope](11, cmp))
with BoundedQueueBasedMessageQueue { with BoundedQueueBasedMessageQueue {
final def queue: BlockingQueue[Envelope] = this final def queue: BlockingQueue[Envelope] = this
} }
} }
@ -779,10 +780,11 @@ object UnboundedDequeBasedMailbox {
* BoundedDequeBasedMailbox is an bounded MailboxType, backed by a Deque. * BoundedDequeBasedMailbox is an bounded MailboxType, backed by a Deque.
*/ */
case class BoundedDequeBasedMailbox( final val capacity: Int, override final val pushTimeOut: FiniteDuration) case class BoundedDequeBasedMailbox( final val capacity: Int, override final val pushTimeOut: FiniteDuration)
extends MailboxType with ProducesMessageQueue[BoundedDequeBasedMailbox.MessageQueue] extends MailboxType with ProducesMessageQueue[BoundedDequeBasedMailbox.MessageQueue]
with ProducesPushTimeoutSemanticsMailbox { with ProducesPushTimeoutSemanticsMailbox {
def this(settings: ActorSystem.Settings, config: Config) = this(config.getInt("mailbox-capacity"), def this(settings: ActorSystem.Settings, config: Config) = this(
config.getInt("mailbox-capacity"),
config.getNanosDuration("mailbox-push-timeout-time")) config.getNanosDuration("mailbox-push-timeout-time"))
if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedDequeBasedMailbox can not be negative") if (capacity < 0) throw new IllegalArgumentException("The capacity for BoundedDequeBasedMailbox can not be negative")
@ -794,7 +796,7 @@ case class BoundedDequeBasedMailbox( final val capacity: Int, override final val
object BoundedDequeBasedMailbox { object BoundedDequeBasedMailbox {
class MessageQueue(capacity: Int, val pushTimeOut: FiniteDuration) class MessageQueue(capacity: Int, val pushTimeOut: FiniteDuration)
extends LinkedBlockingDeque[Envelope](capacity) with BoundedDequeBasedMessageQueue { extends LinkedBlockingDeque[Envelope](capacity) with BoundedDequeBasedMessageQueue {
final val queue = this final val queue = this
} }
} }
@ -856,9 +858,10 @@ object UnboundedControlAwareMailbox {
* to allow messages that extend [[akka.dispatch.ControlMessage]] to be delivered with priority. * to allow messages that extend [[akka.dispatch.ControlMessage]] to be delivered with priority.
*/ */
final case class BoundedControlAwareMailbox(capacity: Int, override final val pushTimeOut: FiniteDuration) extends MailboxType final case class BoundedControlAwareMailbox(capacity: Int, override final val pushTimeOut: FiniteDuration) extends MailboxType
with ProducesMessageQueue[BoundedControlAwareMailbox.MessageQueue] with ProducesMessageQueue[BoundedControlAwareMailbox.MessageQueue]
with ProducesPushTimeoutSemanticsMailbox { with ProducesPushTimeoutSemanticsMailbox {
def this(settings: ActorSystem.Settings, config: Config) = this(config.getInt("mailbox-capacity"), def this(settings: ActorSystem.Settings, config: Config) = this(
config.getInt("mailbox-capacity"),
config.getNanosDuration("mailbox-push-timeout-time")) config.getNanosDuration("mailbox-push-timeout-time"))
def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = new BoundedControlAwareMailbox.MessageQueue(capacity, pushTimeOut) def create(owner: Option[ActorRef], system: Option[ActorSystem]): MessageQueue = new BoundedControlAwareMailbox.MessageQueue(capacity, pushTimeOut)

View file

@ -23,10 +23,10 @@ object Mailboxes {
} }
private[akka] class Mailboxes( private[akka] class Mailboxes(
val settings: ActorSystem.Settings, val settings: ActorSystem.Settings,
val eventStream: EventStream, val eventStream: EventStream,
dynamicAccess: DynamicAccess, dynamicAccess: DynamicAccess,
deadLetters: ActorRef) { deadLetters: ActorRef) {
import Mailboxes._ import Mailboxes._
@ -187,7 +187,7 @@ private[akka] class Mailboxes(
val mailboxType = conf.getString("mailbox-type") match { val mailboxType = conf.getString("mailbox-type") match {
case "" throw new ConfigurationException(s"The setting mailbox-type, defined in [$id] is empty") case "" throw new ConfigurationException(s"The setting mailbox-type, defined in [$id] is empty")
case fqcn case fqcn
val args = List(classOf[ActorSystem.Settings] -> settings, classOf[Config] -> conf) val args = List(classOf[ActorSystem.Settings] settings, classOf[Config] conf)
dynamicAccess.createInstanceFor[MailboxType](fqcn, args).recover({ dynamicAccess.createInstanceFor[MailboxType](fqcn, args).recover({
case exception case exception
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -228,7 +228,7 @@ private[akka] class Mailboxes(
//INTERNAL API //INTERNAL API
private def config(id: String): Config = { private def config(id: String): Config = {
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
ConfigFactory.parseMap(Map("id" -> id).asJava) ConfigFactory.parseMap(Map("id" id).asJava)
.withFallback(settings.config.getConfig(id)) .withFallback(settings.config.getConfig(id))
.withFallback(defaultMailboxConfig) .withFallback(defaultMailboxConfig)
} }

View file

@ -15,12 +15,13 @@ import scala.concurrent.duration.FiniteDuration
* the `lookup` method in [[akka.dispatch.Dispatchers]]. * the `lookup` method in [[akka.dispatch.Dispatchers]].
*/ */
class PinnedDispatcher( class PinnedDispatcher(
_configurator: MessageDispatcherConfigurator, _configurator: MessageDispatcherConfigurator,
_actor: ActorCell, _actor: ActorCell,
_id: String, _id: String,
_shutdownTimeout: FiniteDuration, _shutdownTimeout: FiniteDuration,
_threadPoolConfig: ThreadPoolConfig) _threadPoolConfig: ThreadPoolConfig)
extends Dispatcher(_configurator, extends Dispatcher(
_configurator,
_id, _id,
Int.MaxValue, Int.MaxValue,
Duration.Zero, Duration.Zero,

View file

@ -65,12 +65,13 @@ trait ExecutorServiceFactoryProvider {
/** /**
* A small configuration DSL to create ThreadPoolExecutors that can be provided as an ExecutorServiceFactoryProvider to Dispatcher * A small configuration DSL to create ThreadPoolExecutors that can be provided as an ExecutorServiceFactoryProvider to Dispatcher
*/ */
final case class ThreadPoolConfig(allowCorePoolTimeout: Boolean = ThreadPoolConfig.defaultAllowCoreThreadTimeout, final case class ThreadPoolConfig(
corePoolSize: Int = ThreadPoolConfig.defaultCorePoolSize, allowCorePoolTimeout: Boolean = ThreadPoolConfig.defaultAllowCoreThreadTimeout,
maxPoolSize: Int = ThreadPoolConfig.defaultMaxPoolSize, corePoolSize: Int = ThreadPoolConfig.defaultCorePoolSize,
threadTimeout: Duration = ThreadPoolConfig.defaultTimeout, maxPoolSize: Int = ThreadPoolConfig.defaultMaxPoolSize,
queueFactory: ThreadPoolConfig.QueueFactory = ThreadPoolConfig.linkedBlockingQueue(), threadTimeout: Duration = ThreadPoolConfig.defaultTimeout,
rejectionPolicy: RejectedExecutionHandler = ThreadPoolConfig.defaultRejectionPolicy) queueFactory: ThreadPoolConfig.QueueFactory = ThreadPoolConfig.linkedBlockingQueue(),
rejectionPolicy: RejectedExecutionHandler = ThreadPoolConfig.defaultRejectionPolicy)
extends ExecutorServiceFactoryProvider { extends ExecutorServiceFactoryProvider {
class ThreadPoolExecutorServiceFactory(val threadFactory: ThreadFactory) extends ExecutorServiceFactory { class ThreadPoolExecutorServiceFactory(val threadFactory: ThreadFactory) extends ExecutorServiceFactory {
def createExecutorService: ExecutorService = { def createExecutorService: ExecutorService = {
@ -173,11 +174,12 @@ object MonitorableThreadFactory {
} }
} }
final case class MonitorableThreadFactory(name: String, final case class MonitorableThreadFactory(
daemonic: Boolean, name: String,
contextClassLoader: Option[ClassLoader], daemonic: Boolean,
exceptionHandler: Thread.UncaughtExceptionHandler = MonitorableThreadFactory.doNothing, contextClassLoader: Option[ClassLoader],
protected val counter: AtomicLong = new AtomicLong) exceptionHandler: Thread.UncaughtExceptionHandler = MonitorableThreadFactory.doNothing,
protected val counter: AtomicLong = new AtomicLong)
extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory { extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory {
def newThread(pool: ForkJoinPool): ForkJoinWorkerThread = { def newThread(pool: ForkJoinPool): ForkJoinWorkerThread = {

View file

@ -261,6 +261,6 @@ private[akka] final case class Failed(child: ActorRef, cause: Throwable, uid: In
@SerialVersionUID(1L) @SerialVersionUID(1L)
private[akka] final case class DeathWatchNotification( private[akka] final case class DeathWatchNotification(
actor: ActorRef, actor: ActorRef,
existenceConfirmed: Boolean, existenceConfirmed: Boolean,
addressTerminated: Boolean) extends SystemMessage with DeadLetterSuppression addressTerminated: Boolean) extends SystemMessage with DeadLetterSuppression

View file

@ -572,9 +572,9 @@ object Logging {
} }
/** /**
* Obtain LoggingAdapter with MDC support for the given actor. * Obtain LoggingAdapter with MDC support for the given actor.
* Don't use it outside its specific Actor as it isn't thread safe * Don't use it outside its specific Actor as it isn't thread safe
*/ */
def getLogger(logSource: Actor): DiagnosticLoggingAdapter = apply(logSource) def getLogger(logSource: Actor): DiagnosticLoggingAdapter = apply(logSource)
/** /**

View file

@ -5,6 +5,7 @@
package akka.io package akka.io
import java.nio.ByteBuffer import java.nio.ByteBuffer
import scala.util.control.NonFatal
trait BufferPool { trait BufferPool {
def acquire(): ByteBuffer def acquire(): ByteBuffer
@ -54,11 +55,42 @@ private[akka] class DirectByteBufferPool(defaultBufferSize: Int, maxPoolEntries:
} }
} }
private final def offerBufferToPool(buf: ByteBuffer): Unit = private final def offerBufferToPool(buf: ByteBuffer): Unit = {
pool.synchronized { val clean =
if (buffersInPool < maxPoolEntries) { pool.synchronized {
pool(buffersInPool) = buf if (buffersInPool < maxPoolEntries) {
buffersInPool += 1 pool(buffersInPool) = buf
} // else let the buffer be gc'd buffersInPool += 1
false
} else {
// try to clean it outside the lock, or let the buffer be gc'd
true
}
}
if (clean)
tryCleanDirectByteBuffer(buf)
}
/**
* DirectByteBuffers are garbage collected by using a phantom reference and a
* reference queue. Every once a while, the JVM checks the reference queue and
* cleans the DirectByteBuffers. However, as this doesn't happen
* immediately after discarding all references to a DirectByteBuffer, it's
* easy to OutOfMemoryError yourself using DirectByteBuffers. This function
* explicitly calls the Cleaner method of a DirectByteBuffer.
*
* Utilizes reflection to avoid dependency to `sun.misc.Cleaner`.
*/
private final def tryCleanDirectByteBuffer(toBeDestroyed: ByteBuffer): Unit = try {
if (toBeDestroyed.isDirect) {
val cleanerMethod = toBeDestroyed.getClass().getMethod("cleaner")
cleanerMethod.setAccessible(true)
val cleaner = cleanerMethod.invoke(toBeDestroyed)
val cleanMethod = cleaner.getClass().getMethod("clean")
cleanMethod.setAccessible(true)
cleanMethod.invoke(cleaner)
} }
} catch {
case NonFatal(_) // attempt failed, ok
}
} }

View file

@ -58,7 +58,7 @@ object SimpleDnsCache {
new Cache( new Cache(
queue + new ExpiryEntry(answer.name, until), queue + new ExpiryEntry(answer.name, until),
cache + (answer.name -> CacheEntry(answer, until)), cache + (answer.name CacheEntry(answer, until)),
clock) clock)
} }

View file

@ -110,11 +110,12 @@ object Tcp extends ExtensionId[TcpExt] with ExtensionIdProvider {
* @param localAddress optionally specifies a specific address to bind to * @param localAddress optionally specifies a specific address to bind to
* @param options Please refer to the `Tcp.SO` object for a list of all supported options. * @param options Please refer to the `Tcp.SO` object for a list of all supported options.
*/ */
final case class Connect(remoteAddress: InetSocketAddress, final case class Connect(
localAddress: Option[InetSocketAddress] = None, remoteAddress: InetSocketAddress,
options: immutable.Traversable[SocketOption] = Nil, localAddress: Option[InetSocketAddress] = None,
timeout: Option[FiniteDuration] = None, options: immutable.Traversable[SocketOption] = Nil,
pullMode: Boolean = false) extends Command timeout: Option[FiniteDuration] = None,
pullMode: Boolean = false) extends Command
/** /**
* The Bind message is send to the TCP manager actor, which is obtained via * The Bind message is send to the TCP manager actor, which is obtained via
@ -135,11 +136,12 @@ object Tcp extends ExtensionId[TcpExt] with ExtensionIdProvider {
* *
* @param options Please refer to the `Tcp.SO` object for a list of all supported options. * @param options Please refer to the `Tcp.SO` object for a list of all supported options.
*/ */
final case class Bind(handler: ActorRef, final case class Bind(
localAddress: InetSocketAddress, handler: ActorRef,
backlog: Int = 100, localAddress: InetSocketAddress,
options: immutable.Traversable[SocketOption] = Nil, backlog: Int = 100,
pullMode: Boolean = false) extends Command options: immutable.Traversable[SocketOption] = Nil,
pullMode: Boolean = false) extends Command
/** /**
* This message must be sent to a TCP connection actor after receiving the * This message must be sent to a TCP connection actor after receiving the
@ -624,11 +626,12 @@ object TcpMessage {
* @param timeout is the desired connection timeout, `null` means "no timeout" * @param timeout is the desired connection timeout, `null` means "no timeout"
* @param pullMode enables pull based reading from the connection * @param pullMode enables pull based reading from the connection
*/ */
def connect(remoteAddress: InetSocketAddress, def connect(
localAddress: InetSocketAddress, remoteAddress: InetSocketAddress,
options: JIterable[SocketOption], localAddress: InetSocketAddress,
timeout: FiniteDuration, options: JIterable[SocketOption],
pullMode: Boolean): Command = Connect(remoteAddress, Option(localAddress), options, Option(timeout), pullMode) timeout: FiniteDuration,
pullMode: Boolean): Command = Connect(remoteAddress, Option(localAddress), options, Option(timeout), pullMode)
/** /**
* Connect to the given `remoteAddress` without binding to a local address and without * Connect to the given `remoteAddress` without binding to a local address and without
@ -658,17 +661,19 @@ object TcpMessage {
* @param pullMode enables pull based accepting and of connections and pull * @param pullMode enables pull based accepting and of connections and pull
* based reading from the accepted connections. * based reading from the accepted connections.
*/ */
def bind(handler: ActorRef, def bind(
endpoint: InetSocketAddress, handler: ActorRef,
backlog: Int, endpoint: InetSocketAddress,
options: JIterable[SocketOption], backlog: Int,
pullMode: Boolean): Command = Bind(handler, endpoint, backlog, options, pullMode) options: JIterable[SocketOption],
pullMode: Boolean): Command = Bind(handler, endpoint, backlog, options, pullMode)
/** /**
* Open a listening socket without specifying options. * Open a listening socket without specifying options.
*/ */
def bind(handler: ActorRef, def bind(
endpoint: InetSocketAddress, handler: ActorRef,
backlog: Int): Command = Bind(handler, endpoint, backlog, Nil) endpoint: InetSocketAddress,
backlog: Int): Command = Bind(handler, endpoint, backlog, Nil)
/** /**
* This message must be sent to a TCP connection actor after receiving the * This message must be sent to a TCP connection actor after receiving the

View file

@ -388,9 +388,9 @@ private[io] abstract class TcpConnection(val tcp: TcpExt, val channel: SocketCha
class PendingBufferWrite( class PendingBufferWrite(
val commander: ActorRef, val commander: ActorRef,
remainingData: ByteString, remainingData: ByteString,
ack: Any, ack: Any,
buffer: ByteBuffer, buffer: ByteBuffer,
tail: WriteCommand) extends PendingWrite { tail: WriteCommand) extends PendingWrite {
def doWrite(info: ConnectionInfo): PendingWrite = { def doWrite(info: ConnectionInfo): PendingWrite = {
@tailrec def writeToChannel(data: ByteString): PendingWrite = { @tailrec def writeToChannel(data: ByteString): PendingWrite = {
@ -429,11 +429,11 @@ private[io] abstract class TcpConnection(val tcp: TcpExt, val channel: SocketCha
class PendingWriteFile( class PendingWriteFile(
val commander: ActorRef, val commander: ActorRef,
fileChannel: FileChannel, fileChannel: FileChannel,
offset: Long, offset: Long,
remaining: Long, remaining: Long,
ack: Event, ack: Event,
tail: WriteCommand) extends PendingWrite with Runnable { tail: WriteCommand) extends PendingWrite with Runnable {
def doWrite(info: ConnectionInfo): PendingWrite = { def doWrite(info: ConnectionInfo): PendingWrite = {
tcp.fileIoDispatcher.execute(this) tcp.fileIoDispatcher.execute(this)
@ -479,10 +479,11 @@ private[io] object TcpConnection {
/** /**
* Groups required connection-related data that are only available once the connection has been fully established. * Groups required connection-related data that are only available once the connection has been fully established.
*/ */
final case class ConnectionInfo(registration: ChannelRegistration, final case class ConnectionInfo(
handler: ActorRef, registration: ChannelRegistration,
keepOpenOnPeerClosed: Boolean, handler: ActorRef,
useResumeWriting: Boolean) keepOpenOnPeerClosed: Boolean,
useResumeWriting: Boolean)
// INTERNAL MESSAGES // INTERNAL MESSAGES

View file

@ -15,12 +15,13 @@ import akka.io.Inet.SocketOption
* *
* INTERNAL API * INTERNAL API
*/ */
private[io] class TcpIncomingConnection(_tcp: TcpExt, private[io] class TcpIncomingConnection(
_channel: SocketChannel, _tcp: TcpExt,
registry: ChannelRegistry, _channel: SocketChannel,
bindHandler: ActorRef, registry: ChannelRegistry,
options: immutable.Traversable[SocketOption], bindHandler: ActorRef,
readThrottling: Boolean) options: immutable.Traversable[SocketOption],
readThrottling: Boolean)
extends TcpConnection(_tcp, _channel, readThrottling) { extends TcpConnection(_tcp, _channel, readThrottling) {
signDeathPact(bindHandler) signDeathPact(bindHandler)

View file

@ -31,11 +31,12 @@ private[io] object TcpListener {
/** /**
* INTERNAL API * INTERNAL API
*/ */
private[io] class TcpListener(selectorRouter: ActorRef, private[io] class TcpListener(
tcp: TcpExt, selectorRouter: ActorRef,
channelRegistry: ChannelRegistry, tcp: TcpExt,
bindCommander: ActorRef, channelRegistry: ChannelRegistry,
bind: Bind) bindCommander: ActorRef,
bind: Bind)
extends Actor with ActorLogging with RequiresMessageQueue[UnboundedMessageQueueSemantics] { extends Actor with ActorLogging with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
import TcpListener._ import TcpListener._

View file

@ -19,10 +19,11 @@ import akka.io.Tcp._
* *
* INTERNAL API * INTERNAL API
*/ */
private[io] class TcpOutgoingConnection(_tcp: TcpExt, private[io] class TcpOutgoingConnection(
channelRegistry: ChannelRegistry, _tcp: TcpExt,
commander: ActorRef, channelRegistry: ChannelRegistry,
connect: Connect) commander: ActorRef,
connect: Connect)
extends TcpConnection(_tcp, SocketChannel.open().configureBlocking(false).asInstanceOf[SocketChannel], connect.pullMode) { extends TcpConnection(_tcp, SocketChannel.open().configureBlocking(false).asInstanceOf[SocketChannel], connect.pullMode) {
import context._ import context._

View file

@ -92,9 +92,10 @@ object Udp extends ExtensionId[UdpExt] with ExtensionIdProvider {
* The listener actor for the newly bound port will reply with a [[Bound]] * The listener actor for the newly bound port will reply with a [[Bound]]
* message, or the manager will reply with a [[CommandFailed]] message. * message, or the manager will reply with a [[CommandFailed]] message.
*/ */
final case class Bind(handler: ActorRef, final case class Bind(
localAddress: InetSocketAddress, handler: ActorRef,
options: immutable.Traversable[SocketOption] = Nil) extends Command localAddress: InetSocketAddress,
options: immutable.Traversable[SocketOption] = Nil) extends Command
/** /**
* Send this message to the listener actor that previously sent a [[Bound]] * Send this message to the listener actor that previously sent a [[Bound]]

View file

@ -84,10 +84,11 @@ object UdpConnected extends ExtensionId[UdpConnectedExt] with ExtensionIdProvide
* which is restricted to sending to and receiving from the given `remoteAddress`. * which is restricted to sending to and receiving from the given `remoteAddress`.
* All received datagrams will be sent to the designated `handler` actor. * All received datagrams will be sent to the designated `handler` actor.
*/ */
final case class Connect(handler: ActorRef, final case class Connect(
remoteAddress: InetSocketAddress, handler: ActorRef,
localAddress: Option[InetSocketAddress] = None, remoteAddress: InetSocketAddress,
options: immutable.Traversable[SocketOption] = Nil) extends Command localAddress: Option[InetSocketAddress] = None,
options: immutable.Traversable[SocketOption] = Nil) extends Command
/** /**
* Send this message to a connection actor (which had previously sent the * Send this message to a connection actor (which had previously sent the
@ -176,21 +177,24 @@ object UdpConnectedMessage {
* which is restricted to sending to and receiving from the given `remoteAddress`. * which is restricted to sending to and receiving from the given `remoteAddress`.
* All received datagrams will be sent to the designated `handler` actor. * All received datagrams will be sent to the designated `handler` actor.
*/ */
def connect(handler: ActorRef, def connect(
remoteAddress: InetSocketAddress, handler: ActorRef,
localAddress: InetSocketAddress, remoteAddress: InetSocketAddress,
options: JIterable[SocketOption]): Command = Connect(handler, remoteAddress, Some(localAddress), options) localAddress: InetSocketAddress,
options: JIterable[SocketOption]): Command = Connect(handler, remoteAddress, Some(localAddress), options)
/** /**
* Connect without specifying the `localAddress`. * Connect without specifying the `localAddress`.
*/ */
def connect(handler: ActorRef, def connect(
remoteAddress: InetSocketAddress, handler: ActorRef,
options: JIterable[SocketOption]): Command = Connect(handler, remoteAddress, None, options) remoteAddress: InetSocketAddress,
options: JIterable[SocketOption]): Command = Connect(handler, remoteAddress, None, options)
/** /**
* Connect without specifying the `localAddress` or `options`. * Connect without specifying the `localAddress` or `options`.
*/ */
def connect(handler: ActorRef, def connect(
remoteAddress: InetSocketAddress): Command = Connect(handler, remoteAddress, None, Nil) handler: ActorRef,
remoteAddress: InetSocketAddress): Command = Connect(handler, remoteAddress, None, Nil)
/** /**
* This message is understood by the connection actors to send data to their * This message is understood by the connection actors to send data to their

View file

@ -18,10 +18,11 @@ import akka.io.UdpConnected._
/** /**
* INTERNAL API * INTERNAL API
*/ */
private[io] class UdpConnection(udpConn: UdpConnectedExt, private[io] class UdpConnection(
channelRegistry: ChannelRegistry, udpConn: UdpConnectedExt,
commander: ActorRef, channelRegistry: ChannelRegistry,
connect: Connect) commander: ActorRef,
connect: Connect)
extends Actor with ActorLogging with RequiresMessageQueue[UnboundedMessageQueueSemantics] { extends Actor with ActorLogging with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
import connect._ import connect._
@ -153,7 +154,8 @@ private[io] class UdpConnection(udpConn: UdpConnectedExt,
thunk thunk
} catch { } catch {
case NonFatal(e) case NonFatal(e)
log.debug("Failure while connecting UDP channel to remote address [{}] local address [{}]: {}", log.debug(
"Failure while connecting UDP channel to remote address [{}] local address [{}]: {}",
remoteAddress, localAddress.getOrElse("undefined"), e) remoteAddress, localAddress.getOrElse("undefined"), e)
commander ! CommandFailed(connect) commander ! CommandFailed(connect)
context.stop(self) context.stop(self)

View file

@ -19,10 +19,11 @@ import akka.io.Udp._
/** /**
* INTERNAL API * INTERNAL API
*/ */
private[io] class UdpListener(val udp: UdpExt, private[io] class UdpListener(
channelRegistry: ChannelRegistry, val udp: UdpExt,
bindCommander: ActorRef, channelRegistry: ChannelRegistry,
bind: Bind) bindCommander: ActorRef,
bind: Bind)
extends Actor with ActorLogging with WithUdpSend with RequiresMessageQueue[UnboundedMessageQueueSemantics] { extends Actor with ActorLogging with WithUdpSend with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
import udp.bufferPool import udp.bufferPool

View file

@ -14,10 +14,11 @@ import akka.actor._
/** /**
* INTERNAL API * INTERNAL API
*/ */
private[io] class UdpSender(val udp: UdpExt, private[io] class UdpSender(
channelRegistry: ChannelRegistry, val udp: UdpExt,
commander: ActorRef, channelRegistry: ChannelRegistry,
options: immutable.Traversable[SocketOption]) commander: ActorRef,
options: immutable.Traversable[SocketOption])
extends Actor with ActorLogging with WithUdpSend with RequiresMessageQueue[UnboundedMessageQueueSemantics] { extends Actor with ActorLogging with WithUdpSend with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
val channel = { val channel = {

View file

@ -51,7 +51,8 @@ private[io] trait WithUdpSend {
} catch { } catch {
case NonFatal(e) case NonFatal(e)
sender() ! CommandFailed(send) sender() ! CommandFailed(send)
log.debug("Failure while sending UDP datagram to remote address [{}]: {}", log.debug(
"Failure while sending UDP datagram to remote address [{}]: {}",
send.target, e) send.target, e)
retriedSend = false retriedSend = false
pendingSend = null pendingSend = null

View file

@ -16,12 +16,12 @@ import akka.actor.SupervisorStrategy._
*/ */
private class BackoffOnRestartSupervisor( private class BackoffOnRestartSupervisor(
val childProps: Props, val childProps: Props,
val childName: String, val childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
val reset: BackoffReset, val reset: BackoffReset,
randomFactor: Double, randomFactor: Double,
strategy: OneForOneStrategy) strategy: OneForOneStrategy)
extends Actor with HandleBackoff extends Actor with HandleBackoff
with ActorLogging { with ActorLogging {

View file

@ -70,10 +70,10 @@ object Backoff {
* In order to skip this additional delay pass in `0`. * In order to skip this additional delay pass in `0`.
*/ */
def onFailure( def onFailure(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double): BackoffOptions = randomFactor: Double): BackoffOptions =
BackoffOptionsImpl(RestartImpliesFailure, childProps, childName, minBackoff, maxBackoff, randomFactor) BackoffOptionsImpl(RestartImpliesFailure, childProps, childName, minBackoff, maxBackoff, randomFactor)
@ -131,10 +131,10 @@ object Backoff {
* In order to skip this additional delay pass in `0`. * In order to skip this additional delay pass in `0`.
*/ */
def onStop( def onStop(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double): BackoffOptions = randomFactor: Double): BackoffOptions =
BackoffOptionsImpl(StopImpliesFailure, childProps, childName, minBackoff, maxBackoff, randomFactor) BackoffOptionsImpl(StopImpliesFailure, childProps, childName, minBackoff, maxBackoff, randomFactor)
} }
@ -183,14 +183,14 @@ trait BackoffOptions {
} }
private final case class BackoffOptionsImpl( private final case class BackoffOptionsImpl(
backoffType: BackoffType = RestartImpliesFailure, backoffType: BackoffType = RestartImpliesFailure,
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double, randomFactor: Double,
reset: Option[BackoffReset] = None, reset: Option[BackoffReset] = None,
supervisorStrategy: OneForOneStrategy = OneForOneStrategy()(SupervisorStrategy.defaultStrategy.decider)) extends BackoffOptions { supervisorStrategy: OneForOneStrategy = OneForOneStrategy()(SupervisorStrategy.defaultStrategy.decider)) extends BackoffOptions {
val backoffReset = reset.getOrElse(AutoReset(minBackoff)) val backoffReset = reset.getOrElse(AutoReset(minBackoff))

View file

@ -37,10 +37,10 @@ object BackoffSupervisor {
* In order to skip this additional delay pass in `0`. * In order to skip this additional delay pass in `0`.
*/ */
def props( def props(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double): Props = { randomFactor: Double): Props = {
propsWithSupervisorStrategy(childProps, childName, minBackoff, maxBackoff, randomFactor, SupervisorStrategy.defaultStrategy) propsWithSupervisorStrategy(childProps, childName, minBackoff, maxBackoff, randomFactor, SupervisorStrategy.defaultStrategy)
} }
@ -66,12 +66,12 @@ object BackoffSupervisor {
* in the child * in the child
*/ */
def propsWithSupervisorStrategy( def propsWithSupervisorStrategy(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double, randomFactor: Double,
strategy: SupervisorStrategy): Props = { strategy: SupervisorStrategy): Props = {
require(minBackoff > Duration.Zero, "minBackoff must be > 0") require(minBackoff > Duration.Zero, "minBackoff must be > 0")
require(maxBackoff >= minBackoff, "maxBackoff must be >= minBackoff") require(maxBackoff >= minBackoff, "maxBackoff must be >= minBackoff")
require(0.0 <= randomFactor && randomFactor <= 1.0, "randomFactor must be between 0.0 and 1.0") require(0.0 <= randomFactor && randomFactor <= 1.0, "randomFactor must be between 0.0 and 1.0")
@ -145,8 +145,8 @@ object BackoffSupervisor {
*/ */
private[akka] def calculateDelay( private[akka] def calculateDelay(
restartCount: Int, restartCount: Int,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double): FiniteDuration = { randomFactor: Double): FiniteDuration = {
val rnd = 1.0 + ThreadLocalRandom.current().nextDouble() * randomFactor val rnd = 1.0 + ThreadLocalRandom.current().nextDouble() * randomFactor
if (restartCount >= 30) // Duration overflow protection (> 100 years) if (restartCount >= 30) // Duration overflow protection (> 100 years)
@ -166,12 +166,12 @@ object BackoffSupervisor {
*/ */
final class BackoffSupervisor( final class BackoffSupervisor(
val childProps: Props, val childProps: Props,
val childName: String, val childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
val reset: BackoffReset, val reset: BackoffReset,
randomFactor: Double, randomFactor: Double,
strategy: SupervisorStrategy) strategy: SupervisorStrategy)
extends Actor with HandleBackoff { extends Actor with HandleBackoff {
import BackoffSupervisor._ import BackoffSupervisor._
@ -192,20 +192,20 @@ final class BackoffSupervisor(
// for binary compatibility with 2.4.1 // for binary compatibility with 2.4.1
def this( def this(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double, randomFactor: Double,
supervisorStrategy: SupervisorStrategy) = supervisorStrategy: SupervisorStrategy) =
this(childProps, childName, minBackoff, maxBackoff, AutoReset(minBackoff), randomFactor, supervisorStrategy) this(childProps, childName, minBackoff, maxBackoff, AutoReset(minBackoff), randomFactor, supervisorStrategy)
// for binary compatibility with 2.4.0 // for binary compatibility with 2.4.0
def this( def this(
childProps: Props, childProps: Props,
childName: String, childName: String,
minBackoff: FiniteDuration, minBackoff: FiniteDuration,
maxBackoff: FiniteDuration, maxBackoff: FiniteDuration,
randomFactor: Double) = randomFactor: Double) =
this(childProps, childName, minBackoff, maxBackoff, randomFactor, SupervisorStrategy.defaultStrategy) this(childProps, childName, minBackoff, maxBackoff, randomFactor, SupervisorStrategy.defaultStrategy)

View file

@ -515,5 +515,5 @@ class CircuitBreaker(scheduler: Scheduler, maxFailures: Int, callTimeout: Finite
*/ */
class CircuitBreakerOpenException( class CircuitBreakerOpenException(
val remainingDuration: FiniteDuration, val remainingDuration: FiniteDuration,
message: String = "Circuit Breaker is open; calls are failing fast") message: String = "Circuit Breaker is open; calls are failing fast")
extends AkkaException(message) with NoStackTrace extends AkkaException(message) with NoStackTrace

View file

@ -66,9 +66,9 @@ private[akka] final class BalancingRoutingLogic extends RoutingLogic {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class BalancingPool( final case class BalancingPool(
override val nrOfInstances: Int, override val nrOfInstances: Int,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Pool { extends Pool {
def this(config: Config) = def this(config: Config) =
@ -112,12 +112,14 @@ final case class BalancingPool(
// dispatcher of this pool // dispatcher of this pool
val deployDispatcherConfigPath = s"akka.actor.deployment.$deployPath.pool-dispatcher" val deployDispatcherConfigPath = s"akka.actor.deployment.$deployPath.pool-dispatcher"
val systemConfig = context.system.settings.config val systemConfig = context.system.settings.config
val dispatcherConfig = context.system.dispatchers.config(dispatcherId, val dispatcherConfig = context.system.dispatchers.config(
dispatcherId,
// use the user defined 'pool-dispatcher' config as fallback, if any // use the user defined 'pool-dispatcher' config as fallback, if any
if (systemConfig.hasPath(deployDispatcherConfigPath)) systemConfig.getConfig(deployDispatcherConfigPath) if (systemConfig.hasPath(deployDispatcherConfigPath)) systemConfig.getConfig(deployDispatcherConfigPath)
else ConfigFactory.empty) else ConfigFactory.empty)
dispatchers.registerConfigurator(dispatcherId, new BalancingDispatcherConfigurator(dispatcherConfig, dispatchers.registerConfigurator(dispatcherId, new BalancingDispatcherConfigurator(
dispatcherConfig,
dispatchers.prerequisites)) dispatchers.prerequisites))
} }

View file

@ -58,8 +58,8 @@ final class BroadcastRoutingLogic extends RoutingLogic {
final case class BroadcastPool( final case class BroadcastPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[BroadcastPool] { extends Pool with PoolOverrideUnsetConfig[BroadcastPool] {
def this(config: Config) = def this(config: Config) =
@ -118,8 +118,8 @@ final case class BroadcastPool(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class BroadcastGroup( final case class BroadcastGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Group { extends Group {
def this(config: Config) = def this(config: Config) =

View file

@ -39,7 +39,8 @@ class ConsistentHash[T: ClassTag] private (nodes: immutable.SortedMap[Int, T], v
*/ */
def :+(node: T): ConsistentHash[T] = { def :+(node: T): ConsistentHash[T] = {
val nodeHash = hashFor(node.toString) val nodeHash = hashFor(node.toString)
new ConsistentHash(nodes ++ ((1 to virtualNodesFactor) map { r (concatenateNodeHash(nodeHash, r) -> node) }), new ConsistentHash(
nodes ++ ((1 to virtualNodesFactor) map { r (concatenateNodeHash(nodeHash, r) node) }),
virtualNodesFactor) virtualNodesFactor)
} }
@ -57,7 +58,8 @@ class ConsistentHash[T: ClassTag] private (nodes: immutable.SortedMap[Int, T], v
*/ */
def :-(node: T): ConsistentHash[T] = { def :-(node: T): ConsistentHash[T] = {
val nodeHash = hashFor(node.toString) val nodeHash = hashFor(node.toString)
new ConsistentHash(nodes -- ((1 to virtualNodesFactor) map { r concatenateNodeHash(nodeHash, r) }), new ConsistentHash(
nodes -- ((1 to virtualNodesFactor) map { r concatenateNodeHash(nodeHash, r) }),
virtualNodesFactor) virtualNodesFactor)
} }
@ -110,12 +112,13 @@ class ConsistentHash[T: ClassTag] private (nodes: immutable.SortedMap[Int, T], v
object ConsistentHash { object ConsistentHash {
def apply[T: ClassTag](nodes: Iterable[T], virtualNodesFactor: Int): ConsistentHash[T] = { def apply[T: ClassTag](nodes: Iterable[T], virtualNodesFactor: Int): ConsistentHash[T] = {
new ConsistentHash(immutable.SortedMap.empty[Int, T] ++ new ConsistentHash(
(for { immutable.SortedMap.empty[Int, T] ++
node nodes (for {
nodeHash = hashFor(node.toString) node nodes
vnode 1 to virtualNodesFactor nodeHash = hashFor(node.toString)
} yield (concatenateNodeHash(nodeHash, vnode) -> node)), vnode 1 to virtualNodesFactor
} yield (concatenateNodeHash(nodeHash, vnode) node)),
virtualNodesFactor) virtualNodesFactor)
} }

View file

@ -135,9 +135,9 @@ object ConsistentHashingRoutingLogic {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class ConsistentHashingRoutingLogic( final case class ConsistentHashingRoutingLogic(
system: ActorSystem, system: ActorSystem,
virtualNodesFactor: Int = 0, virtualNodesFactor: Int = 0,
hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping) hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping)
extends RoutingLogic { extends RoutingLogic {
import ConsistentHashingRouter._ import ConsistentHashingRouter._
@ -219,7 +219,8 @@ final case class ConsistentHashingRoutingLogic(
case _ if hashMapping.isDefinedAt(message) target(hashMapping(message)) case _ if hashMapping.isDefinedAt(message) target(hashMapping(message))
case hashable: ConsistentHashable target(hashable.consistentHashKey) case hashable: ConsistentHashable target(hashable.consistentHashKey)
case other case other
log.warning("Message [{}] must be handled by hashMapping, or implement [{}] or be wrapped in [{}]", log.warning(
"Message [{}] must be handled by hashMapping, or implement [{}] or be wrapped in [{}]",
message.getClass.getName, classOf[ConsistentHashable].getName, message.getClass.getName, classOf[ConsistentHashable].getName,
classOf[ConsistentHashableEnvelope].getName) classOf[ConsistentHashableEnvelope].getName)
NoRoutee NoRoutee
@ -266,13 +267,13 @@ final case class ConsistentHashingRoutingLogic(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class ConsistentHashingPool( final case class ConsistentHashingPool(
override val nrOfInstances: Int, override val nrOfInstances: Int,
override val resizer: Option[Resizer] = None, override val resizer: Option[Resizer] = None,
val virtualNodesFactor: Int = 0, val virtualNodesFactor: Int = 0,
val hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping, val hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[ConsistentHashingPool] { extends Pool with PoolOverrideUnsetConfig[ConsistentHashingPool] {
def this(config: Config) = def this(config: Config) =
@ -354,10 +355,10 @@ final case class ConsistentHashingPool(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class ConsistentHashingGroup( final case class ConsistentHashingGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
val virtualNodesFactor: Int = 0, val virtualNodesFactor: Int = 0,
val hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping, val hashMapping: ConsistentHashingRouter.ConsistentHashMapping = ConsistentHashingRouter.emptyConsistentHashMapping,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Group { extends Group {
def this(config: Config) = def this(config: Config) =

View file

@ -44,9 +44,9 @@ case object OptimalSizeExploringResizer {
*/ */
private[routing] case class ResizeRecord( private[routing] case class ResizeRecord(
underutilizationStreak: Option[UnderUtilizationStreak] = None, underutilizationStreak: Option[UnderUtilizationStreak] = None,
messageCount: Long = 0, messageCount: Long = 0,
totalQueueLength: Int = 0, totalQueueLength: Int = 0,
checkTime: Long = 0) checkTime: Long = 0)
/** /**
* INTERNAL API * INTERNAL API
@ -115,16 +115,16 @@ case object OptimalSizeExploringResizer {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
case class DefaultOptimalSizeExploringResizer( case class DefaultOptimalSizeExploringResizer(
lowerBound: PoolSize = 1, lowerBound: PoolSize = 1,
upperBound: PoolSize = 30, upperBound: PoolSize = 30,
chanceOfScalingDownWhenFull: Double = 0.2, chanceOfScalingDownWhenFull: Double = 0.2,
actionInterval: Duration = 5.seconds, actionInterval: Duration = 5.seconds,
numOfAdjacentSizesToConsiderDuringOptimization: Int = 16, numOfAdjacentSizesToConsiderDuringOptimization: Int = 16,
exploreStepSize: Double = 0.1, exploreStepSize: Double = 0.1,
downsizeRatio: Double = 0.8, downsizeRatio: Double = 0.8,
downsizeAfterUnderutilizedFor: Duration = 72.hours, downsizeAfterUnderutilizedFor: Duration = 72.hours,
explorationProbability: Double = 0.4, explorationProbability: Double = 0.4,
weightOfLatestMetric: Double = 0.5) extends OptimalSizeExploringResizer { weightOfLatestMetric: Double = 0.5) extends OptimalSizeExploringResizer {
/** /**
* Leave package accessible for testing purpose * Leave package accessible for testing purpose
*/ */

View file

@ -59,8 +59,8 @@ final class RandomRoutingLogic extends RoutingLogic {
final case class RandomPool( final case class RandomPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[RandomPool] { extends Pool with PoolOverrideUnsetConfig[RandomPool] {
def this(config: Config) = def this(config: Config) =
@ -119,8 +119,8 @@ final case class RandomPool(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class RandomGroup( final case class RandomGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Group { extends Group {
def this(config: Config) = def this(config: Config) =

View file

@ -126,13 +126,13 @@ case object DefaultResizer {
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
case class DefaultResizer( case class DefaultResizer(
val lowerBound: Int = 1, val lowerBound: Int = 1,
val upperBound: Int = 10, val upperBound: Int = 10,
val pressureThreshold: Int = 1, val pressureThreshold: Int = 1,
val rampupRate: Double = 0.2, val rampupRate: Double = 0.2,
val backoffThreshold: Double = 0.3, val backoffThreshold: Double = 0.3,
val backoffRate: Double = 0.1, val backoffRate: Double = 0.1,
val messagesPerResize: Int = 10) extends Resizer { val messagesPerResize: Int = 10) extends Resizer {
/** /**
* Java API constructor for default values except bounds. * Java API constructor for default values except bounds.
@ -246,13 +246,13 @@ case class DefaultResizer(
* INTERNAL API * INTERNAL API
*/ */
private[akka] final class ResizablePoolCell( private[akka] final class ResizablePoolCell(
_system: ActorSystemImpl, _system: ActorSystemImpl,
_ref: InternalActorRef, _ref: InternalActorRef,
_routerProps: Props, _routerProps: Props,
_routerDispatcher: MessageDispatcher, _routerDispatcher: MessageDispatcher,
_routeeProps: Props, _routeeProps: Props,
_supervisor: InternalActorRef, _supervisor: InternalActorRef,
val pool: Pool) val pool: Pool)
extends RoutedActorCell(_system, _ref, _routerProps, _routerDispatcher, _routeeProps, _supervisor) { extends RoutedActorCell(_system, _ref, _routerProps, _routerDispatcher, _routeeProps, _supervisor) {
require(pool.resizer.isDefined, "RouterConfig must be a Pool with defined resizer") require(pool.resizer.isDefined, "RouterConfig must be a Pool with defined resizer")

View file

@ -67,12 +67,13 @@ final class RoundRobinRoutingLogic extends RoutingLogic {
final case class RoundRobinPool( final case class RoundRobinPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[RoundRobinPool] { extends Pool with PoolOverrideUnsetConfig[RoundRobinPool] {
def this(config: Config) = def this(config: Config) =
this(nrOfInstances = config.getInt("nr-of-instances"), this(
nrOfInstances = config.getInt("nr-of-instances"),
resizer = Resizer.fromConfig(config), resizer = Resizer.fromConfig(config),
usePoolDispatcher = config.hasPath("pool-dispatcher")) usePoolDispatcher = config.hasPath("pool-dispatcher"))
@ -127,8 +128,8 @@ final case class RoundRobinPool(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class RoundRobinGroup( final case class RoundRobinGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Group { extends Group {
def this(config: Config) = def this(config: Config) =

View file

@ -35,12 +35,12 @@ private[akka] object RoutedActorCell {
* INTERNAL API * INTERNAL API
*/ */
private[akka] class RoutedActorCell( private[akka] class RoutedActorCell(
_system: ActorSystemImpl, _system: ActorSystemImpl,
_ref: InternalActorRef, _ref: InternalActorRef,
_routerProps: Props, _routerProps: Props,
_routerDispatcher: MessageDispatcher, _routerDispatcher: MessageDispatcher,
val routeeProps: Props, val routeeProps: Props,
_supervisor: InternalActorRef) _supervisor: InternalActorRef)
extends ActorCell(_system, _ref, _routerProps, _routerDispatcher, _supervisor) { extends ActorCell(_system, _ref, _routerProps, _routerDispatcher, _supervisor) {
private[akka] val routerConfig = _routerProps.routerConfig private[akka] val routerConfig = _routerProps.routerConfig
@ -154,8 +154,9 @@ private[akka] class RouterActor extends Actor {
} }
val routingLogicController: Option[ActorRef] = cell.routerConfig.routingLogicController( val routingLogicController: Option[ActorRef] = cell.routerConfig.routingLogicController(
cell.router.logic).map(props context.actorOf(props.withDispatcher(context.props.dispatcher), cell.router.logic).map(props context.actorOf(
name = "routingLogicController")) props.withDispatcher(context.props.dispatcher),
name = "routingLogicController"))
def receive = { def receive = {
case GetRoutees case GetRoutees

View file

@ -22,13 +22,13 @@ import akka.dispatch.MessageDispatcher
* send a message to one (or more) of these actors. * send a message to one (or more) of these actors.
*/ */
private[akka] class RoutedActorRef( private[akka] class RoutedActorRef(
_system: ActorSystemImpl, _system: ActorSystemImpl,
_routerProps: Props, _routerProps: Props,
_routerDispatcher: MessageDispatcher, _routerDispatcher: MessageDispatcher,
_routerMailbox: MailboxType, _routerMailbox: MailboxType,
_routeeProps: Props, _routeeProps: Props,
_supervisor: InternalActorRef, _supervisor: InternalActorRef,
_path: ActorPath) _path: ActorPath)
extends RepointableActorRef(_system, _routerProps, _routerDispatcher, _routerMailbox, _supervisor, _path) { extends RepointableActorRef(_system, _routerProps, _routerDispatcher, _routerMailbox, _supervisor, _path) {
// verify that a BalancingDispatcher is not used with a Router // verify that a BalancingDispatcher is not used with a Router

View file

@ -3,7 +3,6 @@
*/ */
package akka.routing package akka.routing
import scala.collection.immutable import scala.collection.immutable
import akka.ConfigurationException import akka.ConfigurationException
import akka.actor.ActorContext import akka.actor.ActorContext
@ -282,9 +281,9 @@ case object FromConfig extends FromConfig {
*/ */
def getInstance = this def getInstance = this
@inline final def apply( @inline final def apply(
resizer: Option[Resizer] = None, resizer: Option[Resizer] = None,
supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
routerDispatcher: String = Dispatchers.DefaultDispatcherId) = routerDispatcher: String = Dispatchers.DefaultDispatcherId) =
new FromConfig(resizer, supervisorStrategy, routerDispatcher) new FromConfig(resizer, supervisorStrategy, routerDispatcher)
@inline final def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher) @inline final def unapply(fc: FromConfig): Option[String] = Some(fc.routerDispatcher)
@ -297,9 +296,10 @@ case object FromConfig extends FromConfig {
* (defaults to default-dispatcher). * (defaults to default-dispatcher).
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
class FromConfig(override val resizer: Option[Resizer], class FromConfig(
override val supervisorStrategy: SupervisorStrategy, override val resizer: Option[Resizer],
override val routerDispatcher: String) extends Pool { override val supervisorStrategy: SupervisorStrategy,
override val routerDispatcher: String) extends Pool {
def this() = this(None, Pool.defaultSupervisorStrategy, Dispatchers.DefaultDispatcherId) def this() = this(None, Pool.defaultSupervisorStrategy, Dispatchers.DefaultDispatcherId)

View file

@ -97,10 +97,10 @@ private[akka] final case class ScatterGatherFirstCompletedRoutees(
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class ScatterGatherFirstCompletedPool( final case class ScatterGatherFirstCompletedPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
within: FiniteDuration, within: FiniteDuration,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[ScatterGatherFirstCompletedPool] { extends Pool with PoolOverrideUnsetConfig[ScatterGatherFirstCompletedPool] {
def this(config: Config) = def this(config: Config) =
@ -165,9 +165,9 @@ final case class ScatterGatherFirstCompletedPool(
*/ */
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class ScatterGatherFirstCompletedGroup( final case class ScatterGatherFirstCompletedGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
within: FiniteDuration, within: FiniteDuration,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) override val routerDispatcher: String = Dispatchers.DefaultDispatcherId)
extends Group { extends Group {
def this(config: Config) = def this(config: Config) =

View file

@ -45,11 +45,12 @@ class SmallestMailboxRoutingLogic extends RoutingLogic {
// 4. An ActorRef with unknown mailbox size that isn't processing anything // 4. An ActorRef with unknown mailbox size that isn't processing anything
// 5. An ActorRef with a known mailbox size // 5. An ActorRef with a known mailbox size
// 6. An ActorRef without any messages // 6. An ActorRef without any messages
@tailrec private def selectNext(targets: immutable.IndexedSeq[Routee], @tailrec private def selectNext(
proposedTarget: Routee = NoRoutee, targets: immutable.IndexedSeq[Routee],
currentScore: Long = Long.MaxValue, proposedTarget: Routee = NoRoutee,
at: Int = 0, currentScore: Long = Long.MaxValue,
deep: Boolean = false): Routee = { at: Int = 0,
deep: Boolean = false): Routee = {
if (targets.isEmpty) if (targets.isEmpty)
NoRoutee NoRoutee
else if (at >= targets.size) { else if (at >= targets.size) {
@ -174,8 +175,8 @@ class SmallestMailboxRoutingLogic extends RoutingLogic {
final case class SmallestMailboxPool( final case class SmallestMailboxPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[SmallestMailboxPool] { extends Pool with PoolOverrideUnsetConfig[SmallestMailboxPool] {
def this(config: Config) = def this(config: Config) =

View file

@ -142,11 +142,11 @@ private[akka] final case class TailChoppingRoutees(
@SerialVersionUID(1L) @SerialVersionUID(1L)
final case class TailChoppingPool( final case class TailChoppingPool(
override val nrOfInstances: Int, override val resizer: Option[Resizer] = None, override val nrOfInstances: Int, override val resizer: Option[Resizer] = None,
within: FiniteDuration, within: FiniteDuration,
interval: FiniteDuration, interval: FiniteDuration,
override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy, override val supervisorStrategy: SupervisorStrategy = Pool.defaultSupervisorStrategy,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId, override val routerDispatcher: String = Dispatchers.DefaultDispatcherId,
override val usePoolDispatcher: Boolean = false) override val usePoolDispatcher: Boolean = false)
extends Pool with PoolOverrideUnsetConfig[TailChoppingPool] { extends Pool with PoolOverrideUnsetConfig[TailChoppingPool] {
def this(config: Config) = def this(config: Config) =
@ -227,10 +227,10 @@ final case class TailChoppingPool(
* router management messages * router management messages
*/ */
final case class TailChoppingGroup( final case class TailChoppingGroup(
override val paths: immutable.Iterable[String], override val paths: immutable.Iterable[String],
within: FiniteDuration, within: FiniteDuration,
interval: FiniteDuration, interval: FiniteDuration,
override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) extends Group { override val routerDispatcher: String = Dispatchers.DefaultDispatcherId) extends Group {
def this(config: Config) = def this(config: Config) =
this( this(

View file

@ -38,7 +38,7 @@ object Serialization {
private final def configToMap(path: String): Map[String, String] = { private final def configToMap(path: String): Map[String, String] = {
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
config.getConfig(path).root.unwrapped.asScala.toMap map { case (k, v) (k -> v.toString) } config.getConfig(path).root.unwrapped.asScala.toMap map { case (k, v) (k v.toString) }
} }
} }
@ -236,7 +236,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
* loading is performed by the systems [[akka.actor.DynamicAccess]]. * loading is performed by the systems [[akka.actor.DynamicAccess]].
*/ */
def serializerOf(serializerFQN: String): Try[Serializer] = def serializerOf(serializerFQN: String): Try[Serializer] =
system.dynamicAccess.createInstanceFor[Serializer](serializerFQN, List(classOf[ExtendedActorSystem] -> system)) recoverWith { system.dynamicAccess.createInstanceFor[Serializer](serializerFQN, List(classOf[ExtendedActorSystem] system)) recoverWith {
case _: NoSuchMethodException system.dynamicAccess.createInstanceFor[Serializer](serializerFQN, Nil) case _: NoSuchMethodException system.dynamicAccess.createInstanceFor[Serializer](serializerFQN, Nil)
} }
@ -245,7 +245,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
* By default always contains the following mapping: "java" -> akka.serialization.JavaSerializer * By default always contains the following mapping: "java" -> akka.serialization.JavaSerializer
*/ */
private val serializers: Map[String, Serializer] = private val serializers: Map[String, Serializer] =
for ((k: String, v: String) settings.Serializers) yield k -> serializerOf(v).get for ((k: String, v: String) settings.Serializers) yield k serializerOf(v).get
/** /**
* bindings is a Seq of tuple representing the mapping from Class to Serializer. * bindings is a Seq of tuple representing the mapping from Class to Serializer.
@ -286,7 +286,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
* Maps from a Serializer Identity (Int) to a Serializer instance (optimization) * Maps from a Serializer Identity (Int) to a Serializer instance (optimization)
*/ */
val serializerByIdentity: Map[Int, Serializer] = val serializerByIdentity: Map[Int, Serializer] =
Map(NullSerializer.identifier -> NullSerializer) ++ serializers map { case (_, v) (v.identifier, v) } Map(NullSerializer.identifier NullSerializer) ++ serializers map { case (_, v) (v.identifier, v) }
private val isJavaSerializationWarningEnabled = settings.config.getBoolean("akka.actor.warn-about-java-serializer-usage") private val isJavaSerializationWarningEnabled = settings.config.getBoolean("akka.actor.warn-about-java-serializer-usage")

View file

@ -7,15 +7,15 @@ object BoxedType {
import java.{ lang jl } import java.{ lang jl }
private val toBoxed = Map[Class[_], Class[_]]( private val toBoxed = Map[Class[_], Class[_]](
classOf[Boolean] -> classOf[jl.Boolean], classOf[Boolean] classOf[jl.Boolean],
classOf[Byte] -> classOf[jl.Byte], classOf[Byte] classOf[jl.Byte],
classOf[Char] -> classOf[jl.Character], classOf[Char] classOf[jl.Character],
classOf[Short] -> classOf[jl.Short], classOf[Short] classOf[jl.Short],
classOf[Int] -> classOf[jl.Integer], classOf[Int] classOf[jl.Integer],
classOf[Long] -> classOf[jl.Long], classOf[Long] classOf[jl.Long],
classOf[Float] -> classOf[jl.Float], classOf[Float] classOf[jl.Float],
classOf[Double] -> classOf[jl.Double], classOf[Double] classOf[jl.Double],
classOf[Unit] -> classOf[scala.runtime.BoxedUnit]) classOf[Unit] classOf[scala.runtime.BoxedUnit])
final def apply(c: Class[_]): Class[_] = if (c.isPrimitive) toBoxed(c) else c final def apply(c: Class[_]): Class[_] = if (c.isPrimitive) toBoxed(c) else c
} }

View file

@ -357,7 +357,7 @@ object ByteString {
private[akka] object Companion { private[akka] object Companion {
private val companionMap = Seq(ByteString1, ByteString1C, ByteStrings). private val companionMap = Seq(ByteString1, ByteString1C, ByteStrings).
map(x x.SerializationIdentity -> x).toMap. map(x x.SerializationIdentity x).toMap.
withDefault(x throw new IllegalArgumentException("Invalid serialization id " + x)) withDefault(x throw new IllegalArgumentException("Invalid serialization id " + x))
def apply(from: Byte): Companion = companionMap(from) def apply(from: Byte): Companion = companionMap(from)

View file

@ -187,7 +187,7 @@ object LineNumbers {
val cl = c.getClassLoader val cl = c.getClassLoader
val r = cl.getResourceAsStream(resource) val r = cl.getResourceAsStream(resource)
if (debug) println(s"LNB: resource '$resource' resolved to stream $r") if (debug) println(s"LNB: resource '$resource' resolved to stream $r")
Option(r).map(_ -> None) Option(r).map(_ None)
} }
private def getStreamForLambda(l: AnyRef): Option[(InputStream, Some[String])] = private def getStreamForLambda(l: AnyRef): Option[(InputStream, Some[String])] =
@ -269,7 +269,7 @@ object LineNumbers {
val count = d.readUnsignedShort() val count = d.readUnsignedShort()
if (debug) println(s"LNB: reading $count methods") if (debug) println(s"LNB: reading $count methods")
if (c.contains("Code") && c.contains("LineNumberTable")) { if (c.contains("Code") && c.contains("LineNumberTable")) {
(1 to count).map(_ readMethod(d, c("Code"), c("LineNumberTable"), filter)).flatten.foldLeft(Int.MaxValue -> 0) { (1 to count).map(_ readMethod(d, c("Code"), c("LineNumberTable"), filter)).flatten.foldLeft(Int.MaxValue 0) {
case ((low, high), (start, end)) (Math.min(low, start), Math.max(high, end)) case ((low, high), (start, end)) (Math.min(low, start), Math.max(high, end))
} match { } match {
case (Int.MaxValue, 0) None case (Int.MaxValue, 0) None
@ -282,10 +282,11 @@ object LineNumbers {
} }
} }
private def readMethod(d: DataInputStream, private def readMethod(
codeTag: Int, d: DataInputStream,
lineNumberTableTag: Int, codeTag: Int,
filter: Option[String])(implicit c: Constants): Option[(Int, Int)] = { lineNumberTableTag: Int,
filter: Option[String])(implicit c: Constants): Option[(Int, Int)] = {
skip(d, 2) // access flags skip(d, 2) // access flags
val name = d.readUnsignedShort() // name val name = d.readUnsignedShort() // name
skip(d, 2) // signature skip(d, 2) // signature
@ -315,7 +316,7 @@ object LineNumbers {
skip(d, 2) // start PC skip(d, 2) // start PC
d.readUnsignedShort() // finally: the line number d.readUnsignedShort() // finally: the line number
} }
Some(lines.min -> lines.max) Some(lines.min lines.max)
} }
} }
if (debug) println(s"LNB: nested attributes yielded: $possibleLines") if (debug) println(s"LNB: nested attributes yielded: $possibleLines")

View file

@ -127,7 +127,7 @@ private[akka] class SubclassifiedIndex[K, V] private (protected var values: Set[
if (!found) { if (!found) {
val v = values + value val v = values + value
val n = new Nonroot(root, key, v) val n = new Nonroot(root, key, v)
integrate(n) ++ n.innerAddValue(key, value) :+ (key -> v) integrate(n) ++ n.innerAddValue(key, value) :+ (key v)
} else ch } else ch
} }

View file

@ -34,7 +34,7 @@ class ActorCreationBenchmark {
} }
@TearDown(Level.Trial) @TearDown(Level.Trial)
def shutdown():Unit = { def shutdown(): Unit = {
system.terminate() system.terminate()
Await.ready(system.whenTerminated, 15.seconds) Await.ready(system.whenTerminated, 15.seconds)
} }

View file

@ -28,7 +28,7 @@ class ForkJoinActorBenchmark {
implicit var system: ActorSystem = _ implicit var system: ActorSystem = _
@Setup(Level.Trial) @Setup(Level.Trial)
def setup():Unit = { def setup(): Unit = {
system = ActorSystem("ForkJoinActorBenchmark", ConfigFactory.parseString( system = ActorSystem("ForkJoinActorBenchmark", ConfigFactory.parseString(
s"""| akka { s"""| akka {
| log-dead-letters = off | log-dead-letters = off
@ -44,11 +44,12 @@ class ForkJoinActorBenchmark {
| } | }
| } | }
| } | }
""".stripMargin)) """.stripMargin
))
} }
@TearDown(Level.Trial) @TearDown(Level.Trial)
def shutdown():Unit = { def shutdown(): Unit = {
system.terminate() system.terminate()
Await.ready(system.whenTerminated, 15.seconds) Await.ready(system.whenTerminated, 15.seconds)
} }
@ -56,7 +57,7 @@ class ForkJoinActorBenchmark {
@Benchmark @Benchmark
@Measurement(timeUnit = TimeUnit.MILLISECONDS) @Measurement(timeUnit = TimeUnit.MILLISECONDS)
@OperationsPerInvocation(messages) @OperationsPerInvocation(messages)
def pingPong():Unit = { def pingPong(): Unit = {
val ping = system.actorOf(Props[ForkJoinActorBenchmark.PingPong]) val ping = system.actorOf(Props[ForkJoinActorBenchmark.PingPong])
val pong = system.actorOf(Props[ForkJoinActorBenchmark.PingPong]) val pong = system.actorOf(Props[ForkJoinActorBenchmark.PingPong])
@ -72,7 +73,7 @@ class ForkJoinActorBenchmark {
@Benchmark @Benchmark
@Measurement(timeUnit = TimeUnit.MILLISECONDS) @Measurement(timeUnit = TimeUnit.MILLISECONDS)
@OperationsPerInvocation(messages) @OperationsPerInvocation(messages)
def floodPipe():Unit = { def floodPipe(): Unit = {
val end = system.actorOf(Props(classOf[ForkJoinActorBenchmark.Pipe], None)) val end = system.actorOf(Props(classOf[ForkJoinActorBenchmark.Pipe], None))
val middle = system.actorOf(Props(classOf[ForkJoinActorBenchmark.Pipe], Some(end))) val middle = system.actorOf(Props(classOf[ForkJoinActorBenchmark.Pipe], Some(end)))

View file

@ -26,7 +26,7 @@ class RouterPoolCreationBenchmark {
var size = 0 var size = 0
@TearDown(Level.Trial) @TearDown(Level.Trial)
def shutdown():Unit = { def shutdown(): Unit = {
system.terminate() system.terminate()
Await.ready(system.whenTerminated, 15.seconds) Await.ready(system.whenTerminated, 15.seconds)
} }

View file

@ -56,13 +56,13 @@ class ScheduleBenchmark {
var promise: Promise[Any] = _ var promise: Promise[Any] = _
@Setup(Level.Iteration) @Setup(Level.Iteration)
def setup():Unit = { def setup(): Unit = {
winner = (to * ratio + 1).toInt winner = (to * ratio + 1).toInt
promise = Promise[Any]() promise = Promise[Any]()
} }
@TearDown @TearDown
def shutdown():Unit = { def shutdown(): Unit = {
system.terminate() system.terminate()
Await.ready(system.whenTerminated, 15.seconds) Await.ready(system.whenTerminated, 15.seconds)
} }
@ -70,7 +70,7 @@ class ScheduleBenchmark {
def op(idx: Int) = if (idx == winner) promise.trySuccess(idx) else idx def op(idx: Int) = if (idx == winner) promise.trySuccess(idx) else idx
@Benchmark @Benchmark
def oneSchedule():Unit = { def oneSchedule(): Unit = {
val aIdx = new AtomicInteger(1) val aIdx = new AtomicInteger(1)
val tryWithNext = scheduler.schedule(0.millis, interval) { val tryWithNext = scheduler.schedule(0.millis, interval) {
val idx = aIdx.getAndIncrement val idx = aIdx.getAndIncrement
@ -84,7 +84,7 @@ class ScheduleBenchmark {
} }
@Benchmark @Benchmark
def multipleScheduleOnce():Unit = { def multipleScheduleOnce(): Unit = {
val tryWithNext = (1 to to).foldLeft(0.millis -> List[Cancellable]()) { val tryWithNext = (1 to to).foldLeft(0.millis -> List[Cancellable]()) {
case ((interv, c), idx) case ((interv, c), idx)
(interv + interval, scheduler.scheduleOnce(interv) { (interv + interval, scheduler.scheduleOnce(interv) {

View file

@ -35,7 +35,7 @@ class StashCreationBenchmark {
val probe = TestProbe() val probe = TestProbe()
@TearDown(Level.Trial) @TearDown(Level.Trial)
def shutdown():Unit = { def shutdown(): Unit = {
system.terminate() system.terminate()
Await.ready(system.whenTerminated, 15.seconds) Await.ready(system.whenTerminated, 15.seconds)
} }

Some files were not shown because too many files have changed in this diff Show more