Upgrade to Scala 2.13.5 (#30072)
This commit is contained in:
parent
846359919f
commit
c5655a9ce6
264 changed files with 1071 additions and 538 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
# 2 new methods, TestProbe is not for user extension
|
||||||
|
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.actor.testkit.typed.scaladsl.TestProbe.fishForMessagePF")
|
||||||
|
|
@ -105,6 +105,7 @@ private[akka] final class TestProbeImpl[M](name: String, system: ActorSystem[_])
|
||||||
case x if x eq Duration.Undefined => duration
|
case x if x eq Duration.Undefined => duration
|
||||||
case x if !x.isFinite => throw new IllegalArgumentException("`end` cannot be infinite")
|
case x if !x.isFinite => throw new IllegalArgumentException("`end` cannot be infinite")
|
||||||
case f: FiniteDuration => f - now
|
case f: FiniteDuration => f - now
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getRemainingOr(duration: JDuration): JDuration =
|
override def getRemainingOr(duration: JDuration): JDuration =
|
||||||
|
|
@ -266,9 +267,16 @@ private[akka] final class TestProbeImpl[M](name: String, system: ActorSystem[_])
|
||||||
override def fishForMessage(max: FiniteDuration, hint: String)(fisher: M => FishingOutcome): immutable.Seq[M] =
|
override def fishForMessage(max: FiniteDuration, hint: String)(fisher: M => FishingOutcome): immutable.Seq[M] =
|
||||||
fishForMessage_internal(max.dilated, hint, fisher)
|
fishForMessage_internal(max.dilated, hint, fisher)
|
||||||
|
|
||||||
|
override def fishForMessagePF(max: FiniteDuration, hint: String)(
|
||||||
|
fisher: PartialFunction[M, FishingOutcome]): immutable.Seq[M] =
|
||||||
|
fishForMessage(max, hint)(fisher)
|
||||||
|
|
||||||
override def fishForMessage(max: FiniteDuration)(fisher: M => FishingOutcome): immutable.Seq[M] =
|
override def fishForMessage(max: FiniteDuration)(fisher: M => FishingOutcome): immutable.Seq[M] =
|
||||||
fishForMessage(max, "")(fisher)
|
fishForMessage(max, "")(fisher)
|
||||||
|
|
||||||
|
override def fishForMessagePF(max: FiniteDuration)(fisher: PartialFunction[M, FishingOutcome]): immutable.Seq[M] =
|
||||||
|
fishForMessage(max)(fisher)
|
||||||
|
|
||||||
override def fishForMessage(max: JDuration, fisher: java.util.function.Function[M, FishingOutcome]): JList[M] =
|
override def fishForMessage(max: JDuration, fisher: java.util.function.Function[M, FishingOutcome]): JList[M] =
|
||||||
fishForMessage(max, "", fisher)
|
fishForMessage(max, "", fisher)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,11 +198,21 @@ object TestProbe {
|
||||||
*/
|
*/
|
||||||
def fishForMessage(max: FiniteDuration, hint: String)(fisher: M => FishingOutcome): immutable.Seq[M]
|
def fishForMessage(max: FiniteDuration, hint: String)(fisher: M => FishingOutcome): immutable.Seq[M]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as `fishForMessage` but accepting a partial function and failing for non-matches
|
||||||
|
*/
|
||||||
|
def fishForMessagePF(max: FiniteDuration, hint: String)(fisher: PartialFunction[M, FishingOutcome]): immutable.Seq[M]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as the other `fishForMessage` but with no hint
|
* Same as the other `fishForMessage` but with no hint
|
||||||
*/
|
*/
|
||||||
def fishForMessage(max: FiniteDuration)(fisher: M => FishingOutcome): immutable.Seq[M]
|
def fishForMessage(max: FiniteDuration)(fisher: M => FishingOutcome): immutable.Seq[M]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as `fishForMessage` but with no hint, accepting a partial function and failing for non-matches
|
||||||
|
*/
|
||||||
|
def fishForMessagePF(max: FiniteDuration)(fisher: PartialFunction[M, FishingOutcome]): immutable.Seq[M]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expect the given actor to be stopped or stop within the given timeout or
|
* Expect the given actor to be stopped or stop within the given timeout or
|
||||||
* throw an [[AssertionError]].
|
* throw an [[AssertionError]].
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ object BehaviorTestKitSpec {
|
||||||
case IsTimerActive(key, replyTo) =>
|
case IsTimerActive(key, replyTo) =>
|
||||||
replyTo ! timers.isTimerActive(key)
|
replyTo ! timers.isTimerActive(key)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected command: $unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.receiveSignal {
|
.receiveSignal {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
probe.ref ! "two"
|
probe.ref ! "two"
|
||||||
|
|
||||||
intercept[AssertionError] {
|
intercept[AssertionError] {
|
||||||
probe.fishForMessage(shortDuration) {
|
probe.fishForMessagePF(shortDuration) {
|
||||||
case "one" => FishingOutcomes.continue
|
case "one" => FishingOutcomes.continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +117,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
probe.ref ! "one"
|
probe.ref ! "one"
|
||||||
|
|
||||||
intercept[AssertionError] {
|
intercept[AssertionError] {
|
||||||
probe.fishForMessage(shortDuration) {
|
probe.fishForMessagePF(shortDuration) {
|
||||||
case "one" => FishingOutcomes.continue
|
case "one" => FishingOutcomes.continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class ActorSelectionSpec extends AkkaSpec with DefaultTimeout {
|
||||||
def empty(path: String) =
|
def empty(path: String) =
|
||||||
new EmptyLocalActorRef(sysImpl.provider, path match {
|
new EmptyLocalActorRef(sysImpl.provider, path match {
|
||||||
case RelativeActorPath(elems) => sysImpl.lookupRoot.path / elems
|
case RelativeActorPath(elems) => sysImpl.lookupRoot.path / elems
|
||||||
|
case _ => throw new RuntimeException()
|
||||||
}, system.eventStream)
|
}, system.eventStream)
|
||||||
|
|
||||||
val idProbe = TestProbe()
|
val idProbe = TestProbe()
|
||||||
|
|
@ -79,6 +80,7 @@ class ActorSelectionSpec extends AkkaSpec with DefaultTimeout {
|
||||||
Await.result(node ? query, timeout.duration) match {
|
Await.result(node ? query, timeout.duration) match {
|
||||||
case ref: ActorRef => Some(ref)
|
case ref: ActorRef => Some(ref)
|
||||||
case selection: ActorSelection => identify(selection)
|
case selection: ActorSelection => identify(selection)
|
||||||
|
case _ => throw new RuntimeException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -365,8 +367,13 @@ class ActorSelectionSpec extends AkkaSpec with DefaultTimeout {
|
||||||
|
|
||||||
val probe = TestProbe()
|
val probe = TestProbe()
|
||||||
system.actorSelection("/user/a/*").tell(Identify(1), probe.ref)
|
system.actorSelection("/user/a/*").tell(Identify(1), probe.ref)
|
||||||
probe.receiveN(2).map { case ActorIdentity(1, r) => r }.toSet should ===(
|
probe
|
||||||
Set[Option[ActorRef]](Some(b1), Some(b2)))
|
.receiveN(2)
|
||||||
|
.map {
|
||||||
|
case ActorIdentity(1, r) => r
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
|
}
|
||||||
|
.toSet should ===(Set[Option[ActorRef]](Some(b1), Some(b2)))
|
||||||
probe.expectNoMessage()
|
probe.expectNoMessage()
|
||||||
|
|
||||||
system.actorSelection("/user/a/b1/*").tell(Identify(2), probe.ref)
|
system.actorSelection("/user/a/b1/*").tell(Identify(2), probe.ref)
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ object ActorSystemSpec {
|
||||||
TestKit.awaitCond(mbox.actor.actor != null, 1.second)
|
TestKit.awaitCond(mbox.actor.actor != null, 1.second)
|
||||||
mbox.actor.actor match {
|
mbox.actor.actor match {
|
||||||
case FastActor(latch, _) => Await.ready(latch, 1.second)
|
case FastActor(latch, _) => Await.ready(latch, 1.second)
|
||||||
|
case _ => throw new IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ object Chameneos {
|
||||||
final case class MeetingCount(count: Int) extends ChameneosEvent
|
final case class MeetingCount(count: Int) extends ChameneosEvent
|
||||||
case object Exit extends ChameneosEvent
|
case object Exit extends ChameneosEvent
|
||||||
|
|
||||||
abstract class Colour
|
abstract sealed class Colour
|
||||||
case object RED extends Colour
|
case object RED extends Colour
|
||||||
case object YELLOW extends Colour
|
case object YELLOW extends Colour
|
||||||
case object BLUE extends Colour
|
case object BLUE extends Colour
|
||||||
|
|
|
||||||
|
|
@ -683,6 +683,7 @@ object SupervisorHierarchySpec {
|
||||||
if (depth > 0) {
|
if (depth > 0) {
|
||||||
l.underlying.children.foreach(getErrors(_, depth - 1))
|
l.underlying.children.foreach(getErrors(_, depth - 1))
|
||||||
}
|
}
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -694,6 +695,7 @@ object SupervisorHierarchySpec {
|
||||||
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)
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,7 @@ object TypedActorSpec {
|
||||||
override def onReceive(msg: Any, sender: ActorRef): Unit = {
|
override def onReceive(msg: Any, sender: ActorRef): Unit = {
|
||||||
ensureContextAvailable(msg match {
|
ensureContextAvailable(msg match {
|
||||||
case "pigdog" => sender ! "dogpig"
|
case "pigdog" => sender ! "dogpig"
|
||||||
|
case _ =>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn
|
||||||
config match {
|
config match {
|
||||||
case BoundedMailbox(capacity, _) => aQueue.remainingCapacity should ===(capacity)
|
case BoundedMailbox(capacity, _) => aQueue.remainingCapacity should ===(capacity)
|
||||||
case UnboundedMailbox() => aQueue.remainingCapacity should ===(Int.MaxValue)
|
case UnboundedMailbox() => aQueue.remainingCapacity should ===(Int.MaxValue)
|
||||||
|
case _ => fail()
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
|
|
@ -187,6 +188,7 @@ class DefaultMailboxSpec extends MailboxSpec {
|
||||||
def factory = {
|
def factory = {
|
||||||
case u: UnboundedMailbox => u.create(None, None)
|
case u: UnboundedMailbox => u.create(None, None)
|
||||||
case b: BoundedMailbox => b.create(None, None)
|
case b: BoundedMailbox => b.create(None, None)
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,6 +199,7 @@ class PriorityMailboxSpec extends MailboxSpec {
|
||||||
case UnboundedMailbox() => new UnboundedPriorityMailbox(comparator).create(None, None)
|
case UnboundedMailbox() => new UnboundedPriorityMailbox(comparator).create(None, None)
|
||||||
case BoundedMailbox(capacity, pushTimeOut) =>
|
case BoundedMailbox(capacity, pushTimeOut) =>
|
||||||
new BoundedPriorityMailbox(comparator, capacity, pushTimeOut).create(None, None)
|
new BoundedPriorityMailbox(comparator, capacity, pushTimeOut).create(None, None)
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,6 +210,7 @@ class StablePriorityMailboxSpec extends MailboxSpec {
|
||||||
case UnboundedMailbox() => new UnboundedStablePriorityMailbox(comparator).create(None, None)
|
case UnboundedMailbox() => new UnboundedStablePriorityMailbox(comparator).create(None, None)
|
||||||
case BoundedMailbox(capacity, pushTimeOut) =>
|
case BoundedMailbox(capacity, pushTimeOut) =>
|
||||||
new BoundedStablePriorityMailbox(comparator, capacity, pushTimeOut).create(None, None)
|
new BoundedStablePriorityMailbox(comparator, capacity, pushTimeOut).create(None, None)
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,6 +220,7 @@ class ControlAwareMailboxSpec extends MailboxSpec {
|
||||||
case UnboundedMailbox() => new UnboundedControlAwareMailbox().create(None, None)
|
case UnboundedMailbox() => new UnboundedControlAwareMailbox().create(None, None)
|
||||||
case BoundedMailbox(capacity, pushTimeOut) =>
|
case BoundedMailbox(capacity, pushTimeOut) =>
|
||||||
new BoundedControlAwareMailbox(capacity, pushTimeOut).create(None, None)
|
new BoundedControlAwareMailbox(capacity, pushTimeOut).create(None, None)
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,6 +263,7 @@ class SingleConsumerOnlyMailboxSpec extends MailboxSpec {
|
||||||
def factory = {
|
def factory = {
|
||||||
case _: UnboundedMailbox => SingleConsumerOnlyUnboundedMailbox().create(None, None)
|
case _: UnboundedMailbox => SingleConsumerOnlyUnboundedMailbox().create(None, None)
|
||||||
case _ @BoundedMailbox(capacity, _) => NonBlockingBoundedMailbox(capacity).create(None, None)
|
case _ @BoundedMailbox(capacity, _) => NonBlockingBoundedMailbox(capacity).create(None, None)
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,14 @@ object PriorityDispatcherSpec {
|
||||||
extends UnboundedPriorityMailbox(PriorityGenerator({
|
extends UnboundedPriorityMailbox(PriorityGenerator({
|
||||||
case i: Int => i //Reverse order
|
case i: Int => i //Reverse order
|
||||||
case Result => Int.MaxValue
|
case Result => Int.MaxValue
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}: Any => Int))
|
}: Any => Int))
|
||||||
|
|
||||||
class Bounded(@unused settings: ActorSystem.Settings, @unused config: Config)
|
class Bounded(@unused settings: ActorSystem.Settings, @unused config: Config)
|
||||||
extends BoundedPriorityMailbox(PriorityGenerator({
|
extends BoundedPriorityMailbox(PriorityGenerator({
|
||||||
case i: Int => i //Reverse order
|
case i: Int => i //Reverse order
|
||||||
case Result => Int.MaxValue
|
case Result => Int.MaxValue
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}: Any => Int), 1000, 10 seconds)
|
}: Any => Int), 1000, 10 seconds)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ object StablePriorityDispatcherSpec {
|
||||||
case i: Int if i <= 100 => i // Small integers have high priority
|
case i: Int if i <= 100 => i // Small integers have high priority
|
||||||
case _: Int => 101 // Don't care for other integers
|
case _: Int => 101 // Don't care for other integers
|
||||||
case Result => Int.MaxValue
|
case Result => Int.MaxValue
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}: Any => Int))
|
}: Any => Int))
|
||||||
|
|
||||||
class Bounded(@unused settings: ActorSystem.Settings, @unused config: Config)
|
class Bounded(@unused settings: ActorSystem.Settings, @unused config: Config)
|
||||||
|
|
@ -37,6 +38,7 @@ object StablePriorityDispatcherSpec {
|
||||||
case i: Int if i <= 100 => i // Small integers have high priority
|
case i: Int if i <= 100 => i // Small integers have high priority
|
||||||
case _: Int => 101 // Don't care for other integers
|
case _: Int => 101 // Don't care for other integers
|
||||||
case Result => Int.MaxValue
|
case Result => Int.MaxValue
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}: Any => Int), 1000, 10 seconds)
|
}: Any => Int), 1000, 10 seconds)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package akka.io
|
||||||
|
|
||||||
import java.net.DatagramSocket
|
import java.net.DatagramSocket
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
|
||||||
import akka.actor.ActorRef
|
import akka.actor.ActorRef
|
||||||
import akka.io.Inet._
|
import akka.io.Inet._
|
||||||
import akka.io.Udp._
|
import akka.io.Udp._
|
||||||
|
|
@ -64,7 +63,9 @@ class UdpIntegrationSpec extends AkkaSpec("""
|
||||||
}
|
}
|
||||||
|
|
||||||
"be able to send several packet back and forth with binding" in {
|
"be able to send several packet back and forth with binding" in {
|
||||||
val Seq(serverAddress, clientAddress) = temporaryServerAddresses(2, udp = true)
|
val addresses = temporaryServerAddresses(2, udp = true)
|
||||||
|
val serverAddress = addresses(0)
|
||||||
|
val clientAddress = addresses(1)
|
||||||
val server = bindUdp(serverAddress, testActor)
|
val server = bindUdp(serverAddress, testActor)
|
||||||
val client = bindUdp(clientAddress, testActor)
|
val client = bindUdp(clientAddress, testActor)
|
||||||
val data = ByteString("Fly little packet!")
|
val data = ByteString("Fly little packet!")
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@ class AsyncDnsManagerSpec extends AkkaSpec("""
|
||||||
|
|
||||||
"support ipv6" in {
|
"support ipv6" in {
|
||||||
dns ! Resolve("::1") // ::1 will short circuit the resolution
|
dns ! Resolve("::1") // ::1 will short circuit the resolution
|
||||||
val Resolved("::1", Seq(AAAARecord("::1", Ttl.effectivelyForever, _)), Nil) = expectMsgType[Resolved]
|
expectMsgType[Resolved] match {
|
||||||
|
case Resolved("::1", Seq(AAAARecord("::1", Ttl.effectivelyForever, _)), Nil) =>
|
||||||
|
case other => fail(other.toString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"support ipv6 also using the old protocol" in {
|
"support ipv6 also using the old protocol" in {
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,9 @@ class AsyncDnsResolverSpec extends AkkaSpec("""
|
||||||
r ! Resolve(name)
|
r ! Resolve(name)
|
||||||
dnsClient1.expectNoMessage(50.millis)
|
dnsClient1.expectNoMessage(50.millis)
|
||||||
val answer = senderProbe.expectMsgType[Resolved]
|
val answer = senderProbe.expectMsgType[Resolved]
|
||||||
val Seq(aaaaRecord) = answer.records.collect {
|
val aaaaRecord = answer.records match {
|
||||||
case r: AAAARecord => r
|
case Seq(r: AAAARecord) => r
|
||||||
|
case _ => throw new RuntimeException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
aaaaRecord.name should be("1:2:3:0:0:0:0:0")
|
aaaaRecord.name should be("1:2:3:0:0:0:0:0")
|
||||||
aaaaRecord.ttl should be(Ttl.effectivelyForever)
|
aaaaRecord.ttl should be(Ttl.effectivelyForever)
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,9 @@ class ConfiguredLocalRoutingSpec
|
||||||
r.underlying match {
|
r.underlying match {
|
||||||
case c: RoutedActorCell => c.routerConfig
|
case c: RoutedActorCell => c.routerConfig
|
||||||
case _: UnstartedCell => awaitCond(r.isStarted, 1 second, 10 millis); routerConfig(ref)
|
case _: UnstartedCell => awaitCond(r.isStarted, 1 second, 10 millis); routerConfig(ref)
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unexpected underlying cell ${r.underlying}")
|
||||||
}
|
}
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unexpected actorref $ref")
|
||||||
}
|
}
|
||||||
|
|
||||||
def collectRouteePaths(probe: TestProbe, router: ActorRef, n: Int): immutable.Seq[ActorPath] = {
|
def collectRouteePaths(probe: TestProbe, router: ActorRef, n: Int): immutable.Seq[ActorPath] = {
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,8 @@ package akka.serialization
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.CompletionStage
|
import java.util.concurrent.CompletionStage
|
||||||
|
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
|
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
|
||||||
import akka.actor.ExtendedActorSystem
|
import akka.actor.ExtendedActorSystem
|
||||||
import akka.testkit.{ AkkaSpec, EventFilter }
|
import akka.testkit.{ AkkaSpec, EventFilter }
|
||||||
|
|
||||||
|
|
@ -45,6 +42,7 @@ object AsyncSerializeSpec {
|
||||||
o match {
|
o match {
|
||||||
case Message1(msg) => Future.successful(msg.getBytes)
|
case Message1(msg) => Future.successful(msg.getBytes)
|
||||||
case Message2(msg) => Future.successful(msg.getBytes)
|
case Message2(msg) => Future.successful(msg.getBytes)
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown type $o")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +50,7 @@ object AsyncSerializeSpec {
|
||||||
manifest match {
|
manifest match {
|
||||||
case "1" => Future.successful(Message1(new String(bytes)))
|
case "1" => Future.successful(Message1(new String(bytes)))
|
||||||
case "2" => Future.successful(Message2(new String(bytes)))
|
case "2" => Future.successful(Message2(new String(bytes)))
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown manifest $manifest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +59,7 @@ object AsyncSerializeSpec {
|
||||||
override def manifest(o: AnyRef): String = o match {
|
override def manifest(o: AnyRef): String = o match {
|
||||||
case _: Message1 => "1"
|
case _: Message1 => "1"
|
||||||
case _: Message2 => "2"
|
case _: Message2 => "2"
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown type $o")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,6 +69,7 @@ object AsyncSerializeSpec {
|
||||||
o match {
|
o match {
|
||||||
case Message3(msg) => CompletableFuture.completedFuture(msg.getBytes)
|
case Message3(msg) => CompletableFuture.completedFuture(msg.getBytes)
|
||||||
case Message4(msg) => CompletableFuture.completedFuture(msg.getBytes)
|
case Message4(msg) => CompletableFuture.completedFuture(msg.getBytes)
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown type $o")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,6 +77,7 @@ object AsyncSerializeSpec {
|
||||||
manifest match {
|
manifest match {
|
||||||
case "1" => CompletableFuture.completedFuture(Message3(new String(bytes)))
|
case "1" => CompletableFuture.completedFuture(Message3(new String(bytes)))
|
||||||
case "2" => CompletableFuture.completedFuture(Message4(new String(bytes)))
|
case "2" => CompletableFuture.completedFuture(Message4(new String(bytes)))
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown manifest $manifest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,6 +86,7 @@ object AsyncSerializeSpec {
|
||||||
override def manifest(o: AnyRef): String = o match {
|
override def manifest(o: AnyRef): String = o match {
|
||||||
case _: Message3 => "1"
|
case _: Message3 => "1"
|
||||||
case _: Message4 => "2"
|
case _: Message4 => "2"
|
||||||
|
case _ => throw new IllegalArgumentException(s"Unknown type $o")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -619,10 +619,10 @@ trait CustomContainsMatcher {
|
||||||
|
|
||||||
def attemptMatch(remainingTruth: List[A], remainingSequence: List[A]): MatchResult =
|
def attemptMatch(remainingTruth: List[A], remainingSequence: List[A]): MatchResult =
|
||||||
(remainingTruth, remainingSequence) match {
|
(remainingTruth, remainingSequence) match {
|
||||||
case (_, Nil) => matchResult(true)
|
case (_, Nil) => matchResult(true)
|
||||||
case (Nil, _) => matchResult(false)
|
case (Nil, _) => matchResult(false)
|
||||||
case (x :: xs, y :: ys) if x.equals(y) => attemptMatch(xs, ys)
|
case (x :: xs, y :: ys) if x == y => attemptMatch(xs, ys)
|
||||||
case (_ :: xs, ys) => attemptMatch(xs, ys)
|
case (_ :: xs, ys) => attemptMatch(xs, ys)
|
||||||
}
|
}
|
||||||
|
|
||||||
def matchResult(success: Boolean): MatchResult =
|
def matchResult(success: Boolean): MatchResult =
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ object InterceptSpec {
|
||||||
val wrapped = msg match {
|
val wrapped = msg match {
|
||||||
case c: Command => InternalProtocol.WrappedCommand(c)
|
case c: Command => InternalProtocol.WrappedCommand(c)
|
||||||
case r: ExternalResponse => InternalProtocol.WrappedExternalResponse(r)
|
case r: ExternalResponse => InternalProtocol.WrappedExternalResponse(r)
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}
|
}
|
||||||
target(ctx, wrapped)
|
target(ctx, wrapped)
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +64,7 @@ object InterceptSpec {
|
||||||
|
|
||||||
def apply(probe: ActorRef[String]): Behavior[Command] = {
|
def apply(probe: ActorRef[String]): Behavior[Command] = {
|
||||||
Behaviors
|
Behaviors
|
||||||
.intercept(() => new ProtocolTransformer)(Behaviors.receiveMessage[InternalProtocol] {
|
.intercept(() => new ProtocolTransformer)(Behaviors.receiveMessagePartial[InternalProtocol] {
|
||||||
case InternalProtocol.WrappedCommand(cmd) =>
|
case InternalProtocol.WrappedCommand(cmd) =>
|
||||||
probe ! cmd.s
|
probe ! cmd.s
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
@ -396,6 +397,7 @@ class InterceptSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
signal match {
|
signal match {
|
||||||
case PostStop =>
|
case PostStop =>
|
||||||
probe.ref ! "interceptor-post-stop"
|
probe.ref ! "interceptor-post-stop"
|
||||||
|
case _ =>
|
||||||
}
|
}
|
||||||
target(ctx, signal)
|
target(ctx, signal)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ class MailboxSelectorSpec extends ScalaTestWithActorTestKit("""
|
||||||
adapter.classicContext match {
|
adapter.classicContext match {
|
||||||
case cell: ActorCell =>
|
case cell: ActorCell =>
|
||||||
cell.mailbox.messageQueue
|
cell.mailbox.messageQueue
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}
|
}
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}
|
}
|
||||||
|
|
||||||
replyTo ! mailbox
|
replyTo ! mailbox
|
||||||
|
|
|
||||||
|
|
@ -1195,6 +1195,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
||||||
case "boom" =>
|
case "boom" =>
|
||||||
probe.ref ! context.self
|
probe.ref ! context.self
|
||||||
Behaviors.stopped
|
Behaviors.stopped
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
context.watch(child)
|
context.watch(child)
|
||||||
|
|
@ -1420,7 +1421,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
||||||
Behaviors.stopped
|
Behaviors.stopped
|
||||||
} else {
|
} else {
|
||||||
stopInSetup.set(true)
|
stopInSetup.set(true)
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case "boom" => throw TestException("boom")
|
case "boom" => throw TestException("boom")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,12 @@ class TerminatedSpec extends AnyWordSpec with Matchers with LogCapturing {
|
||||||
|
|
||||||
(childFailed match {
|
(childFailed match {
|
||||||
case Terminated(r) => r
|
case Terminated(r) => r
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}) shouldEqual probe.ref
|
}) shouldEqual probe.ref
|
||||||
|
|
||||||
(childFailed match {
|
(childFailed match {
|
||||||
case ChildFailed(ref, e) => (ref, e)
|
case ChildFailed(ref, e) => (ref, e)
|
||||||
|
case unexpected => throw new RuntimeException(s"Unexpected: $unexpected")
|
||||||
}) shouldEqual ((probe.ref, ex))
|
}) shouldEqual ((probe.ref, ex))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import akka.testkit.TestProbe
|
||||||
object ProbedBehavior {
|
object ProbedBehavior {
|
||||||
def behavior(probe: u.ActorRef): Behavior[String] = {
|
def behavior(probe: u.ActorRef): Behavior[String] = {
|
||||||
Behaviors
|
Behaviors
|
||||||
.receiveMessage[String] {
|
.receiveMessagePartial[String] {
|
||||||
case "throw" => throw TestException("oh dear")
|
case "throw" => throw TestException("oh dear")
|
||||||
}
|
}
|
||||||
.receiveSignal {
|
.receiveSignal {
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,11 @@
|
||||||
package akka.actor.typed.delivery
|
package akka.actor.typed.delivery
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
import scala.concurrent.duration.Duration
|
import scala.concurrent.duration.Duration
|
||||||
import scala.concurrent.duration.FiniteDuration
|
import scala.concurrent.duration.FiniteDuration
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef
|
import akka.actor.typed.ActorRef
|
||||||
import akka.actor.typed.Behavior
|
import akka.actor.typed.Behavior
|
||||||
import akka.actor.typed.delivery.ConsumerController.SequencedMessage
|
import akka.actor.typed.delivery.ConsumerController.SequencedMessage
|
||||||
|
|
@ -21,6 +18,8 @@ import akka.actor.typed.scaladsl.ActorContext
|
||||||
import akka.actor.typed.scaladsl.Behaviors
|
import akka.actor.typed.scaladsl.Behaviors
|
||||||
import akka.serialization.SerializerWithStringManifest
|
import akka.serialization.SerializerWithStringManifest
|
||||||
|
|
||||||
|
import java.io.NotSerializableException
|
||||||
|
|
||||||
object TestConsumer {
|
object TestConsumer {
|
||||||
|
|
||||||
final case class Job(payload: String)
|
final case class Job(payload: String)
|
||||||
|
|
@ -140,6 +139,7 @@ class TestSerializer extends SerializerWithStringManifest {
|
||||||
override def toBinary(o: AnyRef): Array[Byte] =
|
override def toBinary(o: AnyRef): Array[Byte] =
|
||||||
o match {
|
o match {
|
||||||
case TestConsumer.Job(payload) => payload.getBytes(StandardCharsets.UTF_8)
|
case TestConsumer.Job(payload) => payload.getBytes(StandardCharsets.UTF_8)
|
||||||
|
case unexpected => throw new NotSerializableException(s"Unexpected: $unexpected")
|
||||||
}
|
}
|
||||||
|
|
||||||
override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef =
|
override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef =
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class TestDurableProducerQueue[A](
|
||||||
|
|
||||||
private def active(state: State[A]): Behavior[Command[A]] = {
|
private def active(state: State[A]): Behavior[Command[A]] = {
|
||||||
stateHolder.set(state)
|
stateHolder.set(state)
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case cmd: LoadState[A] @unchecked =>
|
case cmd: LoadState[A] @unchecked =>
|
||||||
maybeFail(cmd)
|
maybeFail(cmd)
|
||||||
if (delay == Duration.Zero) cmd.replyTo ! state else context.scheduleOnce(delay, cmd.replyTo, state)
|
if (delay == Duration.Zero) cmd.replyTo ! state else context.scheduleOnce(delay, cmd.replyTo, state)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import akka.actor.typed.scaladsl.Behaviors
|
||||||
|
|
||||||
object TestProducer {
|
object TestProducer {
|
||||||
|
|
||||||
trait Command
|
sealed trait Command
|
||||||
final case class RequestNext(sendTo: ActorRef[TestConsumer.Job]) extends Command
|
final case class RequestNext(sendTo: ActorRef[TestConsumer.Job]) extends Command
|
||||||
private case object Tick extends Command
|
private case object Tick extends Command
|
||||||
|
|
||||||
|
|
@ -62,12 +62,10 @@ object TestProducer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private def activeNoDelay(n: Int): Behavior[Command] = {
|
private def activeNoDelay(n: Int): Behavior[Command] = {
|
||||||
Behaviors.receive { (ctx, msg) =>
|
Behaviors.receivePartial {
|
||||||
msg match {
|
case (ctx, RequestNext(sendTo)) =>
|
||||||
case RequestNext(sendTo) =>
|
sendMessage(n, sendTo, ctx)
|
||||||
sendMessage(n, sendTo, ctx)
|
activeNoDelay(n + 1)
|
||||||
activeNoDelay(n + 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,17 +43,15 @@ object TestProducerWithAsk {
|
||||||
}
|
}
|
||||||
|
|
||||||
private def idle(n: Int, replyProbe: ActorRef[Long]): Behavior[Command] = {
|
private def idle(n: Int, replyProbe: ActorRef[Long]): Behavior[Command] = {
|
||||||
Behaviors.receive { (ctx, msg) =>
|
Behaviors.receivePartial {
|
||||||
msg match {
|
case (_, Tick) => Behaviors.same
|
||||||
case Tick => Behaviors.same
|
case (_, RequestNext(sendTo)) => active(n + 1, replyProbe, sendTo)
|
||||||
case RequestNext(sendTo) => active(n + 1, replyProbe, sendTo)
|
case (_, Confirmed(seqNr)) =>
|
||||||
case Confirmed(seqNr) =>
|
replyProbe ! seqNr
|
||||||
replyProbe ! seqNr
|
Behaviors.same
|
||||||
Behaviors.same
|
case (ctx, AskTimeout) =>
|
||||||
case AskTimeout =>
|
ctx.log.warn("Timeout")
|
||||||
ctx.log.warn("Timeout")
|
Behaviors.same
|
||||||
Behaviors.same
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,33 +59,32 @@ object TestProducerWithAsk {
|
||||||
n: Int,
|
n: Int,
|
||||||
replyProbe: ActorRef[Long],
|
replyProbe: ActorRef[Long],
|
||||||
sendTo: ActorRef[ProducerController.MessageWithConfirmation[TestConsumer.Job]]): Behavior[Command] = {
|
sendTo: ActorRef[ProducerController.MessageWithConfirmation[TestConsumer.Job]]): Behavior[Command] = {
|
||||||
Behaviors.receive { (ctx, msg) =>
|
Behaviors.receivePartial {
|
||||||
msg match {
|
case (ctx, Tick) =>
|
||||||
case Tick =>
|
val msg = s"msg-$n"
|
||||||
val msg = s"msg-$n"
|
ctx.log.info("sent {}", msg)
|
||||||
ctx.log.info("sent {}", msg)
|
ctx.ask(
|
||||||
ctx.ask(
|
sendTo,
|
||||||
sendTo,
|
(askReplyTo: ActorRef[Long]) =>
|
||||||
(askReplyTo: ActorRef[Long]) =>
|
ProducerController.MessageWithConfirmation(TestConsumer.Job(msg), askReplyTo)) {
|
||||||
ProducerController.MessageWithConfirmation(TestConsumer.Job(msg), askReplyTo)) {
|
case Success(seqNr) => Confirmed(seqNr)
|
||||||
case Success(seqNr) => Confirmed(seqNr)
|
case Failure(_) => AskTimeout
|
||||||
case Failure(_) => AskTimeout
|
}
|
||||||
}
|
idle(n, replyProbe)
|
||||||
idle(n, replyProbe)
|
|
||||||
|
|
||||||
case RequestNext(_) =>
|
case (_, RequestNext(_)) =>
|
||||||
throw new IllegalStateException("Unexpected RequestNext, already got one.")
|
throw new IllegalStateException("Unexpected RequestNext, already got one.")
|
||||||
|
|
||||||
case Confirmed(seqNr) =>
|
case (ctx, Confirmed(seqNr)) =>
|
||||||
ctx.log.info("Reply Confirmed [{}]", seqNr)
|
ctx.log.info("Reply Confirmed [{}]", seqNr)
|
||||||
replyProbe ! seqNr
|
replyProbe ! seqNr
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
case AskTimeout =>
|
case (ctx, AskTimeout) =>
|
||||||
ctx.log.warn("Timeout")
|
ctx.log.warn("Timeout")
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,24 +33,22 @@ object TestProducerWorkPulling {
|
||||||
}
|
}
|
||||||
|
|
||||||
private def idle(n: Int): Behavior[Command] = {
|
private def idle(n: Int): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case Tick => Behaviors.same
|
case Tick => Behaviors.same
|
||||||
case RequestNext(sendTo) => active(n + 1, sendTo)
|
case RequestNext(sendTo) => active(n + 1, sendTo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def active(n: Int, sendTo: ActorRef[TestConsumer.Job]): Behavior[Command] = {
|
private def active(n: Int, sendTo: ActorRef[TestConsumer.Job]): Behavior[Command] = {
|
||||||
Behaviors.receive { (ctx, msg) =>
|
Behaviors.receivePartial {
|
||||||
msg match {
|
case (ctx, Tick) =>
|
||||||
case Tick =>
|
val msg = s"msg-$n"
|
||||||
val msg = s"msg-$n"
|
ctx.log.info("sent {}", msg)
|
||||||
ctx.log.info("sent {}", msg)
|
sendTo ! TestConsumer.Job(msg)
|
||||||
sendTo ! TestConsumer.Job(msg)
|
idle(n)
|
||||||
idle(n)
|
|
||||||
|
|
||||||
case RequestNext(_) =>
|
case (_, RequestNext(_)) =>
|
||||||
throw new IllegalStateException("Unexpected RequestNext, already got one.")
|
throw new IllegalStateException("Unexpected RequestNext, already got one.")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ class AdaptationFailureSpec extends ScalaTestWithActorTestKit with AnyWordSpecLi
|
||||||
case (_, Terminated(`ref`)) =>
|
case (_, Terminated(`ref`)) =>
|
||||||
probe.ref ! "actor-stopped"
|
probe.ref ! "actor-stopped"
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
case _ => Behaviors.unhandled
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ object ReceptionistApiSpec {
|
||||||
// to cover as much of the API as possible
|
// to cover as much of the API as possible
|
||||||
context.system.receptionist ! Receptionist.Register(key, context.self.narrow, context.self.narrow)
|
context.system.receptionist ! Receptionist.Register(key, context.self.narrow, context.self.narrow)
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case key.Listing(services) =>
|
case key.Listing(services) =>
|
||||||
services.foreach(_ ! "woho")
|
services.foreach(_ ! "woho")
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,11 @@ class ActorContextAskSpec
|
||||||
case class Ping(respondTo: ActorRef[Pong.type]) extends Protocol
|
case class Ping(respondTo: ActorRef[Pong.type]) extends Protocol
|
||||||
case object Pong extends Protocol
|
case object Pong extends Protocol
|
||||||
|
|
||||||
val pingPong = spawn(Behaviors.receive[Protocol]((_, message) =>
|
val pingPong = spawn(Behaviors.receiveMessagePartial[Protocol] {
|
||||||
message match {
|
case Ping(respondTo) =>
|
||||||
case Ping(respondTo) =>
|
respondTo ! Pong
|
||||||
respondTo ! Pong
|
Behaviors.same
|
||||||
Behaviors.same
|
})
|
||||||
}))
|
|
||||||
|
|
||||||
val snitch = Behaviors.setup[AnyRef] { context =>
|
val snitch = Behaviors.setup[AnyRef] { context =>
|
||||||
context.ask(pingPong, Ping) {
|
context.ask(pingPong, Ping) {
|
||||||
|
|
@ -93,7 +92,7 @@ class ActorContextAskSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
Behaviors
|
Behaviors
|
||||||
.receive[AnyRef] {
|
.receivePartial[AnyRef] {
|
||||||
case (_, message) =>
|
case (_, message) =>
|
||||||
probe.ref ! message
|
probe.ref ! message
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class MessageAdapterSpec
|
||||||
|
|
||||||
case class Wrapped(qualifier: String, response: Response)
|
case class Wrapped(qualifier: String, response: Response)
|
||||||
|
|
||||||
val pingPong = spawn(Behaviors.receiveMessage[Ping] {
|
val pingPong = spawn(Behaviors.receiveMessagePartial[Ping] {
|
||||||
case Ping1(sender) =>
|
case Ping1(sender) =>
|
||||||
sender ! Pong1("hello-1")
|
sender ! Pong1("hello-1")
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
@ -131,10 +131,10 @@ class MessageAdapterSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
"not break if wrong/unknown response type" in {
|
"not break if wrong/unknown response type" in {
|
||||||
trait Ping
|
sealed trait Ping
|
||||||
case class Ping1(sender: ActorRef[Pong1]) extends Ping
|
case class Ping1(sender: ActorRef[Pong1]) extends Ping
|
||||||
case class Ping2(sender: ActorRef[Pong2]) extends Ping
|
case class Ping2(sender: ActorRef[Pong2]) extends Ping
|
||||||
trait Response
|
sealed trait Response
|
||||||
case class Pong1(greeting: String) extends Response
|
case class Pong1(greeting: String) extends Response
|
||||||
case class Pong2(greeting: String) extends Response
|
case class Pong2(greeting: String) extends Response
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ final class OnSignalSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike
|
||||||
}, s"$i")
|
}, s"$i")
|
||||||
}
|
}
|
||||||
Behaviors
|
Behaviors
|
||||||
.receiveMessage[String] {
|
.receiveMessagePartial[String] {
|
||||||
case "stop" =>
|
case "stop" =>
|
||||||
Behaviors.stopped
|
Behaviors.stopped
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ class RoutersSpec extends ScalaTestWithActorTestKit("""
|
||||||
case object BCast extends Cmd
|
case object BCast extends Cmd
|
||||||
|
|
||||||
def behavior(replyTo: ActorRef[AnyRef]) = Behaviors.setup[Cmd] { ctx =>
|
def behavior(replyTo: ActorRef[AnyRef]) = Behaviors.setup[Cmd] { ctx =>
|
||||||
Behaviors.receiveMessage[Cmd] {
|
Behaviors.receiveMessagePartial[Cmd] {
|
||||||
case ReplyWithAck | BCast =>
|
case ReplyWithAck | BCast =>
|
||||||
val reply = ctx.self.path
|
val reply = ctx.self.path
|
||||||
replyTo ! reply
|
replyTo ! reply
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
}
|
}
|
||||||
|
|
||||||
Behaviors.receiveMessage[String] {
|
Behaviors.receiveMessagePartial[String] {
|
||||||
case msg if msg.startsWith("stash") =>
|
case msg if msg.startsWith("stash") =>
|
||||||
stash.stash(msg)
|
stash.stash(msg)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
@ -635,14 +635,14 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
stash.stash("handled")
|
stash.stash("handled")
|
||||||
|
|
||||||
def unstashing(n: Int): Behavior[String] =
|
def unstashing(n: Int): Behavior[String] =
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case "unhandled" => Behaviors.unhandled
|
case "unhandled" => Behaviors.unhandled
|
||||||
case "handled" =>
|
case "handled" =>
|
||||||
probe.ref ! s"handled $n"
|
probe.ref ! s"handled $n"
|
||||||
unstashing(n + 1)
|
unstashing(n + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case "unstash" =>
|
case "unstash" =>
|
||||||
stash.unstashAll(unstashing(1))
|
stash.unstashAll(unstashing(1))
|
||||||
}
|
}
|
||||||
|
|
@ -665,7 +665,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
val ref = spawn(Behaviors.withStash[String](10) { stash =>
|
val ref = spawn(Behaviors.withStash[String](10) { stash =>
|
||||||
stash.stash("one")
|
stash.stash("one")
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case "unstash" =>
|
case "unstash" =>
|
||||||
stash.unstashAll(Behaviors.stopped)
|
stash.unstashAll(Behaviors.stopped)
|
||||||
}
|
}
|
||||||
|
|
@ -683,7 +683,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
|
||||||
stash.stash("one")
|
stash.stash("one")
|
||||||
stash.stash("two")
|
stash.stash("two")
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case "unstash" =>
|
case "unstash" =>
|
||||||
stash.unstashAll(Behaviors.receiveMessage { unstashed =>
|
stash.unstashAll(Behaviors.receiveMessage { unstashed =>
|
||||||
probe.ref ! unstashed
|
probe.ref ! unstashed
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class StopSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with LogCa
|
||||||
|
|
||||||
"execute the post stop" in {
|
"execute the post stop" in {
|
||||||
val probe = TestProbe[Done]()
|
val probe = TestProbe[Done]()
|
||||||
val ref = spawn(Behaviors.receiveMessage[String] {
|
val ref = spawn(Behaviors.receiveMessagePartial[String] {
|
||||||
case "stop" =>
|
case "stop" =>
|
||||||
Behaviors.stopped { () =>
|
Behaviors.stopped { () =>
|
||||||
probe.ref ! Done
|
probe.ref ! Done
|
||||||
|
|
@ -46,7 +46,7 @@ class StopSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with LogCa
|
||||||
val probe = TestProbe[String]()
|
val probe = TestProbe[String]()
|
||||||
val ref = spawn(
|
val ref = spawn(
|
||||||
Behaviors
|
Behaviors
|
||||||
.receiveMessage[String] {
|
.receiveMessagePartial[String] {
|
||||||
case "stop" =>
|
case "stop" =>
|
||||||
Behaviors.stopped { () =>
|
Behaviors.stopped { () =>
|
||||||
probe.ref ! "callback"
|
probe.ref ! "callback"
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ object Aggregator {
|
||||||
|
|
||||||
def collecting(replies: immutable.IndexedSeq[Reply]): Behavior[Command] = {
|
def collecting(replies: immutable.IndexedSeq[Reply]): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessage {
|
||||||
case WrappedReply(reply: Reply) =>
|
case WrappedReply(reply) =>
|
||||||
val newReplies = replies :+ reply
|
val newReplies = replies :+ reply.asInstanceOf[Reply]
|
||||||
if (newReplies.size == expectedReplies) {
|
if (newReplies.size == expectedReplies) {
|
||||||
val result = aggregateReplies(newReplies)
|
val result = aggregateReplies(newReplies)
|
||||||
replyTo ! result
|
replyTo ! result
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ object AggregatorSpec {
|
||||||
.map {
|
.map {
|
||||||
case Hotel1.Quote(hotel, price) => Quote(hotel, price)
|
case Hotel1.Quote(hotel, price) => Quote(hotel, price)
|
||||||
case Hotel2.Price(hotel, price) => Quote(hotel, price)
|
case Hotel2.Price(hotel, price) => Quote(hotel, price)
|
||||||
|
case unknown => throw new RuntimeException(s"Unknown reply $unknown")
|
||||||
}
|
}
|
||||||
.sortBy(_.price)
|
.sortBy(_.price)
|
||||||
.toList),
|
.toList),
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ object IntroSpec {
|
||||||
final case class SessionDenied(reason: String) extends SessionEvent
|
final case class SessionDenied(reason: String) extends SessionEvent
|
||||||
final case class MessagePosted(screenName: String, message: String) extends SessionEvent
|
final case class MessagePosted(screenName: String, message: String) extends SessionEvent
|
||||||
|
|
||||||
trait SessionCommand
|
sealed trait SessionCommand
|
||||||
final case class PostMessage(message: String) extends SessionCommand
|
final case class PostMessage(message: String) extends SessionCommand
|
||||||
private final case class NotifyClient(message: MessagePosted) extends SessionCommand
|
private final case class NotifyClient(message: MessagePosted) extends SessionCommand
|
||||||
//#chatroom-protocol
|
//#chatroom-protocol
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ object OOIntroSpec {
|
||||||
final case class SessionDenied(reason: String) extends SessionEvent
|
final case class SessionDenied(reason: String) extends SessionEvent
|
||||||
final case class MessagePosted(screenName: String, message: String) extends SessionEvent
|
final case class MessagePosted(screenName: String, message: String) extends SessionEvent
|
||||||
|
|
||||||
trait SessionCommand
|
sealed trait SessionCommand
|
||||||
final case class PostMessage(message: String) extends SessionCommand
|
final case class PostMessage(message: String) extends SessionCommand
|
||||||
private final case class NotifyClient(message: MessagePosted) extends SessionCommand
|
private final case class NotifyClient(message: MessagePosted) extends SessionCommand
|
||||||
//#chatroom-protocol
|
//#chatroom-protocol
|
||||||
|
|
@ -84,7 +84,7 @@ object OOIntroSpec {
|
||||||
client: ActorRef[SessionEvent])
|
client: ActorRef[SessionEvent])
|
||||||
extends AbstractBehavior[SessionCommand](context) {
|
extends AbstractBehavior[SessionCommand](context) {
|
||||||
|
|
||||||
override def onMessage(msg: SessionCommand): Behavior[SessionCommand] = {
|
override def onMessage(msg: SessionCommand): Behavior[SessionCommand] =
|
||||||
msg match {
|
msg match {
|
||||||
case PostMessage(message) =>
|
case PostMessage(message) =>
|
||||||
// from client, publish to others via the room
|
// from client, publish to others via the room
|
||||||
|
|
@ -95,7 +95,6 @@ object OOIntroSpec {
|
||||||
client ! message
|
client ! message
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//#chatroom-protocol
|
//#chatroom-protocol
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,7 +471,8 @@ object StyleGuideDocExamples {
|
||||||
private def counterWithGuard(remaining: Int): Behavior[Command] = {
|
private def counterWithGuard(remaining: Int): Behavior[Command] = {
|
||||||
//#pattern-match-guard
|
//#pattern-match-guard
|
||||||
// no exhaustiveness check because of guard condition
|
// no exhaustiveness check because of guard condition
|
||||||
Behaviors.receiveMessage {
|
// FIXME not true anymore since Scala 2.13.5
|
||||||
|
Behaviors.receiveMessagePartial {
|
||||||
case Down if remaining == 1 =>
|
case Down if remaining == 1 =>
|
||||||
notifyWhenZero.tell(Done)
|
notifyWhenZero.tell(Done)
|
||||||
zero
|
zero
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ object TailChopping {
|
||||||
|
|
||||||
def waiting(requestCount: Int): Behavior[Command] = {
|
def waiting(requestCount: Int): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessage {
|
||||||
case WrappedReply(reply: Reply) =>
|
case WrappedReply(reply) =>
|
||||||
replyTo ! reply
|
replyTo ! reply.asInstanceOf[Reply]
|
||||||
Behaviors.stopped
|
Behaviors.stopped
|
||||||
|
|
||||||
case RequestTimeout =>
|
case RequestTimeout =>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Java API with classtag so have likely not been used from Java
|
||||||
|
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.actor.typed.delivery.WorkPullingProducerController.apply")
|
||||||
|
|
@ -237,7 +237,7 @@ object WorkPullingProducerController {
|
||||||
/**
|
/**
|
||||||
* Java API
|
* Java API
|
||||||
*/
|
*/
|
||||||
def apply[A: ClassTag](
|
def apply[A](
|
||||||
messageClass: Class[A],
|
messageClass: Class[A],
|
||||||
producerId: String,
|
producerId: String,
|
||||||
workerServiceKey: ServiceKey[ConsumerController.Command[A]],
|
workerServiceKey: ServiceKey[ConsumerController.Command[A]],
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ object ProducerControllerImpl {
|
||||||
.narrow
|
.narrow
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
||||||
settings: ProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
settings: ProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
||||||
|
|
@ -206,7 +206,7 @@ object ProducerControllerImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
||||||
settings: ProducerController.Settings,
|
settings: ProducerController.Settings,
|
||||||
|
|
@ -222,11 +222,11 @@ object ProducerControllerImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def createInitialState[A: ClassTag](hasDurableQueue: Boolean) = {
|
private def createInitialState[A](hasDurableQueue: Boolean) = {
|
||||||
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
||||||
}
|
}
|
||||||
|
|
||||||
private def createState[A: ClassTag](
|
private def createState[A](
|
||||||
self: ActorRef[InternalCommand],
|
self: ActorRef[InternalCommand],
|
||||||
producerId: String,
|
producerId: String,
|
||||||
send: SequencedMessage[A] => Unit,
|
send: SequencedMessage[A] => Unit,
|
||||||
|
|
@ -825,6 +825,9 @@ private class ProducerControllerImpl[A: ClassTag](
|
||||||
|
|
||||||
case DurableQueueTerminated =>
|
case DurableQueueTerminated =>
|
||||||
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
||||||
|
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected message: $unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ import akka.util.Timeout
|
||||||
.narrow
|
.narrow
|
||||||
}
|
}
|
||||||
|
|
||||||
private def createInitialState[A: ClassTag](hasDurableQueue: Boolean) = {
|
private def createInitialState[A](hasDurableQueue: Boolean) = {
|
||||||
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +158,7 @@ import akka.util.Timeout
|
||||||
s.unconfirmed.foreach {
|
s.unconfirmed.foreach {
|
||||||
case DurableProducerQueue.MessageSent(oldSeqNr, msg, _, oldConfirmationQualifier, _) =>
|
case DurableProducerQueue.MessageSent(oldSeqNr, msg, _, oldConfirmationQualifier, _) =>
|
||||||
context.self ! ResendDurableMsg(msg, oldConfirmationQualifier, oldSeqNr)
|
context.self ! ResendDurableMsg(msg, oldConfirmationQualifier, oldSeqNr)
|
||||||
|
case _ => // please compiler exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
val msgAdapter: ActorRef[A] = context.messageAdapter(msg => Msg(msg, wasStashed = false, replyTo = None))
|
val msgAdapter: ActorRef[A] = context.messageAdapter(msg => Msg(msg, wasStashed = false, replyTo = None))
|
||||||
|
|
@ -220,12 +221,12 @@ import akka.util.Timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def checkStashFull[A: ClassTag](stashBuffer: StashBuffer[InternalCommand]): Unit = {
|
private def checkStashFull[A](stashBuffer: StashBuffer[InternalCommand]): Unit = {
|
||||||
if (stashBuffer.isFull)
|
if (stashBuffer.isFull)
|
||||||
throw new IllegalArgumentException(s"Buffer is full, size [${stashBuffer.size}].")
|
throw new IllegalArgumentException(s"Buffer is full, size [${stashBuffer.size}].")
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
||||||
settings: WorkPullingProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
settings: WorkPullingProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
||||||
|
|
@ -238,7 +239,7 @@ import akka.util.Timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
||||||
settings: WorkPullingProducerController.Settings,
|
settings: WorkPullingProducerController.Settings,
|
||||||
|
|
@ -658,6 +659,8 @@ private class WorkPullingProducerControllerImpl[A: ClassTag](
|
||||||
case DurableQueueTerminated =>
|
case DurableQueueTerminated =>
|
||||||
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
||||||
|
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected message: $unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ import scala.util.Success
|
||||||
// context-shared timer needed to allow for nested timer usage
|
// context-shared timer needed to allow for nested timer usage
|
||||||
def timer: TimerSchedulerCrossDslSupport[T] = _timer match {
|
def timer: TimerSchedulerCrossDslSupport[T] = _timer match {
|
||||||
case OptionVal.Some(timer) => timer
|
case OptionVal.Some(timer) => timer
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
checkCurrentActorThread()
|
checkCurrentActorThread()
|
||||||
val timer = mkTimer()
|
val timer = mkTimer()
|
||||||
_timer = OptionVal.Some(timer)
|
_timer = OptionVal.Some(timer)
|
||||||
|
|
@ -152,7 +152,7 @@ import scala.util.Success
|
||||||
// lazy init of logging setup
|
// lazy init of logging setup
|
||||||
_logging match {
|
_logging match {
|
||||||
case OptionVal.Some(l) => l
|
case OptionVal.Some(l) => l
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
val logClass = LoggerClass.detectLoggerClassFromStack(classOf[Behavior[_]])
|
val logClass = LoggerClass.detectLoggerClassFromStack(classOf[Behavior[_]])
|
||||||
val logger = LoggerFactory.getLogger(logClass.getName)
|
val logger = LoggerFactory.getLogger(logClass.getName)
|
||||||
val l = LoggingContext(logger, classicActorContext.props.deploy.tags, this)
|
val l = LoggingContext(logger, classicActorContext.props.deploy.tags, this)
|
||||||
|
|
@ -216,6 +216,7 @@ import scala.util.Success
|
||||||
case Success(StatusReply.Success(t: Res)) => mapResponse(Success(t))
|
case Success(StatusReply.Success(t: Res)) => mapResponse(Success(t))
|
||||||
case Success(StatusReply.Error(why)) => mapResponse(Failure(why))
|
case Success(StatusReply.Error(why)) => mapResponse(Failure(why))
|
||||||
case fail: Failure[_] => mapResponse(fail.asInstanceOf[Failure[Res]])
|
case fail: Failure[_] => mapResponse(fail.asInstanceOf[Failure[Res]])
|
||||||
|
case _ => throw new RuntimeException() // won't happen, compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
|
|
||||||
// Java API impl
|
// Java API impl
|
||||||
|
|
@ -247,6 +248,7 @@ import scala.util.Success
|
||||||
case StatusReply.Success(value: Res) => applyToResponse(value, null)
|
case StatusReply.Success(value: Res) => applyToResponse(value, null)
|
||||||
case StatusReply.Error(why) => applyToResponse(null.asInstanceOf[Res], why)
|
case StatusReply.Error(why) => applyToResponse(null.asInstanceOf[Res], why)
|
||||||
case null => applyToResponse(null.asInstanceOf[Res], failure)
|
case null => applyToResponse(null.asInstanceOf[Res], failure)
|
||||||
|
case _ => throw new RuntimeException() // won't happen, compiler exhaustiveness check pleaser
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -295,7 +297,7 @@ import scala.util.Success
|
||||||
_messageAdapters.filterNot { case (cls, _) => cls == boxedMessageClass }
|
_messageAdapters.filterNot { case (cls, _) => cls == boxedMessageClass }
|
||||||
val ref = messageAdapterRef match {
|
val ref = messageAdapterRef match {
|
||||||
case OptionVal.Some(ref) => ref.asInstanceOf[ActorRef[U]]
|
case OptionVal.Some(ref) => ref.asInstanceOf[ActorRef[U]]
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
// AdaptMessage is not really a T, but that is erased
|
// AdaptMessage is not really a T, but that is erased
|
||||||
val ref =
|
val ref =
|
||||||
internalSpawnMessageAdapter[Any](msg => AdaptWithRegisteredMessageAdapter(msg).asInstanceOf[T], "adapter")
|
internalSpawnMessageAdapter[Any](msg => AdaptWithRegisteredMessageAdapter(msg).asInstanceOf[T], "adapter")
|
||||||
|
|
@ -315,12 +317,12 @@ import scala.util.Success
|
||||||
*/
|
*/
|
||||||
@InternalApi private[akka] def setCurrentActorThread(): Unit = {
|
@InternalApi private[akka] def setCurrentActorThread(): Unit = {
|
||||||
_currentActorThread match {
|
_currentActorThread match {
|
||||||
case OptionVal.None =>
|
|
||||||
_currentActorThread = OptionVal.Some(Thread.currentThread())
|
|
||||||
case OptionVal.Some(t) =>
|
case OptionVal.Some(t) =>
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
s"Invalid access by thread from the outside of $self. " +
|
s"Invalid access by thread from the outside of $self. " +
|
||||||
s"Current message is processed by $t, but also accessed from ${Thread.currentThread()}.")
|
s"Current message is processed by $t, but also accessed from ${Thread.currentThread()}.")
|
||||||
|
case _ =>
|
||||||
|
_currentActorThread = OptionVal.Some(Thread.currentThread())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,7 +345,7 @@ import scala.util.Success
|
||||||
s"Unsupported access to ActorContext operation from the outside of $self. " +
|
s"Unsupported access to ActorContext operation from the outside of $self. " +
|
||||||
s"Current message is processed by $t, but ActorContext was called from $callerThread.")
|
s"Current message is processed by $t, but ActorContext was called from $callerThread.")
|
||||||
}
|
}
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
s"Unsupported access to ActorContext from the outside of $self. " +
|
s"Unsupported access to ActorContext from the outside of $self. " +
|
||||||
s"No message is currently processed by the actor, but ActorContext was called from $callerThread.")
|
s"No message is currently processed by the actor, but ActorContext was called from $callerThread.")
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ private[akka] object BehaviorTags {
|
||||||
def onPostStop(ctx: TypedActorContext[T]): Unit = {
|
def onPostStop(ctx: TypedActorContext[T]): Unit = {
|
||||||
postStop match {
|
postStop match {
|
||||||
case OptionVal.Some(callback) => callback(ctx)
|
case OptionVal.Some(callback) => callback(ctx)
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,9 @@ private[akka] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] wit
|
||||||
}
|
}
|
||||||
.getOrElse(ext.createExtension(self))
|
.getOrElse(ext.createExtension(self))
|
||||||
instance match {
|
instance match {
|
||||||
case null => throw new IllegalStateException(s"Extension instance created as 'null' for extension [$ext]")
|
case null => throw new IllegalStateException(s"Extension instance created as 'null' for extension [$ext]")
|
||||||
case instance: T @unchecked =>
|
case nonNull =>
|
||||||
|
val instance = nonNull.asInstanceOf[T]
|
||||||
// Replace our in process signal with the initialized extension
|
// Replace our in process signal with the initialized extension
|
||||||
extensions.replace(ext, inProcessOfRegistration, instance)
|
extensions.replace(ext, inProcessOfRegistration, instance)
|
||||||
instance
|
instance
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,8 @@ import java.util.function.Predicate
|
||||||
throw new IllegalArgumentException("Cannot unstash with unhandled as starting behavior")
|
throw new IllegalArgumentException("Cannot unstash with unhandled as starting behavior")
|
||||||
else if (started == BehaviorImpl.same) {
|
else if (started == BehaviorImpl.same) {
|
||||||
currentBehaviorWhenUnstashInProgress match {
|
currentBehaviorWhenUnstashInProgress match {
|
||||||
case OptionVal.None => ctx.asScala.currentBehavior
|
|
||||||
case OptionVal.Some(c) => c
|
case OptionVal.Some(c) => c
|
||||||
|
case _ => ctx.asScala.currentBehavior
|
||||||
}
|
}
|
||||||
} else started
|
} else started
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,14 +193,12 @@ private class RestartSupervisor[T, Thr <: Throwable: ClassTag](initial: Behavior
|
||||||
private var deadline: OptionVal[Deadline] = OptionVal.None
|
private var deadline: OptionVal[Deadline] = OptionVal.None
|
||||||
|
|
||||||
private def deadlineHasTimeLeft: Boolean = deadline match {
|
private def deadlineHasTimeLeft: Boolean = deadline match {
|
||||||
case OptionVal.None => true
|
|
||||||
case OptionVal.Some(d) => d.hasTimeLeft()
|
case OptionVal.Some(d) => d.hasTimeLeft()
|
||||||
|
case _ => true
|
||||||
}
|
}
|
||||||
|
|
||||||
override def aroundSignal(ctx: TypedActorContext[Any], signal: Signal, target: SignalTarget[T]): Behavior[T] = {
|
override def aroundSignal(ctx: TypedActorContext[Any], signal: Signal, target: SignalTarget[T]): Behavior[T] = {
|
||||||
restartingInProgress match {
|
restartingInProgress match {
|
||||||
case OptionVal.None =>
|
|
||||||
super.aroundSignal(ctx, signal, target)
|
|
||||||
case OptionVal.Some((stashBuffer, children)) =>
|
case OptionVal.Some((stashBuffer, children)) =>
|
||||||
signal match {
|
signal match {
|
||||||
case Terminated(ref) if strategy.stopChildren && children(ref) =>
|
case Terminated(ref) if strategy.stopChildren && children(ref) =>
|
||||||
|
|
@ -219,6 +217,8 @@ private class RestartSupervisor[T, Thr <: Throwable: ClassTag](initial: Behavior
|
||||||
stashBuffer.stash(signal)
|
stashBuffer.stash(signal)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
}
|
}
|
||||||
|
case _ =>
|
||||||
|
super.aroundSignal(ctx, signal, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ private class RestartSupervisor[T, Thr <: Throwable: ClassTag](initial: Behavior
|
||||||
} else
|
} else
|
||||||
restartCompleted(ctx)
|
restartCompleted(ctx)
|
||||||
|
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
throw new IllegalStateException("Unexpected ScheduledRestart when restart not in progress")
|
throw new IllegalStateException("Unexpected ScheduledRestart when restart not in progress")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -254,18 +254,19 @@ private class RestartSupervisor[T, Thr <: Throwable: ClassTag](initial: Behavior
|
||||||
target(ctx, msg.asInstanceOf[T])
|
target(ctx, msg.asInstanceOf[T])
|
||||||
}
|
}
|
||||||
|
|
||||||
case m: T @unchecked =>
|
case msg =>
|
||||||
|
val m = msg.asInstanceOf[T]
|
||||||
restartingInProgress match {
|
restartingInProgress match {
|
||||||
case OptionVal.None =>
|
|
||||||
try {
|
|
||||||
target(ctx, m)
|
|
||||||
} catch handleReceiveException(ctx, target)
|
|
||||||
case OptionVal.Some((stashBuffer, _)) =>
|
case OptionVal.Some((stashBuffer, _)) =>
|
||||||
if (stashBuffer.isFull)
|
if (stashBuffer.isFull)
|
||||||
dropped(ctx, m)
|
dropped(ctx, m)
|
||||||
else
|
else
|
||||||
stashBuffer.stash(m)
|
stashBuffer.stash(m)
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
case _ =>
|
||||||
|
try {
|
||||||
|
target(ctx, m)
|
||||||
|
} catch handleReceiveException(ctx, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -371,10 +372,10 @@ private class RestartSupervisor[T, Thr <: Throwable: ClassTag](initial: Behavior
|
||||||
try {
|
try {
|
||||||
val newBehavior = Behavior.validateAsInitial(Behavior.start(initial, ctx.asInstanceOf[TypedActorContext[T]]))
|
val newBehavior = Behavior.validateAsInitial(Behavior.start(initial, ctx.asInstanceOf[TypedActorContext[T]]))
|
||||||
val nextBehavior = restartingInProgress match {
|
val nextBehavior = restartingInProgress match {
|
||||||
case OptionVal.None => newBehavior
|
|
||||||
case OptionVal.Some((stashBuffer, _)) =>
|
case OptionVal.Some((stashBuffer, _)) =>
|
||||||
restartingInProgress = OptionVal.None
|
restartingInProgress = OptionVal.None
|
||||||
stashBuffer.unstashAll(newBehavior.unsafeCast)
|
stashBuffer.unstashAll(newBehavior.unsafeCast)
|
||||||
|
case _ => newBehavior
|
||||||
}
|
}
|
||||||
nextBehavior.narrow
|
nextBehavior.narrow
|
||||||
} catch handleException(ctx, signalRestart = {
|
} catch handleException(ctx, signalRestart = {
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,9 @@ import akka.util.OptionVal
|
||||||
adaptAndHandle(msg)
|
adaptAndHandle(msg)
|
||||||
case signal: Signal =>
|
case signal: Signal =>
|
||||||
handleSignal(signal)
|
handleSignal(signal)
|
||||||
case msg: T @unchecked =>
|
case msg =>
|
||||||
handleMessage(msg)
|
val t = msg.asInstanceOf[T]
|
||||||
|
handleMessage(t)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
ctx.clearCurrentActorThread()
|
ctx.clearCurrentActorThread()
|
||||||
|
|
@ -119,9 +120,9 @@ import akka.util.OptionVal
|
||||||
case timerMsg: TimerMsg =>
|
case timerMsg: TimerMsg =>
|
||||||
//we can only get this kind of message if the timer is of this concrete class
|
//we can only get this kind of message if the timer is of this concrete class
|
||||||
c.timer.asInstanceOf[TimerSchedulerImpl[T]].interceptTimerMsg(ctx.log, timerMsg) match {
|
c.timer.asInstanceOf[TimerSchedulerImpl[T]].interceptTimerMsg(ctx.log, timerMsg) match {
|
||||||
case OptionVal.None => // means TimerMsg not applicable, discard
|
|
||||||
case OptionVal.Some(m) =>
|
case OptionVal.Some(m) =>
|
||||||
next(Behavior.interpretMessage(behavior, c, m), m)
|
next(Behavior.interpretMessage(behavior, c, m), m)
|
||||||
|
case _ => // means TimerMsg not applicable, discard
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
next(Behavior.interpretMessage(behavior, c, msg), msg)
|
next(Behavior.interpretMessage(behavior, c, msg), msg)
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ import akka.annotation.InternalApi
|
||||||
case DispatcherDefault(_) => system.dispatcher
|
case DispatcherDefault(_) => system.dispatcher
|
||||||
case DispatcherFromConfig(str, _) => system.dispatchers.lookup(str)
|
case DispatcherFromConfig(str, _) => system.dispatchers.lookup(str)
|
||||||
case DispatcherSameAsParent(_) => system.dispatcher
|
case DispatcherSameAsParent(_) => system.dispatcher
|
||||||
|
case unknown => throw new RuntimeException(s"Unsupported dispatcher selector: $unknown")
|
||||||
}
|
}
|
||||||
override def shutdown(): Unit = () // there was no shutdown in classic Akka
|
override def shutdown(): Unit = () // there was no shutdown in classic Akka
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import akka.dispatch.Mailboxes
|
||||||
case _: DispatcherDefault => classicProps
|
case _: DispatcherDefault => classicProps
|
||||||
case DispatcherFromConfig(name, _) => classicProps.withDispatcher(name)
|
case DispatcherFromConfig(name, _) => classicProps.withDispatcher(name)
|
||||||
case _: DispatcherSameAsParent => classicProps.withDispatcher(Deploy.DispatcherSameAsParent)
|
case _: DispatcherSameAsParent => classicProps.withDispatcher(Deploy.DispatcherSameAsParent)
|
||||||
|
case unknown => throw new RuntimeException(s"Unsupported dispatcher selector: $unknown")
|
||||||
}).withDeploy(Deploy.local) // disallow remote deployment for typed actors
|
}).withDeploy(Deploy.local) // disallow remote deployment for typed actors
|
||||||
|
|
||||||
val mailboxProps = props.firstOrElse[MailboxSelector](MailboxSelector.default()) match {
|
val mailboxProps = props.firstOrElse[MailboxSelector](MailboxSelector.default()) match {
|
||||||
|
|
@ -34,6 +35,7 @@ import akka.dispatch.Mailboxes
|
||||||
dispatcherProps.withMailbox(s"${Mailboxes.BoundedCapacityPrefix}$capacity")
|
dispatcherProps.withMailbox(s"${Mailboxes.BoundedCapacityPrefix}$capacity")
|
||||||
case MailboxFromConfigSelector(path, _) =>
|
case MailboxFromConfigSelector(path, _) =>
|
||||||
dispatcherProps.withMailbox(path)
|
dispatcherProps.withMailbox(path)
|
||||||
|
case unknown => throw new RuntimeException(s"Unsupported mailbox selector: $unknown")
|
||||||
}
|
}
|
||||||
|
|
||||||
val localDeploy = mailboxProps.withDeploy(Deploy.local) // disallow remote deployment for typed actors
|
val localDeploy = mailboxProps.withDeploy(Deploy.local) // disallow remote deployment for typed actors
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ private[akka] final class TopicImpl[T](topicName: String, context: ActorContext[
|
||||||
private val receptionist = context.system.receptionist
|
private val receptionist = context.system.receptionist
|
||||||
private val receptionistAdapter = context.messageAdapter[Receptionist.Listing] {
|
private val receptionistAdapter = context.messageAdapter[Receptionist.Listing] {
|
||||||
case topicServiceKey.Listing(topics) => TopicInstancesUpdated(topics)
|
case topicServiceKey.Listing(topics) => TopicInstancesUpdated(topics)
|
||||||
|
case _ => throw new IllegalArgumentException() // FIXME exhaustiveness check fails on receptionist listing match
|
||||||
}
|
}
|
||||||
receptionist ! Receptionist.Subscribe(topicServiceKey, receptionistAdapter)
|
receptionist ! Receptionist.Subscribe(topicServiceKey, receptionistAdapter)
|
||||||
|
|
||||||
|
|
@ -139,5 +140,9 @@ private[akka] final class TopicImpl[T](topicName: String, context: ActorContext[
|
||||||
case GetTopicStats(replyTo) =>
|
case GetTopicStats(replyTo) =>
|
||||||
replyTo ! TopicStats(localSubscribers.size, topicInstances.size)
|
replyTo ! TopicStats(localSubscribers.size, topicInstances.size)
|
||||||
this
|
this
|
||||||
|
|
||||||
|
case other =>
|
||||||
|
// can't do exhaustiveness check correctly because of protocol internal/public design
|
||||||
|
throw new IllegalArgumentException(s"Unexpected command type ${other.getClass}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,10 @@ private[akka] object LocalReceptionist extends ReceptionistBehaviorProvider {
|
||||||
replyWithListing(key, subscriber)
|
replyWithListing(key, subscriber)
|
||||||
|
|
||||||
behavior(state.subscriberAdded(key)(subscriber))
|
behavior(state.subscriberAdded(key)(subscriber))
|
||||||
|
|
||||||
|
case other =>
|
||||||
|
// compiler does not know about our division into public and internal commands
|
||||||
|
throw new IllegalArgumentException(s"Unexpected command type ${other.getClass}")
|
||||||
}
|
}
|
||||||
|
|
||||||
def onInternal(ctx: ActorContext[Any], cmd: InternalCommand): Behavior[Any] = cmd match {
|
def onInternal(ctx: ActorContext[Any], cmd: InternalCommand): Behavior[Any] = cmd match {
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,11 @@ abstract class AbstractBehavior[T](context: ActorContext[T]) extends ExtensibleB
|
||||||
|
|
||||||
private var _receive: OptionVal[Receive[T]] = OptionVal.None
|
private var _receive: OptionVal[Receive[T]] = OptionVal.None
|
||||||
private def receive: Receive[T] = _receive match {
|
private def receive: Receive[T] = _receive match {
|
||||||
case OptionVal.None =>
|
case OptionVal.Some(r) => r
|
||||||
|
case _ =>
|
||||||
val receive = createReceive
|
val receive = createReceive
|
||||||
_receive = OptionVal.Some(receive)
|
_receive = OptionVal.Some(receive)
|
||||||
receive
|
receive
|
||||||
case OptionVal.Some(r) => r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def getContext: ActorContext[T] = context
|
protected def getContext: ActorContext[T] = context
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ final class BehaviorBuilder[T] private (messageHandlers: List[Case[T, T]], signa
|
||||||
def onMessageEquals(msg: T, handler: Creator[Behavior[T]]): BehaviorBuilder[T] =
|
def onMessageEquals(msg: T, handler: Creator[Behavior[T]]): BehaviorBuilder[T] =
|
||||||
withMessage[T](
|
withMessage[T](
|
||||||
OptionVal.Some(msg.getClass.asInstanceOf[Class[T]]),
|
OptionVal.Some(msg.getClass.asInstanceOf[Class[T]]),
|
||||||
OptionVal.Some(_.equals(msg)),
|
OptionVal.Some(_ == msg),
|
||||||
(_: T) => handler.create())
|
(_: T) => handler.create())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@
|
||||||
package akka.util
|
package akka.util
|
||||||
|
|
||||||
import java.nio.{ ByteBuffer, ByteOrder }
|
import java.nio.{ ByteBuffer, ByteOrder }
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.BufferedIterator
|
import scala.collection.BufferedIterator
|
||||||
import scala.collection.LinearSeq
|
import scala.collection.LinearSeq
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
import scala.reflect.ClassTag
|
import scala.reflect.ClassTag
|
||||||
|
|
||||||
import akka.util.Collections.EmptyImmutableSeq
|
import akka.util.Collections.EmptyImmutableSeq
|
||||||
|
|
||||||
|
import scala.annotation.nowarn
|
||||||
|
|
||||||
object ByteIterator {
|
object ByteIterator {
|
||||||
object ByteArrayIterator {
|
object ByteArrayIterator {
|
||||||
|
|
||||||
|
|
@ -48,24 +48,25 @@ object ByteIterator {
|
||||||
final override def size: Int = { val l = len; clear(); l }
|
final override def size: Int = { val l = len; clear(); l }
|
||||||
|
|
||||||
final override def ++(that: IterableOnce[Byte]): ByteIterator = that match {
|
final override def ++(that: IterableOnce[Byte]): ByteIterator = that match {
|
||||||
case that: ByteIterator =>
|
case byteIterator: ByteIterator =>
|
||||||
if (that.isEmpty) this
|
if (byteIterator.isEmpty) this
|
||||||
else if (this.isEmpty) that
|
else if (this.isEmpty) byteIterator
|
||||||
else
|
else
|
||||||
that match {
|
byteIterator match {
|
||||||
case that: ByteArrayIterator =>
|
case bai: ByteArrayIterator =>
|
||||||
if ((this.array eq that.array) && (this.until == that.from)) {
|
if ((this.array eq bai.array) && (this.until == bai.from)) {
|
||||||
this.until = that.until
|
this.until = bai.until
|
||||||
that.clear()
|
bai.clear()
|
||||||
this
|
this
|
||||||
} else {
|
} else {
|
||||||
val result = MultiByteArrayIterator(List(this, that))
|
val result = MultiByteArrayIterator(List(this, bai))
|
||||||
this.clear()
|
this.clear()
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
case that: MultiByteArrayIterator => this ++: that
|
case mbai: MultiByteArrayIterator => this ++: mbai
|
||||||
|
case bi => super.++(bi)
|
||||||
}
|
}
|
||||||
case _ => super.++(that)
|
case io => super.++(io)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override def clone: ByteArrayIterator = new ByteArrayIterator(array, from, until)
|
final override def clone: ByteArrayIterator = new ByteArrayIterator(array, from, until)
|
||||||
|
|
@ -99,9 +100,11 @@ object ByteIterator {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@nowarn("msg=deprecated")
|
||||||
override def copyToArray[B >: Byte](xs: Array[B], start: Int): Int =
|
override def copyToArray[B >: Byte](xs: Array[B], start: Int): Int =
|
||||||
this.copyToArray(xs, start, xs.length)
|
this.copyToArray(xs, start, xs.length)
|
||||||
|
|
||||||
|
@nowarn("msg=deprecated")
|
||||||
override def copyToArray[B >: Byte](xs: Array[B]): Int =
|
override def copyToArray[B >: Byte](xs: Array[B]): Int =
|
||||||
this.copyToArray(xs, 0, xs.length)
|
this.copyToArray(xs, 0, xs.length)
|
||||||
|
|
||||||
|
|
@ -234,22 +237,23 @@ object ByteIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final override def ++(that: IterableOnce[Byte]): ByteIterator = that match {
|
final override def ++(that: IterableOnce[Byte]): ByteIterator = that match {
|
||||||
case that: ByteIterator =>
|
case bi: ByteIterator =>
|
||||||
if (that.isEmpty) this
|
if (bi.isEmpty) this
|
||||||
else if (this.isEmpty) that
|
else if (this.isEmpty) bi
|
||||||
else {
|
else {
|
||||||
that match {
|
bi match {
|
||||||
case that: ByteArrayIterator =>
|
case bai: ByteArrayIterator =>
|
||||||
iterators = this.iterators :+ that
|
iterators = this.iterators :+ bai
|
||||||
that.clear()
|
bai.clear()
|
||||||
this
|
this
|
||||||
case that: MultiByteArrayIterator =>
|
case mbai: MultiByteArrayIterator =>
|
||||||
iterators = this.iterators ++ that.iterators
|
iterators = this.iterators ++ mbai.iterators
|
||||||
that.clear()
|
mbai.clear()
|
||||||
this
|
this
|
||||||
|
case bi => super.++(bi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case _ => super.++(that)
|
case io => super.++(io)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override def clone: MultiByteArrayIterator = {
|
final override def clone: MultiByteArrayIterator = {
|
||||||
|
|
|
||||||
|
|
@ -833,6 +833,7 @@ sealed abstract class ByteString
|
||||||
array
|
array
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@nowarn("msg=deprecated")
|
||||||
final override def copyToArray[B >: Byte](xs: Array[B], start: Int): Int = {
|
final override def copyToArray[B >: Byte](xs: Array[B], start: Int): Int = {
|
||||||
// super uses byteiterator
|
// super uses byteiterator
|
||||||
copyToArray(xs, start, size.min(xs.size))
|
copyToArray(xs, start, size.min(xs.size))
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@ private[akka] trait AbstractProps {
|
||||||
case c: Class[_] if c == coc =>
|
case c: Class[_] if c == coc =>
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"erased Creator types (e.g. lambdas) are unsupported, use Props.create(actorClass, creator) instead")
|
"erased Creator types (e.g. lambdas) are unsupported, use Props.create(actorClass, creator) instead")
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"unexpected type: $unexpected")
|
||||||
}
|
}
|
||||||
create(classOf[CreatorConsumer], actorClass, creator)
|
create(classOf[CreatorConsumer], actorClass, creator)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -565,6 +565,8 @@ private[akka] class ActorCell(
|
||||||
case PoisonPill => self.stop()
|
case PoisonPill => self.stop()
|
||||||
case sel: ActorSelectionMessage => receiveSelection(sel)
|
case sel: ActorSelectionMessage => receiveSelection(sel)
|
||||||
case Identify(messageId) => sender() ! ActorIdentity(messageId, Some(self))
|
case Identify(messageId) => sender() ! ActorIdentity(messageId, Some(self))
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected message for autoreceive: $unexpected") // for exhaustiveness check, will not happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,6 +241,8 @@ private[akka] trait RepointableRef extends ActorRefScope {
|
||||||
case i: InternalActorRef =>
|
case i: InternalActorRef =>
|
||||||
(i.isLocal && i.isInstanceOf[PromiseActorRef]) ||
|
(i.isLocal && i.isInstanceOf[PromiseActorRef]) ||
|
||||||
(!i.isLocal && i.path.elements.head == "temp")
|
(!i.isLocal && i.path.elements.head == "temp")
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"ActorRef is not internal: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -924,8 +926,9 @@ private[akka] class VirtualPathContainer(
|
||||||
|
|
||||||
(oldWatching, wBy)
|
(oldWatching, wBy)
|
||||||
|
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
(ActorCell.emptyActorRefSet, ActorCell.emptyActorRefSet)
|
(ActorCell.emptyActorRefSet, ActorCell.emptyActorRefSet)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -949,14 +952,14 @@ private[akka] class VirtualPathContainer(
|
||||||
val toNotify = this.synchronized {
|
val toNotify = this.synchronized {
|
||||||
// cleanup watchedBy since we know they are dead
|
// cleanup watchedBy since we know they are dead
|
||||||
_watchedBy match {
|
_watchedBy match {
|
||||||
case OptionVal.None =>
|
|
||||||
// terminated
|
|
||||||
ActorCell.emptyActorRefSet
|
|
||||||
case OptionVal.Some(watchedBy) =>
|
case OptionVal.Some(watchedBy) =>
|
||||||
maintainAddressTerminatedSubscription(OptionVal.None) {
|
maintainAddressTerminatedSubscription(OptionVal.None) {
|
||||||
_watchedBy = OptionVal.Some(watchedBy.filterNot(_.path.address == address))
|
_watchedBy = OptionVal.Some(watchedBy.filterNot(_.path.address == address))
|
||||||
}
|
}
|
||||||
watching
|
watching
|
||||||
|
case _ =>
|
||||||
|
// terminated
|
||||||
|
ActorCell.emptyActorRefSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -978,8 +981,6 @@ private[akka] class VirtualPathContainer(
|
||||||
private def addWatcher(watchee: ActorRef, watcher: ActorRef): Unit = {
|
private def addWatcher(watchee: ActorRef, watcher: ActorRef): Unit = {
|
||||||
val selfTerminated = this.synchronized {
|
val selfTerminated = this.synchronized {
|
||||||
_watchedBy match {
|
_watchedBy match {
|
||||||
case OptionVal.None =>
|
|
||||||
true
|
|
||||||
case OptionVal.Some(watchedBy) =>
|
case OptionVal.Some(watchedBy) =>
|
||||||
val watcheeSelf = watchee == this
|
val watcheeSelf = watchee == this
|
||||||
val watcherSelf = watcher == this
|
val watcherSelf = watcher == this
|
||||||
|
|
@ -1001,6 +1002,8 @@ private[akka] class VirtualPathContainer(
|
||||||
Logging.Error(path.toString, classOf[FunctionRef], s"BUG: illegal Watch($watchee,$watcher) for $this"))
|
Logging.Error(path.toString, classOf[FunctionRef], s"BUG: illegal Watch($watchee,$watcher) for $this"))
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
case _ =>
|
||||||
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// outside of synchronized block
|
// outside of synchronized block
|
||||||
|
|
@ -1012,7 +1015,6 @@ private[akka] class VirtualPathContainer(
|
||||||
|
|
||||||
private def remWatcher(watchee: ActorRef, watcher: ActorRef): Unit = this.synchronized {
|
private def remWatcher(watchee: ActorRef, watcher: ActorRef): Unit = this.synchronized {
|
||||||
_watchedBy match {
|
_watchedBy match {
|
||||||
case OptionVal.None => // do nothing...
|
|
||||||
case OptionVal.Some(watchedBy) =>
|
case OptionVal.Some(watchedBy) =>
|
||||||
val watcheeSelf = watchee == this
|
val watcheeSelf = watchee == this
|
||||||
val watcherSelf = watcher == this
|
val watcherSelf = watcher == this
|
||||||
|
|
@ -1033,6 +1035,8 @@ private[akka] class VirtualPathContainer(
|
||||||
publish(
|
publish(
|
||||||
Logging.Error(path.toString, classOf[FunctionRef], s"BUG: illegal Unwatch($watchee,$watcher) for $this"))
|
Logging.Error(path.toString, classOf[FunctionRef], s"BUG: illegal Unwatch($watchee,$watcher) for $this"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case _ => // do nothing...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1097,7 +1101,7 @@ private[akka] class VirtualPathContainer(
|
||||||
def watchedByOrEmpty: Set[ActorRef] =
|
def watchedByOrEmpty: Set[ActorRef] =
|
||||||
_watchedBy match {
|
_watchedBy match {
|
||||||
case OptionVal.Some(watchedBy) => watchedBy
|
case OptionVal.Some(watchedBy) => watchedBy
|
||||||
case OptionVal.None => ActorCell.emptyActorRefSet
|
case _ => ActorCell.emptyActorRefSet
|
||||||
}
|
}
|
||||||
|
|
||||||
change match {
|
change match {
|
||||||
|
|
|
||||||
|
|
@ -756,7 +756,7 @@ private[akka] class LocalActorRefProvider private[akka] (
|
||||||
Serialization.Information(getDefaultAddress, system)
|
Serialization.Information(getDefaultAddress, system)
|
||||||
serializationInformationCache match {
|
serializationInformationCache match {
|
||||||
case OptionVal.Some(info) => info
|
case OptionVal.Some(info) => info
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
if (system eq null)
|
if (system eq null)
|
||||||
throw new IllegalStateException("Too early access of serializationInformation")
|
throw new IllegalStateException("Too early access of serializationInformation")
|
||||||
else {
|
else {
|
||||||
|
|
@ -773,7 +773,7 @@ private[akka] class LocalActorRefProvider private[akka] (
|
||||||
override private[akka] def addressString: String = {
|
override private[akka] def addressString: String = {
|
||||||
_addressString match {
|
_addressString match {
|
||||||
case OptionVal.Some(addr) => addr
|
case OptionVal.Some(addr) => addr
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
val addr = getDefaultAddress.toString
|
val addr = getDefaultAddress.toString
|
||||||
_addressString = OptionVal.Some(addr)
|
_addressString = OptionVal.Some(addr)
|
||||||
addr
|
addr
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ class ReflectiveDynamicAccess(val classLoader: ClassLoader) extends DynamicAcces
|
||||||
case null => throw new NullPointerException
|
case null => throw new NullPointerException
|
||||||
case x if !t.isInstance(x) => throw new ClassCastException(fqcn + " is not a subtype of " + t)
|
case x if !t.isInstance(x) => throw new ClassCastException(fqcn + " is not a subtype of " + t)
|
||||||
case x: T => x
|
case x: T => x
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected module field: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
}.recover { case i: InvocationTargetException if i.getTargetException ne null => throw i.getTargetException }
|
}.recover { case i: InvocationTargetException if i.getTargetException ne null => throw i.getTargetException }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ trait Timers extends Actor {
|
||||||
actorCell.currentMessage = actorCell.currentMessage.copy(message = m)
|
actorCell.currentMessage = actorCell.currentMessage.copy(message = m)
|
||||||
}
|
}
|
||||||
super.aroundReceive(receive, m)
|
super.aroundReceive(receive, m)
|
||||||
case OptionVal.None => // discard
|
case _ => // discard
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
super.aroundReceive(receive, msg)
|
super.aroundReceive(receive, msg)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ private[akka] trait DeathWatch { this: ActorCell =>
|
||||||
checkWatchingSame(a, None)
|
checkWatchingSame(a, None)
|
||||||
}
|
}
|
||||||
a
|
a
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"ActorRef is not internal: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
override final def watchWith(subject: ActorRef, msg: Any): ActorRef = subject match {
|
override final def watchWith(subject: ActorRef, msg: Any): ActorRef = subject match {
|
||||||
|
|
@ -46,6 +48,8 @@ private[akka] trait DeathWatch { this: ActorCell =>
|
||||||
checkWatchingSame(a, Some(msg))
|
checkWatchingSame(a, Some(msg))
|
||||||
}
|
}
|
||||||
a
|
a
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"ActorRef is not internal: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
override final def unwatch(subject: ActorRef): ActorRef = subject match {
|
override final def unwatch(subject: ActorRef): ActorRef = subject match {
|
||||||
|
|
@ -58,6 +62,8 @@ private[akka] trait DeathWatch { this: ActorCell =>
|
||||||
}
|
}
|
||||||
terminatedQueued -= a
|
terminatedQueued -= a
|
||||||
a
|
a
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"ActorRef is not internal: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def receivedTerminated(t: Terminated): Unit =
|
protected def receivedTerminated(t: Terminated): Unit =
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,8 @@ abstract class MessageDispatcher(val configurator: MessageDispatcherConfigurator
|
||||||
if (updateShutdownSchedule(SCHEDULED, RESCHEDULED)) ()
|
if (updateShutdownSchedule(SCHEDULED, RESCHEDULED)) ()
|
||||||
else ifSensibleToDoSoThenScheduleShutdown()
|
else ifSensibleToDoSoThenScheduleShutdown()
|
||||||
case RESCHEDULED =>
|
case RESCHEDULED =>
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected actor class marker: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,6 +247,8 @@ abstract class MessageDispatcher(val configurator: MessageDispatcherConfigurator
|
||||||
if (updateShutdownSchedule(RESCHEDULED, SCHEDULED)) scheduleShutdownAction()
|
if (updateShutdownSchedule(RESCHEDULED, SCHEDULED)) scheduleShutdownAction()
|
||||||
else run()
|
else run()
|
||||||
case UNSCHEDULED =>
|
case UNSCHEDULED =>
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected actor class marker: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,8 @@ private[akka] class Mailboxes(
|
||||||
case x =>
|
case x =>
|
||||||
throw new IllegalArgumentException(s"no wildcard type allowed in RequireMessageQueue argument (was [$x])")
|
throw new IllegalArgumentException(s"no wildcard type allowed in RequireMessageQueue argument (was [$x])")
|
||||||
}
|
}
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected actor class marker: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
|
|
||||||
// don’t care if this happens twice
|
// don’t care if this happens twice
|
||||||
|
|
@ -131,6 +133,8 @@ private[akka] class Mailboxes(
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
s"no wildcard type allowed in ProducesMessageQueue argument (was [$x])")
|
s"no wildcard type allowed in ProducesMessageQueue argument (was [$x])")
|
||||||
}
|
}
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected message queue type marker: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ private[io] class UdpListener(val udp: UdpExt, channelRegistry: ChannelRegistry,
|
||||||
handler ! Received(ByteString(buffer), sender)
|
handler ! Received(ByteString(buffer), sender)
|
||||||
if (readsLeft > 0) innerReceive(readsLeft - 1, buffer)
|
if (readsLeft > 0) innerReceive(readsLeft - 1, buffer)
|
||||||
case null => // null means no data was available
|
case null => // null means no data was available
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected address in buffer: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,10 +136,13 @@ object DnsSettings {
|
||||||
/**
|
/**
|
||||||
* INTERNAL API
|
* INTERNAL API
|
||||||
*/
|
*/
|
||||||
@InternalApi private[akka] def parseNameserverAddress(str: String): InetSocketAddress = {
|
@InternalApi private[akka] def parseNameserverAddress(str: String): InetSocketAddress =
|
||||||
val inetSocketAddress(host, port) = str
|
str match {
|
||||||
new InetSocketAddress(host, Option(port).fold(DnsFallbackPort)(_.toInt))
|
case inetSocketAddress(host, port) =>
|
||||||
}
|
new InetSocketAddress(host, Option(port).fold(DnsFallbackPort)(_.toInt))
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unparseable address string: $unexpected") // will not happen, for exhaustiveness check
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* INTERNAL API
|
* INTERNAL API
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ private[io] final class AsyncDnsResolver(
|
||||||
val record = address match {
|
val record = address match {
|
||||||
case _: Inet4Address => ARecord(name, Ttl.effectivelyForever, address)
|
case _: Inet4Address => ARecord(name, Ttl.effectivelyForever, address)
|
||||||
case ipv6address: Inet6Address => AAAARecord(name, Ttl.effectivelyForever, ipv6address)
|
case ipv6address: Inet6Address => AAAARecord(name, Ttl.effectivelyForever, ipv6address)
|
||||||
|
case unexpected => throw new IllegalArgumentException(s"Unexpected address: $unexpected")
|
||||||
}
|
}
|
||||||
DnsProtocol.Resolved(name, record :: Nil)
|
DnsProtocol.Resolved(name, record :: Nil)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ private[akka] object RecordTypeSerializer {
|
||||||
def parse(it: ByteIterator): RecordType = {
|
def parse(it: ByteIterator): RecordType = {
|
||||||
val id = it.getShort
|
val id = it.getShort
|
||||||
RecordType(id) match {
|
RecordType(id) match {
|
||||||
case OptionVal.None => throw new IllegalArgumentException(s"Illegal id [$id] for DnsRecordType")
|
|
||||||
case OptionVal.Some(t) => t
|
case OptionVal.Some(t) => t
|
||||||
|
case _ => throw new IllegalArgumentException(s"Illegal id [$id] for DnsRecordType")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -604,6 +604,7 @@ private[akka] final class PromiseActorRef private (
|
||||||
updateState(Stopped, StoppedWithPath(provider.tempPath()))
|
updateState(Stopped, StoppedWithPath(provider.tempPath()))
|
||||||
path
|
path
|
||||||
case Registering => path // spin until registration is completed
|
case Registering => path // spin until registration is completed
|
||||||
|
case unexpected => throw new IllegalStateException(s"Unexpected state: $unexpected")
|
||||||
}
|
}
|
||||||
|
|
||||||
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = state match {
|
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = state match {
|
||||||
|
|
@ -668,6 +669,7 @@ private[akka] final class PromiseActorRef private (
|
||||||
} else stop()
|
} else stop()
|
||||||
case Stopped | _: StoppedWithPath => // already stopped
|
case Stopped | _: StoppedWithPath => // already stopped
|
||||||
case Registering => stop() // spin until registration is completed before stopping
|
case Registering => stop() // spin until registration is completed before stopping
|
||||||
|
case unexpected => throw new IllegalStateException(s"Unexpected state: $unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,8 @@ object StatusReply {
|
||||||
s match {
|
s match {
|
||||||
case StatusReply.Success(v) => ScalaSuccess(v.asInstanceOf[T])
|
case StatusReply.Success(v) => ScalaSuccess(v.asInstanceOf[T])
|
||||||
case StatusReply.Error(ex) => ScalaFailure[T](ex)
|
case StatusReply.Error(ex) => ScalaFailure[T](ex)
|
||||||
|
case unexpected =>
|
||||||
|
ScalaFailure(new IllegalArgumentException(s"Unexpected status reply success value: ${unexpected}"))
|
||||||
}
|
}
|
||||||
case fail @ ScalaFailure(_) => fail.asInstanceOf[Try[T]]
|
case fail @ ScalaFailure(_) => fail.asInstanceOf[Try[T]]
|
||||||
}(ExecutionContexts.parasitic)
|
}(ExecutionContexts.parasitic)
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,8 @@ final case class ConsistentHashingRoutingLogic(
|
||||||
case bytes: Array[Byte] => currentConsistenHash.nodeFor(bytes).routee
|
case bytes: Array[Byte] => currentConsistenHash.nodeFor(bytes).routee
|
||||||
case str: String => currentConsistenHash.nodeFor(str).routee
|
case str: String => currentConsistenHash.nodeFor(str).routee
|
||||||
case x: AnyRef => currentConsistenHash.nodeFor(SerializationExtension(system).serialize(x).get).routee
|
case x: AnyRef => currentConsistenHash.nodeFor(SerializationExtension(system).serialize(x).get).routee
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected hashdata: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case NonFatal(e) =>
|
case NonFatal(e) =>
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,7 @@ import akka.util.ByteString
|
||||||
val flag = o match {
|
val flag = o match {
|
||||||
case TRUE => TrueB
|
case TRUE => TrueB
|
||||||
case FALSE => FalseB
|
case FALSE => FalseB
|
||||||
|
case b => throw new IllegalArgumentException(s"Non boolean flag: $b")
|
||||||
}
|
}
|
||||||
buf.put(flag)
|
buf.put(flag)
|
||||||
}
|
}
|
||||||
|
|
@ -176,6 +177,7 @@ import akka.util.ByteString
|
||||||
buf.get() match {
|
buf.get() match {
|
||||||
case TrueB => TRUE
|
case TrueB => TRUE
|
||||||
case FalseB => FALSE
|
case FalseB => FALSE
|
||||||
|
case b => throw new IllegalArgumentException(s"Non boolean flag byte: $b")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,6 +185,7 @@ import akka.util.ByteString
|
||||||
val flag = o match {
|
val flag = o match {
|
||||||
case TRUE => TrueB
|
case TRUE => TrueB
|
||||||
case FALSE => FalseB
|
case FALSE => FalseB
|
||||||
|
case b => throw new IllegalArgumentException(s"Non boolean flag: $b")
|
||||||
}
|
}
|
||||||
val result = new Array[Byte](1)
|
val result = new Array[Byte](1)
|
||||||
result(0) = flag
|
result(0) = flag
|
||||||
|
|
@ -193,6 +196,7 @@ import akka.util.ByteString
|
||||||
bytes(0) match {
|
bytes(0) match {
|
||||||
case TrueB => TRUE
|
case TrueB => TRUE
|
||||||
case FalseB => FALSE
|
case FalseB => FALSE
|
||||||
|
case b => throw new IllegalArgumentException(s"Non boolean flag byte: $b")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ object HashCode {
|
||||||
else if (!isArray(value)) result = hash(result, value.hashCode())
|
else if (!isArray(value)) result = hash(result, value.hashCode())
|
||||||
else for (id <- 0 until JArray.getLength(value)) result = hash(result, JArray.get(value, id)) // is an array
|
else for (id <- 0 until JArray.getLength(value)) result = hash(result, JArray.get(value, id)) // is an array
|
||||||
result
|
result
|
||||||
|
case unexpected =>
|
||||||
|
throw new IllegalArgumentException(s"Unexpected hash parameter: $unexpected") // will not happen, for exhaustiveness check
|
||||||
}
|
}
|
||||||
def hash(seed: Int, value: Boolean): Int = firstTerm(seed) + (if (value) 1 else 0)
|
def hash(seed: Int, value: Boolean): Int = firstTerm(seed) + (if (value) 1 else 0)
|
||||||
def hash(seed: Int, value: Char): Int = firstTerm(seed) + value.asInstanceOf[Int]
|
def hash(seed: Int, value: Char): Int = firstTerm(seed) + value.asInstanceOf[Int]
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ object TypedBenchmarkActors {
|
||||||
val startNanoTime = System.nanoTime()
|
val startNanoTime = System.nanoTime()
|
||||||
pairs.foreach(_ ! Message)
|
pairs.foreach(_ ! Message)
|
||||||
var interactionsLeft = numPairs
|
var interactionsLeft = numPairs
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case Done =>
|
case Done =>
|
||||||
interactionsLeft -= 1
|
interactionsLeft -= 1
|
||||||
if (interactionsLeft == 0) {
|
if (interactionsLeft == 0) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ object Producer {
|
||||||
val requestNextAdapter =
|
val requestNextAdapter =
|
||||||
context.messageAdapter[ProducerController.RequestNext[Consumer.Command]](WrappedRequestNext(_))
|
context.messageAdapter[ProducerController.RequestNext[Consumer.Command]](WrappedRequestNext(_))
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case WrappedRequestNext(next) =>
|
case WrappedRequestNext(next) =>
|
||||||
if (next.confirmedSeqNr >= numberOfMessages) {
|
if (next.confirmedSeqNr >= numberOfMessages) {
|
||||||
context.log.info("Completed {} messages", numberOfMessages)
|
context.log.info("Completed {} messages", numberOfMessages)
|
||||||
|
|
@ -114,7 +114,7 @@ object WorkPullingProducer {
|
||||||
var remaining = numberOfMessages + context.system.settings.config
|
var remaining = numberOfMessages + context.system.settings.config
|
||||||
.getInt("akka.reliable-delivery.consumer-controller.flow-control-window")
|
.getInt("akka.reliable-delivery.consumer-controller.flow-control-window")
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case WrappedRequestNext(next) =>
|
case WrappedRequestNext(next) =>
|
||||||
remaining -= 1
|
remaining -= 1
|
||||||
if (remaining == 0) {
|
if (remaining == 0) {
|
||||||
|
|
@ -183,6 +183,9 @@ object Guardian {
|
||||||
consumers.foreach(context.stop)
|
consumers.foreach(context.stop)
|
||||||
replyTo ! Done
|
replyTo ! Done
|
||||||
Behaviors.same
|
Behaviors.same
|
||||||
|
|
||||||
|
case msg =>
|
||||||
|
throw new RuntimeException(s"Unexpected message $msg")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -489,6 +489,7 @@ private[metrics] class WeightedRoutees(
|
||||||
val a = routee match {
|
val a = routee match {
|
||||||
case ActorRefRoutee(ref) => ref.path.address
|
case ActorRefRoutee(ref) => ref.path.address
|
||||||
case ActorSelectionRoutee(sel) => sel.anchor.path.address
|
case ActorSelectionRoutee(sel) => sel.anchor.path.address
|
||||||
|
case _ => throw new RuntimeException()
|
||||||
}
|
}
|
||||||
a match {
|
a match {
|
||||||
case Address(_, _, None, None) => selfAddress
|
case Address(_, _, None, None) => selfAddress
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ abstract class AdaptiveLoadBalancingRouterSpec
|
||||||
// it may take some time until router receives cluster member events
|
// it may take some time until router receives cluster member events
|
||||||
awaitAssert { currentRoutees(router).size should ===(roles.size) }
|
awaitAssert { currentRoutees(router).size should ===(roles.size) }
|
||||||
val routees = currentRoutees(router)
|
val routees = currentRoutees(router)
|
||||||
routees.map { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(roles.map(address).toSet)
|
routees.collect { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(roles.map(address).toSet)
|
||||||
router
|
router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ abstract class AdaptiveLoadBalancingRouterSpec
|
||||||
// it may take some time until router receives cluster member events
|
// it may take some time until router receives cluster member events
|
||||||
awaitAssert { currentRoutees(router3).size should ===(9) }
|
awaitAssert { currentRoutees(router3).size should ===(9) }
|
||||||
val routees = currentRoutees(router3)
|
val routees = currentRoutees(router3)
|
||||||
routees.map { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(Set(address(node1)))
|
routees.collect { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(Set(address(node1)))
|
||||||
}
|
}
|
||||||
enterBarrier("after-4")
|
enterBarrier("after-4")
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +246,7 @@ abstract class AdaptiveLoadBalancingRouterSpec
|
||||||
// it may take some time until router receives cluster member events
|
// it may take some time until router receives cluster member events
|
||||||
awaitAssert { currentRoutees(router4).size should ===(6) }
|
awaitAssert { currentRoutees(router4).size should ===(6) }
|
||||||
val routees = currentRoutees(router4)
|
val routees = currentRoutees(router4)
|
||||||
routees.map { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(
|
routees.collect { case ActorRefRoutee(ref) => fullAddress(ref) }.toSet should ===(
|
||||||
Set(address(node1), address(node2), address(node3)))
|
Set(address(node1), address(node2), address(node3)))
|
||||||
}
|
}
|
||||||
enterBarrier("after-5")
|
enterBarrier("after-5")
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class ClusterMetricsExtensionSpec
|
||||||
loadAverageMock.get should ===(loadAverageEwma +- epsilon)
|
loadAverageMock.get should ===(loadAverageEwma +- epsilon)
|
||||||
cpuCombinedMock.get should ===(cpuCombinedEwma +- epsilon)
|
cpuCombinedMock.get should ===(cpuCombinedEwma +- epsilon)
|
||||||
cpuStolenMock.get should ===(cpuStolenEwma +- epsilon)
|
cpuStolenMock.get should ===(cpuStolenEwma +- epsilon)
|
||||||
|
case _ => fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ import akka.util.Timeout
|
||||||
.narrow
|
.narrow
|
||||||
}
|
}
|
||||||
|
|
||||||
private def createInitialState[A: ClassTag](hasDurableQueue: Boolean) = {
|
private def createInitialState[A](hasDurableQueue: Boolean) = {
|
||||||
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
if (hasDurableQueue) None else Some(DurableProducerQueue.State.empty[A])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,12 +226,12 @@ import akka.util.Timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def checkStashFull[A: ClassTag](stashBuffer: StashBuffer[InternalCommand]): Unit = {
|
private def checkStashFull[A](stashBuffer: StashBuffer[InternalCommand]): Unit = {
|
||||||
if (stashBuffer.isFull)
|
if (stashBuffer.isFull)
|
||||||
throw new IllegalArgumentException(s"Buffer is full, size [${stashBuffer.size}].")
|
throw new IllegalArgumentException(s"Buffer is full, size [${stashBuffer.size}].")
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
durableQueueBehavior: Option[Behavior[DurableProducerQueue.Command[A]]],
|
||||||
settings: ShardingProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
settings: ShardingProducerController.Settings): Option[ActorRef[DurableProducerQueue.Command[A]]] = {
|
||||||
|
|
@ -244,7 +244,7 @@ import akka.util.Timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def askLoadState[A: ClassTag](
|
private def askLoadState[A](
|
||||||
context: ActorContext[InternalCommand],
|
context: ActorContext[InternalCommand],
|
||||||
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
durableQueue: Option[ActorRef[DurableProducerQueue.Command[A]]],
|
||||||
settings: ShardingProducerController.Settings,
|
settings: ShardingProducerController.Settings,
|
||||||
|
|
@ -565,6 +565,8 @@ private class ShardingProducerControllerImpl[A: ClassTag](
|
||||||
case DurableQueueTerminated =>
|
case DurableQueueTerminated =>
|
||||||
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
throw new IllegalStateException("DurableQueue was unexpectedly terminated.")
|
||||||
|
|
||||||
|
case unexpected =>
|
||||||
|
throw new RuntimeException(s"Unexpected message: $unexpected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ import akka.util.JavaDurationConverters._
|
||||||
message match {
|
message match {
|
||||||
case ShardingEnvelope(entityId, _) => entityId //also covers ClassicStartEntity in ShardingEnvelope
|
case ShardingEnvelope(entityId, _) => entityId //also covers ClassicStartEntity in ShardingEnvelope
|
||||||
case ClassicStartEntity(entityId) => entityId
|
case ClassicStartEntity(entityId) => entityId
|
||||||
case msg: E @unchecked => delegate.entityId(msg)
|
case msg => delegate.entityId(msg.asInstanceOf[E])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,8 +69,8 @@ import akka.util.JavaDurationConverters._
|
||||||
case msg: ClassicStartEntity =>
|
case msg: ClassicStartEntity =>
|
||||||
// not really of type M, but erased and StartEntity is only handled internally, not delivered to the entity
|
// not really of type M, but erased and StartEntity is only handled internally, not delivered to the entity
|
||||||
msg.asInstanceOf[M]
|
msg.asInstanceOf[M]
|
||||||
case msg: E @unchecked =>
|
case msg =>
|
||||||
delegate.unwrapMessage(msg)
|
delegate.unwrapMessage(msg.asInstanceOf[E])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ object ShardedDaemonProcessSpec extends MultiNodeConfig {
|
||||||
val snitchRouter = ctx.spawn(Routers.group(SnitchServiceKey), "router")
|
val snitchRouter = ctx.spawn(Routers.group(SnitchServiceKey), "router")
|
||||||
snitchRouter ! ProcessActorEvent(id, "Started")
|
snitchRouter ! ProcessActorEvent(id, "Started")
|
||||||
|
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case Stop =>
|
case Stop =>
|
||||||
snitchRouter ! ProcessActorEvent(id, "Stopped")
|
snitchRouter ! ProcessActorEvent(id, "Stopped")
|
||||||
Behaviors.stopped
|
Behaviors.stopped
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ object DeliveryThroughputSpec extends MultiNodeConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
object Consumer {
|
object Consumer {
|
||||||
trait Command
|
sealed trait Command
|
||||||
|
|
||||||
case object TheMessage extends Command with CborSerializable
|
case object TheMessage extends Command with CborSerializable
|
||||||
case object Stop extends Command
|
case object Stop extends Command
|
||||||
|
|
@ -122,7 +122,7 @@ object DeliveryThroughputSpec extends MultiNodeConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
object Producer {
|
object Producer {
|
||||||
trait Command
|
sealed trait Command
|
||||||
|
|
||||||
case object Run extends Command
|
case object Run extends Command
|
||||||
private case class WrappedRequestNext(r: ProducerController.RequestNext[Consumer.Command]) extends Command
|
private case class WrappedRequestNext(r: ProducerController.RequestNext[Consumer.Command]) extends Command
|
||||||
|
|
@ -180,7 +180,7 @@ object DeliveryThroughputSpec extends MultiNodeConfig {
|
||||||
def serviceKey(testName: String) = ServiceKey[ConsumerController.Command[Consumer.Command]](testName)
|
def serviceKey(testName: String) = ServiceKey[ConsumerController.Command[Consumer.Command]](testName)
|
||||||
|
|
||||||
object WorkPullingProducer {
|
object WorkPullingProducer {
|
||||||
trait Command
|
sealed trait Command
|
||||||
|
|
||||||
case object Run extends Command
|
case object Run extends Command
|
||||||
private case class WrappedRequestNext(r: WorkPullingProducerController.RequestNext[Consumer.Command])
|
private case class WrappedRequestNext(r: WorkPullingProducerController.RequestNext[Consumer.Command])
|
||||||
|
|
@ -225,7 +225,7 @@ object DeliveryThroughputSpec extends MultiNodeConfig {
|
||||||
def typeKey(testName: String) = EntityTypeKey[ConsumerController.SequencedMessage[Consumer.Command]](testName)
|
def typeKey(testName: String) = EntityTypeKey[ConsumerController.SequencedMessage[Consumer.Command]](testName)
|
||||||
|
|
||||||
object ShardingProducer {
|
object ShardingProducer {
|
||||||
trait Command
|
sealed trait Command
|
||||||
|
|
||||||
case object Run extends Command
|
case object Run extends Command
|
||||||
private case class WrappedRequestNext(r: ShardingProducerController.RequestNext[Consumer.Command]) extends Command
|
private case class WrappedRequestNext(r: ShardingProducerController.RequestNext[Consumer.Command]) extends Command
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ object ReplicatedShardingSpec {
|
||||||
val AllReplicas = Set(ReplicaId("DC-A"), ReplicaId("DC-B"))
|
val AllReplicas = Set(ReplicaId("DC-A"), ReplicaId("DC-B"))
|
||||||
|
|
||||||
object MyReplicatedStringSet {
|
object MyReplicatedStringSet {
|
||||||
trait Command extends CborSerializable
|
sealed trait Command extends CborSerializable
|
||||||
case class Add(text: String) extends Command
|
case class Add(text: String) extends Command
|
||||||
case class GetTexts(replyTo: ActorRef[Texts]) extends Command
|
case class GetTexts(replyTo: ActorRef[Texts]) extends Command
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ object ReplicatedShardingSpec {
|
||||||
}
|
}
|
||||||
|
|
||||||
object MyReplicatedIntSet {
|
object MyReplicatedIntSet {
|
||||||
trait Command extends CborSerializable
|
sealed trait Command extends CborSerializable
|
||||||
case class Add(text: Int) extends Command
|
case class Add(text: Int) extends Command
|
||||||
case class GetInts(replyTo: ActorRef[Ints]) extends Command
|
case class GetInts(replyTo: ActorRef[Ints]) extends Command
|
||||||
case class Ints(ints: Set[Int]) extends CborSerializable
|
case class Ints(ints: Set[Int]) extends CborSerializable
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ object ReliableDeliveryShardingSpec {
|
||||||
|
|
||||||
object TestShardingProducer {
|
object TestShardingProducer {
|
||||||
|
|
||||||
trait Command
|
sealed trait Command
|
||||||
final case class RequestNext(sendToRef: ActorRef[ShardingEnvelope[TestConsumer.Job]]) extends Command
|
final case class RequestNext(sendToRef: ActorRef[ShardingEnvelope[TestConsumer.Job]]) extends Command
|
||||||
|
|
||||||
private case object Tick extends Command
|
private case object Tick extends Command
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ object ShardedDaemonProcessSpec {
|
||||||
""")
|
""")
|
||||||
|
|
||||||
object MyActor {
|
object MyActor {
|
||||||
trait Command
|
sealed trait Command
|
||||||
case object Stop extends Command
|
case object Stop extends Command
|
||||||
|
|
||||||
case class Started(id: Int, selfRef: ActorRef[Command])
|
case class Started(id: Int, selfRef: ActorRef[Command])
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ object HelloWorldPersistentEntityExample {
|
||||||
object HelloWorld {
|
object HelloWorld {
|
||||||
|
|
||||||
// Command
|
// Command
|
||||||
trait Command extends CborSerializable
|
sealed trait Command extends CborSerializable
|
||||||
final case class Greet(whom: String)(val replyTo: ActorRef[Greeting]) extends Command
|
final case class Greet(whom: String)(val replyTo: ActorRef[Greeting]) extends Command
|
||||||
// Response
|
// Response
|
||||||
final case class Greeting(whom: String, numberOfPeople: Int) extends CborSerializable
|
final case class Greeting(whom: String, numberOfPeople: Int) extends CborSerializable
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ object WorkPullingDocExample {
|
||||||
import akka.actor.typed.scaladsl.StashBuffer
|
import akka.actor.typed.scaladsl.StashBuffer
|
||||||
|
|
||||||
object ImageWorkManager {
|
object ImageWorkManager {
|
||||||
trait Command
|
sealed trait Command
|
||||||
final case class Convert(fromFormat: String, toFormat: String, image: Array[Byte]) extends Command
|
final case class Convert(fromFormat: String, toFormat: String, image: Array[Byte]) extends Command
|
||||||
private case class WrappedRequestNext(r: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob])
|
private case class WrappedRequestNext(r: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob])
|
||||||
extends Command
|
extends Command
|
||||||
|
|
@ -137,7 +137,7 @@ object WorkPullingDocExample {
|
||||||
import ImageWorkManager._
|
import ImageWorkManager._
|
||||||
|
|
||||||
private def waitForNext(): Behavior[Command] = {
|
private def waitForNext(): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case WrappedRequestNext(next) =>
|
case WrappedRequestNext(next) =>
|
||||||
stashBuffer.unstashAll(active(next))
|
stashBuffer.unstashAll(active(next))
|
||||||
case c: Convert =>
|
case c: Convert =>
|
||||||
|
|
@ -156,7 +156,7 @@ object WorkPullingDocExample {
|
||||||
|
|
||||||
private def active(
|
private def active(
|
||||||
next: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob]): Behavior[Command] = {
|
next: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob]): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case Convert(from, to, image) =>
|
case Convert(from, to, image) =>
|
||||||
val resultId = UUID.randomUUID()
|
val resultId = UUID.randomUUID()
|
||||||
next.sendNextTo ! ImageConverter.ConversionJob(resultId, from, to, image)
|
next.sendNextTo ! ImageConverter.ConversionJob(resultId, from, to, image)
|
||||||
|
|
@ -178,7 +178,7 @@ object WorkPullingDocExample {
|
||||||
implicit val askTimeout: Timeout = 5.seconds
|
implicit val askTimeout: Timeout = 5.seconds
|
||||||
|
|
||||||
private def waitForNext(): Behavior[Command] = {
|
private def waitForNext(): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case WrappedRequestNext(next) =>
|
case WrappedRequestNext(next) =>
|
||||||
stashBuffer.unstashAll(active(next))
|
stashBuffer.unstashAll(active(next))
|
||||||
case c: ConvertRequest =>
|
case c: ConvertRequest =>
|
||||||
|
|
@ -201,7 +201,7 @@ object WorkPullingDocExample {
|
||||||
|
|
||||||
private def active(
|
private def active(
|
||||||
next: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob]): Behavior[Command] = {
|
next: WorkPullingProducerController.RequestNext[ImageConverter.ConversionJob]): Behavior[Command] = {
|
||||||
Behaviors.receiveMessage {
|
Behaviors.receiveMessagePartial {
|
||||||
case ConvertRequest(from, to, image, originalReplyTo) =>
|
case ConvertRequest(from, to, image, originalReplyTo) =>
|
||||||
val resultId = UUID.randomUUID()
|
val resultId = UUID.randomUUID()
|
||||||
context.ask[MessageWithConfirmation[ImageConverter.ConversionJob], Done](
|
context.ask[MessageWithConfirmation[ImageConverter.ConversionJob], Done](
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ class ClusterSharding(system: ExtendedActorSystem) extends Extension {
|
||||||
extractShardId,
|
extractShardId,
|
||||||
allocationStrategy,
|
allocationStrategy,
|
||||||
handOffStopMessage)
|
handOffStopMessage)
|
||||||
val Started(shardRegion) = Await.result(guardian ? startMsg, timeout.duration)
|
val shardRegion = Await.result((guardian ? startMsg).mapTo[Started], timeout.duration).shardRegion
|
||||||
regions.put(typeName, shardRegion)
|
regions.put(typeName, shardRegion)
|
||||||
shardRegion
|
shardRegion
|
||||||
case ref => ref // already started, use cached ActorRef
|
case ref => ref // already started, use cached ActorRef
|
||||||
|
|
@ -545,7 +545,7 @@ class ClusterSharding(system: ExtendedActorSystem) extends Extension {
|
||||||
implicit val timeout = system.settings.CreationTimeout
|
implicit val timeout = system.settings.CreationTimeout
|
||||||
val settings = ClusterShardingSettings(system).withRole(role)
|
val settings = ClusterShardingSettings(system).withRole(role)
|
||||||
val startMsg = StartProxy(typeName, dataCenter, settings, extractEntityId, extractShardId)
|
val startMsg = StartProxy(typeName, dataCenter, settings, extractEntityId, extractShardId)
|
||||||
val Started(shardRegion) = Await.result(guardian ? startMsg, timeout.duration)
|
val shardRegion = Await.result((guardian ? startMsg).mapTo[Started], timeout.duration).shardRegion
|
||||||
// it must be possible to start several proxies, one per data center
|
// it must be possible to start several proxies, one per data center
|
||||||
proxies.put(proxyName(typeName, dataCenter), shardRegion)
|
proxies.put(proxyName(typeName, dataCenter), shardRegion)
|
||||||
shardRegion
|
shardRegion
|
||||||
|
|
@ -777,6 +777,8 @@ private[akka] class ClusterShardingGuardian extends Actor {
|
||||||
new EventSourcedRememberEntitiesProvider(typeName, settings)
|
new EventSourcedRememberEntitiesProvider(typeName, settings)
|
||||||
case ClusterShardingSettings.RememberEntitiesStoreCustom =>
|
case ClusterShardingSettings.RememberEntitiesStoreCustom =>
|
||||||
new CustomStateStoreModeProvider(typeName, context.system, settings)
|
new CustomStateStoreModeProvider(typeName, context.system, settings)
|
||||||
|
case unknown =>
|
||||||
|
throw new IllegalArgumentException(s"Unknown store type: $unknown") // compiler exhaustiveness check pleaser
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -960,7 +960,7 @@ private[akka] class Shard(
|
||||||
entityId,
|
entityId,
|
||||||
unexpected)
|
unexpected)
|
||||||
}
|
}
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
log.warning("{}: Unexpected entity terminated: {}", typeName, ref)
|
log.warning("{}: Unexpected entity terminated: {}", typeName, ref)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -982,7 +982,7 @@ private[akka] class Shard(
|
||||||
entity ! stopMessage
|
entity ! stopMessage
|
||||||
flightRecorder.entityPassivate(id)
|
flightRecorder.entityPassivate(id)
|
||||||
}
|
}
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
log.debug("{}: Unknown entity passivating [{}]. Not sending stopMessage back to entity", typeName, entity)
|
log.debug("{}: Unknown entity passivating [{}]. Not sending stopMessage back to entity", typeName, entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1108,7 +1108,7 @@ private[akka] class Shard(
|
||||||
def getOrCreateEntity(id: EntityId): ActorRef = {
|
def getOrCreateEntity(id: EntityId): ActorRef = {
|
||||||
entities.entity(id) match {
|
entities.entity(id) match {
|
||||||
case OptionVal.Some(child) => child
|
case OptionVal.Some(child) => child
|
||||||
case OptionVal.None =>
|
case _ =>
|
||||||
val name = URLEncoder.encode(id, "utf-8")
|
val name = URLEncoder.encode(id, "utf-8")
|
||||||
val a = context.actorOf(entityProps(id), name)
|
val a = context.actorOf(entityProps(id), name)
|
||||||
context.watchWith(a, EntityTerminated(a))
|
context.watchWith(a, EntityTerminated(a))
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ final private[external] class ExternalShardAllocationClientImpl(system: ActorSys
|
||||||
case UpdateSuccess(_, _) => Future.successful(Done)
|
case UpdateSuccess(_, _) => Future.successful(Done)
|
||||||
case UpdateTimeout =>
|
case UpdateTimeout =>
|
||||||
Future.failed(new ClientTimeoutException(s"Unable to update shard location after ${timeout.duration.pretty}"))
|
Future.failed(new ClientTimeoutException(s"Unable to update shard location after ${timeout.duration.pretty}"))
|
||||||
|
case _ => throw new IllegalArgumentException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,6 +87,7 @@ final private[external] class ExternalShardAllocationClientImpl(system: ActorSys
|
||||||
Future.successful(Map.empty[ShardId, ShardLocation])
|
Future.successful(Map.empty[ShardId, ShardLocation])
|
||||||
case GetFailure(_, _) =>
|
case GetFailure(_, _) =>
|
||||||
Future.failed((new ClientTimeoutException(s"Unable to get shard locations after ${timeout.duration.pretty}")))
|
Future.failed((new ClientTimeoutException(s"Unable to get shard locations after ${timeout.duration.pretty}")))
|
||||||
|
case _ => throw new IllegalArgumentException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
.map { locations =>
|
.map { locations =>
|
||||||
new ShardLocations(locations)
|
new ShardLocations(locations)
|
||||||
|
|
@ -104,6 +106,7 @@ final private[external] class ExternalShardAllocationClientImpl(system: ActorSys
|
||||||
case UpdateSuccess(_, _) => Future.successful(Done)
|
case UpdateSuccess(_, _) => Future.successful(Done)
|
||||||
case UpdateTimeout =>
|
case UpdateTimeout =>
|
||||||
Future.failed(new ClientTimeoutException(s"Unable to update shard location after ${timeout.duration.pretty}"))
|
Future.failed(new ClientTimeoutException(s"Unable to update shard location after ${timeout.duration.pretty}"))
|
||||||
|
case _ => throw new IllegalArgumentException() // compiler exhaustiveness check pleaser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ object GlobalRegistry {
|
||||||
case id: Int => (id.toString, id)
|
case id: Int => (id.toString, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
val extractShardId: ShardRegion.ExtractShardId = msg =>
|
val extractShardId: ShardRegion.ExtractShardId = {
|
||||||
msg match {
|
case id: Int => (id % 10).toString
|
||||||
case id: Int => (id % 10).toString
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SingletonActor(registry: ActorRef) extends Actor with ActorLogging {
|
class SingletonActor(registry: ActorRef) extends Actor with ActorLogging {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ object ClusterShardCoordinatorDowning2Spec {
|
||||||
|
|
||||||
val extractShardId: ShardRegion.ExtractShardId = {
|
val extractShardId: ShardRegion.ExtractShardId = {
|
||||||
case Ping(id: String) => id.charAt(0).toString
|
case Ping(id: String) => id.charAt(0).toString
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ object ClusterShardCoordinatorDowningSpec {
|
||||||
|
|
||||||
val extractShardId: ShardRegion.ExtractShardId = {
|
val extractShardId: ShardRegion.ExtractShardId = {
|
||||||
case Ping(id: String) => id.charAt(0).toString
|
case Ping(id: String) => id.charAt(0).toString
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ object ClusterShardingFailureSpec {
|
||||||
case Get(id) => id.charAt(0).toString
|
case Get(id) => id.charAt(0).toString
|
||||||
case Add(id, _) => id.charAt(0).toString
|
case Add(id, _) => id.charAt(0).toString
|
||||||
case StartEntity(id) => id
|
case StartEntity(id) => id
|
||||||
|
case _ => throw new IllegalArgumentException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue