2018-10-29 17:19:37 +08:00
|
|
|
/*
|
2021-01-08 17:55:38 +01:00
|
|
|
* Copyright (C) 2009-2021 Lightbend Inc. <https://www.lightbend.com>
|
2013-10-15 09:01:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.persistence
|
|
|
|
|
|
2015-05-28 01:37:38 +02:00
|
|
|
import java.util.concurrent.atomic.AtomicInteger
|
|
|
|
|
|
2013-10-15 09:01:07 +02:00
|
|
|
import scala.collection.immutable.Seq
|
2015-06-24 19:58:43 +02:00
|
|
|
import scala.concurrent.Await
|
2014-01-17 20:38:52 +01:00
|
|
|
import scala.concurrent.duration._
|
2015-06-24 19:58:43 +02:00
|
|
|
import scala.util.Random
|
2014-10-22 22:12:22 +02:00
|
|
|
import scala.util.control.NoStackTrace
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2020-04-27 20:32:18 +08:00
|
|
|
import com.github.ghik.silencer.silent
|
|
|
|
|
import com.typesafe.config.{ Config, ConfigFactory }
|
|
|
|
|
|
|
|
|
|
import akka.actor._
|
|
|
|
|
import akka.persistence.PersistentActorSpec._
|
|
|
|
|
import akka.testkit.{ EventFilter, ImplicitSender, TestLatch, TestProbe }
|
|
|
|
|
|
2014-05-21 01:35:21 +02:00
|
|
|
object PersistentActorSpec {
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-03-07 13:20:01 +01:00
|
|
|
final case class Cmd(data: Any)
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-03-07 13:20:01 +01:00
|
|
|
final case class Evt(data: Any)
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
final case class LatchCmd(latch: TestLatch, data: Any) extends NoSerializationVerificationNeeded
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-06-26 10:36:27 +02:00
|
|
|
final case class Delete(toSequenceNr: Long)
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
abstract class ExamplePersistentActor(name: String) extends NamedPersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
var events: List[Any] = Nil
|
2015-07-02 00:44:10 +02:00
|
|
|
var askedForDelete: Option[ActorRef] = None
|
2013-10-15 09:01:07 +02:00
|
|
|
|
|
|
|
|
val updateState: Receive = {
|
2019-04-05 14:43:23 +02:00
|
|
|
case Evt(data) => events = data :: events
|
|
|
|
|
case d @ Some(_: ActorRef) => askedForDelete = d.asInstanceOf[Some[ActorRef]]
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val commonBehavior: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case "boom" => throw new TestException("boom")
|
|
|
|
|
case GetState => sender() ! events.reverse
|
|
|
|
|
case Delete(toSequenceNr) =>
|
2019-03-11 10:38:24 +01:00
|
|
|
persist(Some(sender())) { s =>
|
|
|
|
|
askedForDelete = s
|
|
|
|
|
}
|
2015-07-02 00:44:10 +02:00
|
|
|
deleteMessages(toSequenceNr)
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-19 17:46:32 +01:00
|
|
|
def receiveRecover = updateState
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
trait LevelDbRuntimePluginConfig extends PersistenceIdentity with RuntimePluginConfig {
|
|
|
|
|
val providedConfig: Config
|
|
|
|
|
|
|
|
|
|
override def journalPluginId: String = s"custom.persistence.journal.leveldb"
|
|
|
|
|
|
|
|
|
|
override def snapshotPluginId: String = "custom.persistence.snapshot-store.local"
|
|
|
|
|
|
|
|
|
|
override def journalPluginConfig: Config = providedConfig
|
|
|
|
|
|
|
|
|
|
override def snapshotPluginConfig: Config = providedConfig
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trait InmemRuntimePluginConfig extends PersistenceIdentity with RuntimePluginConfig {
|
|
|
|
|
val providedConfig: Config
|
|
|
|
|
|
|
|
|
|
override def journalPluginId: String = s"custom.persistence.journal.inmem"
|
|
|
|
|
|
|
|
|
|
override def snapshotPluginId: String = "custom.persistence.snapshot-store.local"
|
|
|
|
|
|
|
|
|
|
override def journalPluginConfig: Config = providedConfig
|
|
|
|
|
|
|
|
|
|
override def snapshotPluginConfig: Config = providedConfig
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class Behavior1PersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${data}-1"), Evt(s"${data}-2")))(updateState)
|
2019-02-09 15:25:39 +01:00
|
|
|
case d: DeleteMessagesSuccess =>
|
2019-03-11 10:38:24 +01:00
|
|
|
val replyTo = askedForDelete.getOrElse(
|
|
|
|
|
throw new RuntimeException("Received DeleteMessagesSuccess without anyone asking for delete!"))
|
2015-07-02 00:44:10 +02:00
|
|
|
replyTo ! d
|
2019-02-09 15:25:39 +01:00
|
|
|
case d: DeleteMessagesFailure =>
|
2019-03-11 10:38:24 +01:00
|
|
|
val replyTo = askedForDelete.getOrElse(
|
|
|
|
|
throw new RuntimeException("Received DeleteMessagesFailure without anyone asking for delete!"))
|
2018-08-20 08:14:56 +02:00
|
|
|
replyTo ! d
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
2015-06-23 21:01:36 +02:00
|
|
|
|
|
|
|
|
override protected def onPersistRejected(cause: Throwable, event: Any, seqNr: Long): Unit =
|
|
|
|
|
event match {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Evt(data) => sender() ! s"Rejected: $data"
|
|
|
|
|
case _ => super.onPersistRejected(cause, event, seqNr)
|
2015-06-23 21:01:36 +02:00
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-07-02 00:44:10 +02:00
|
|
|
override protected def onPersistFailure(cause: Throwable, event: Any, seqNr: Long): Unit =
|
|
|
|
|
event match {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Evt(data) => sender() ! s"Failure: $data"
|
|
|
|
|
case _ => super.onPersistFailure(cause, event, seqNr)
|
2015-07-02 00:44:10 +02:00
|
|
|
}
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior1PersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior1PersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior1PersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior1PersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class Behavior2PersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${data}-1"), Evt(s"${data}-2")))(updateState)
|
|
|
|
|
persistAll(Seq(Evt(s"${data}-3"), Evt(s"${data}-4")))(updateState)
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior2PersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior2PersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior2PersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior2PersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class Behavior3PersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${data}-11"), Evt(s"${data}-12")))(updateState)
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(Evt(s"${data}-10"))
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior3PersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior3PersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class Behavior3PersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends Behavior3PersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class ChangeBehaviorInLastEventHandlerPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val newBehavior: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2013-10-15 09:01:07 +02:00
|
|
|
persist(Evt(s"${data}-21"))(updateState)
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(Evt(s"${data}-22")) { event =>
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(event)
|
|
|
|
|
context.unbecome()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
|
|
|
|
persist(Evt(s"${data}-0")) { event =>
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(event)
|
|
|
|
|
context.become(newBehavior)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInLastEventHandlerPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInLastEventHandlerPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInLastEventHandlerPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInLastEventHandlerPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class ChangeBehaviorInFirstEventHandlerPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val newBehavior: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
|
|
|
|
persist(Evt(s"${data}-21")) { event =>
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(event)
|
|
|
|
|
context.unbecome()
|
|
|
|
|
}
|
|
|
|
|
persist(Evt(s"${data}-22"))(updateState)
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
|
|
|
|
persist(Evt(s"${data}-0")) { event =>
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(event)
|
|
|
|
|
context.become(newBehavior)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInFirstEventHandlerPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInFirstEventHandlerPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInFirstEventHandlerPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInFirstEventHandlerPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerFirstPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val newBehavior: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2013-10-15 09:01:07 +02:00
|
|
|
context.unbecome()
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${data}-31"), Evt(s"${data}-32")))(updateState)
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(Evt(s"${data}-30"))
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2013-10-15 09:01:07 +02:00
|
|
|
context.become(newBehavior)
|
|
|
|
|
persist(Evt(s"${data}-0"))(updateState)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerFirstPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInCommandHandlerFirstPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerFirstPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInCommandHandlerFirstPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerLastPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val newBehavior: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${data}-31"), Evt(s"${data}-32")))(updateState)
|
2013-10-15 09:01:07 +02:00
|
|
|
updateState(Evt(s"${data}-30"))
|
|
|
|
|
context.unbecome()
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2013-10-15 09:01:07 +02:00
|
|
|
persist(Evt(s"${data}-0"))(updateState)
|
|
|
|
|
context.become(newBehavior)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerLastPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInCommandHandlerLastPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class ChangeBehaviorInCommandHandlerLastPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ChangeBehaviorInCommandHandlerLastPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-06-03 16:40:44 +02:00
|
|
|
class SnapshottingPersistentActor(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
2019-03-11 10:38:24 +01:00
|
|
|
override def receiveRecover = super.receiveRecover.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case SnapshotOffer(_, events: List[_]) =>
|
2013-10-15 09:01:07 +02:00
|
|
|
probe ! "offered"
|
|
|
|
|
this.events = events
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-24 11:21:21 +01:00
|
|
|
private def handleCmd(cmd: Cmd): Unit = {
|
2015-06-16 12:10:49 +02:00
|
|
|
persistAll(Seq(Evt(s"${cmd.data}-41"), Evt(s"${cmd.data}-42")))(updateState)
|
2014-03-24 11:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
def receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case c: Cmd => handleCmd(c)
|
|
|
|
|
case SaveSnapshotSuccess(_) => probe ! "saved"
|
|
|
|
|
case "snap" => saveSnapshot(events)
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class SnapshottingPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends SnapshottingPersistentActor(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class SnapshottingPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends SnapshottingPersistentActor(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
|
|
|
|
|
|
|
|
|
class SnapshottingBecomingPersistentActor(name: String, probe: ActorRef)
|
|
|
|
|
extends SnapshottingPersistentActor(name, probe) {
|
2014-03-19 11:59:16 +01:00
|
|
|
val becomingRecover: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case msg: SnapshotOffer =>
|
2014-03-19 11:59:16 +01:00
|
|
|
context.become(becomingCommand)
|
|
|
|
|
// sending ourself a normal message here also tests
|
|
|
|
|
// that we stash them until recovery is complete
|
|
|
|
|
self ! "It's changing me"
|
|
|
|
|
super.receiveRecover(msg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def receiveRecover = becomingRecover.orElse(super.receiveRecover)
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val becomingCommand: Receive = receiveCommand.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case "It's changing me" => probe ! "I am becoming"
|
2014-03-19 11:59:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class SnapshottingBecomingPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends SnapshottingBecomingPersistentActor(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class SnapshottingBecomingPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends SnapshottingBecomingPersistentActor(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2014-03-19 11:59:16 +01:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class ReplyInEventHandlerPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd("a") => persist(Evt("a"))(evt => sender() ! evt.data)
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class ReplyInEventHandlerPersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ReplyInEventHandlerPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class ReplyInEventHandlerPersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends ReplyInEventHandlerPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class AsyncPersistPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2014-05-21 01:35:21 +02:00
|
|
|
var counter = 0
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! data
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(Evt(s"$data-${incCounter()}")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! evt.data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private def incCounter(): Int = {
|
|
|
|
|
counter += 1
|
|
|
|
|
counter
|
|
|
|
|
}
|
2015-07-02 00:44:10 +02:00
|
|
|
|
|
|
|
|
override protected def onPersistFailure(cause: Throwable, event: Any, seqNr: Long): Unit =
|
|
|
|
|
event match {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Evt(data) => sender() ! s"Failure: $data"
|
|
|
|
|
case _ => super.onPersistFailure(cause, event, seqNr)
|
2015-07-02 00:44:10 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistPersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistPersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class AsyncPersistThreeTimesPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2014-05-21 01:35:21 +02:00
|
|
|
var counter = 0
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! data
|
|
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
(1 to 3).foreach { _ =>
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(Evt(s"$data-${incCounter()}")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! ("a" + evt.data.toString.drop(1)) // c-1 => a-1, as in "ack"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private def incCounter(): Int = {
|
|
|
|
|
counter += 1
|
|
|
|
|
counter
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistThreeTimesPersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistThreeTimesPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistThreeTimesPersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistThreeTimesPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class AsyncPersistSameEventTwicePersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2014-05-21 01:35:21 +02:00
|
|
|
|
|
|
|
|
// atomic because used from inside the *async* callbacks
|
|
|
|
|
val sendMsgCounter = new AtomicInteger()
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! data
|
|
|
|
|
val event = Evt(data)
|
|
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(event) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
// be way slower, in order to be overtaken by the other callback
|
|
|
|
|
Thread.sleep(300)
|
|
|
|
|
sender() ! s"${evt.data}-a-${sendMsgCounter.incrementAndGet()}"
|
|
|
|
|
}
|
2019-03-11 10:38:24 +01:00
|
|
|
persistAsync(event) { evt =>
|
|
|
|
|
sender() ! s"${evt.data}-b-${sendMsgCounter.incrementAndGet()}"
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class AsyncPersistSameEventTwicePersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistSameEventTwicePersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistSameEventTwicePersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistSameEventTwicePersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
@silent // compiler knows persistAll(Nil)(lambda) will never invoke lambda
|
2015-10-24 10:44:07 -07:00
|
|
|
class PersistAllNilPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data: String) if data contains "defer" =>
|
2015-10-24 10:44:07 -07:00
|
|
|
deferAsync("before-nil")(sender() ! _)
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAll(Nil)(_ => sender() ! "Nil")
|
2015-10-24 10:44:07 -07:00
|
|
|
deferAsync("after-nil")(sender() ! _)
|
|
|
|
|
sender() ! data
|
|
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data: String) if data contains "persist" =>
|
2015-10-24 10:44:07 -07:00
|
|
|
persist("before-nil")(sender() ! _)
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAll(Nil)(_ => sender() ! "Nil")
|
2015-10-24 10:44:07 -07:00
|
|
|
deferAsync("after-nil")(sender() ! _)
|
|
|
|
|
sender() ! data
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class PersistAllNilPersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends PersistAllNilPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class PersistAllNilPersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends PersistAllNilPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2014-05-21 01:35:21 +02:00
|
|
|
|
|
|
|
|
var counter = 0
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! data
|
|
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
persist(Evt(s"$data-e1")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! s"${evt.data}-${incCounter()}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this should be happily executed
|
2019-04-05 14:43:23 +02:00
|
|
|
persistAsync(Evt(s"$data-ea2")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! s"${evt.data}-${incCounter()}"
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
persist(Evt(s"$data-e3")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! s"${evt.data}-${incCounter()}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private def incCounter(): Int = {
|
|
|
|
|
counter += 1
|
|
|
|
|
counter
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-11 10:38:24 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
|
|
|
|
extends AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2014-05-21 01:35:21 +02:00
|
|
|
|
|
|
|
|
var sendMsgCounter = 0
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! data
|
|
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
persist(Evt(s"$data-e1")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! s"${evt.data}-${incCounter()}"
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-05 14:43:23 +02:00
|
|
|
persistAsync(Evt(s"$data-ea2")) { evt =>
|
2014-05-21 01:35:21 +02:00
|
|
|
sender() ! s"${evt.data}-${incCounter()}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def incCounter() = {
|
|
|
|
|
sendMsgCounter += 1
|
|
|
|
|
sendMsgCounter
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistAndPersistMixedSyncAsyncPersistentActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class AsyncPersistAndPersistMixedSyncAsyncPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistAndPersistMixedSyncAsyncPersistentActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2013-10-27 08:01:14 +01:00
|
|
|
|
2014-06-26 17:35:46 +02:00
|
|
|
class AsyncPersistHandlerCorrelationCheck(name: String) extends ExamplePersistentActor(name) {
|
2019-03-11 10:38:24 +01:00
|
|
|
val receiveCommand: Receive = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
|
|
|
|
persistAsync(Evt(data)) { evt =>
|
2014-06-26 17:35:46 +02:00
|
|
|
if (data != evt.data)
|
|
|
|
|
sender() ! s"Expected [$data] bot got [${evt.data}]"
|
|
|
|
|
if (evt.data == "done")
|
|
|
|
|
sender() ! "done"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistHandlerCorrelationCheckWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistHandlerCorrelationCheck(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class AsyncPersistHandlerCorrelationCheckWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends AsyncPersistHandlerCorrelationCheck(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2014-06-26 17:35:46 +02:00
|
|
|
|
2019-03-13 14:24:04 +01:00
|
|
|
class PrimitiveEventPersistentActor(name: String) extends ExamplePersistentActor(name) {
|
2013-10-15 09:01:07 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd("a") => persist(5)(evt => sender() ! evt)
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 14:24:04 +01:00
|
|
|
class PrimitiveEventPersistentActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
|
|
|
|
extends PrimitiveEventPersistentActor(name)
|
2019-03-11 10:38:24 +01:00
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 14:24:04 +01:00
|
|
|
class PrimitiveEventPersistentActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
|
|
|
|
extends PrimitiveEventPersistentActor(name)
|
2019-03-11 10:38:24 +01:00
|
|
|
with InmemRuntimePluginConfig
|
2014-06-05 14:07:17 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
class HandleRecoveryFinishedEventPersistentActor(name: String, probe: ActorRef)
|
|
|
|
|
extends SnapshottingPersistentActor(name, probe) {
|
2014-06-05 14:07:17 +02:00
|
|
|
val sendingRecover: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case msg: SnapshotOffer =>
|
2014-06-05 14:07:17 +02:00
|
|
|
// sending ourself a normal message tests
|
|
|
|
|
// that we stash them until recovery is complete
|
|
|
|
|
self ! "I am the stashed"
|
|
|
|
|
super.receiveRecover(msg)
|
2019-02-09 15:25:39 +01:00
|
|
|
case RecoveryCompleted =>
|
2014-06-05 14:07:17 +02:00
|
|
|
probe ! RecoveryCompleted
|
|
|
|
|
self ! "I am the recovered"
|
|
|
|
|
updateState(Evt(RecoveryCompleted))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def receiveRecover = sendingRecover.orElse(super.receiveRecover)
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
override def receiveCommand: Receive = super.receiveCommand.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String => probe ! s
|
2014-06-05 14:07:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class HandleRecoveryFinishedEventPersistentActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends HandleRecoveryFinishedEventPersistentActor(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class HandleRecoveryFinishedEventPersistentActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends HandleRecoveryFinishedEventPersistentActor(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2018-02-05 22:36:26 +01:00
|
|
|
trait DeferActor extends PersistentActor {
|
2019-02-09 15:25:39 +01:00
|
|
|
def doDefer[A](event: A)(handler: A => Unit): Unit
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
trait DeferSync {
|
2019-02-09 15:25:39 +01:00
|
|
|
this: PersistentActor =>
|
|
|
|
|
def doDefer[A](event: A)(handler: A => Unit): Unit = defer(event)(handler)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
trait DeferAsync {
|
2019-02-09 15:25:39 +01:00
|
|
|
this: PersistentActor =>
|
|
|
|
|
def doDefer[A](event: A)(handler: A => Unit): Unit = deferAsync(event)(handler)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
abstract class DeferringWithPersistActor(name: String) extends ExamplePersistentActor(name) with DeferActor {
|
2014-06-03 16:40:44 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer("d-1") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
persist(s"$data-2") { sender() ! _ }
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer("d-3") { sender() ! _ }
|
|
|
|
|
doDefer("d-4") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-02-05 22:36:26 +01:00
|
|
|
class DeferringAsyncWithPersistActor(name: String) extends DeferringWithPersistActor(name) with DeferAsync
|
|
|
|
|
class DeferringSyncWithPersistActor(name: String) extends DeferringWithPersistActor(name) with DeferSync
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncWithPersistActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncWithPersistActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncWithPersistActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncWithPersistActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2018-02-05 22:36:26 +01:00
|
|
|
abstract class DeferringWithAsyncPersistActor(name: String) extends ExamplePersistentActor(name) with DeferActor {
|
2014-06-03 16:40:44 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer(s"d-$data-1") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
persistAsync(s"pa-$data-2") { sender() ! _ }
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer(s"d-$data-3") { sender() ! _ }
|
|
|
|
|
doDefer(s"d-$data-4") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-02-05 22:36:26 +01:00
|
|
|
class DeferringAsyncWithAsyncPersistActor(name: String) extends DeferringWithAsyncPersistActor(name) with DeferAsync
|
|
|
|
|
class DeferringSyncWithAsyncPersistActor(name: String) extends DeferringWithAsyncPersistActor(name) with DeferSync
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncWithAsyncPersistActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithAsyncPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncWithAsyncPersistActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithAsyncPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncWithAsyncPersistActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithAsyncPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncWithAsyncPersistActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithAsyncPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
abstract class DeferringMixedCallsPPADDPADPersistActor(name: String)
|
|
|
|
|
extends ExamplePersistentActor(name)
|
|
|
|
|
with DeferActor {
|
2014-06-03 16:40:44 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2014-06-03 16:40:44 +02:00
|
|
|
persist(s"p-$data-1") { sender() ! _ }
|
|
|
|
|
persistAsync(s"pa-$data-2") { sender() ! _ }
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer(s"d-$data-3") { sender() ! _ }
|
|
|
|
|
doDefer(s"d-$data-4") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
persistAsync(s"pa-$data-5") { sender() ! _ }
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer(s"d-$data-6") { sender() ! _ }
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-03-11 10:38:24 +01:00
|
|
|
class DeferringAsyncMixedCallsPPADDPADPersistActor(name: String)
|
|
|
|
|
extends DeferringMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with DeferAsync
|
|
|
|
|
class DeferringSyncMixedCallsPPADDPADPersistActor(name: String)
|
|
|
|
|
extends DeferringMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with DeferSync
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringAsyncMixedCallsPPADDPADPersistActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringSyncMixedCallsPPADDPADPersistActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringAsyncMixedCallsPPADDPADPersistActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringSyncMixedCallsPPADDPADPersistActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncMixedCallsPPADDPADPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
|
|
|
|
|
|
|
|
|
abstract class DeferringWithNoPersistCallsPersistActor(name: String)
|
|
|
|
|
extends ExamplePersistentActor(name)
|
|
|
|
|
with DeferActor {
|
2018-02-05 22:36:26 +01:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(_) =>
|
2018-02-05 22:36:26 +01:00
|
|
|
doDefer("d-1") { sender() ! _ }
|
|
|
|
|
doDefer("d-2") { sender() ! _ }
|
|
|
|
|
doDefer("d-3") { sender() ! _ }
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-11 10:38:24 +01:00
|
|
|
class DeferringAsyncWithNoPersistCallsPersistActor(name: String)
|
|
|
|
|
extends DeferringWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with DeferAsync
|
|
|
|
|
class DeferringSyncWithNoPersistCallsPersistActor(name: String)
|
|
|
|
|
extends DeferringWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with DeferSync
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringAsyncWithNoPersistCallsPersistActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringSyncWithNoPersistCallsPersistActorWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringAsyncWithNoPersistCallsPersistActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeferringSyncWithNoPersistCallsPersistActorWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncWithNoPersistCallsPersistActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2018-02-05 22:36:26 +01:00
|
|
|
abstract class DeferringActor(name: String) extends ExamplePersistentActor(name) with DeferActor {
|
2014-06-03 16:40:44 +02:00
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(data) =>
|
2018-02-05 22:36:26 +01:00
|
|
|
sender() ! data
|
2019-03-11 10:38:24 +01:00
|
|
|
persist(()) { _ =>
|
|
|
|
|
} // skip calling defer immediately because of empty pending invocations
|
2019-02-09 15:25:39 +01:00
|
|
|
doDefer(Evt(s"$data-defer")) { evt =>
|
2018-02-05 22:36:26 +01:00
|
|
|
sender() ! evt.data
|
|
|
|
|
}
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-02-05 22:36:26 +01:00
|
|
|
class DeferringAsyncActor(name: String) extends DeferringActor(name) with DeferAsync
|
|
|
|
|
class DeferringSyncActor(name: String) extends DeferringActor(name) with DeferSync
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncActorWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncActor(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringAsyncActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringAsyncActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class DeferringSyncActorWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeferringSyncActor(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2014-06-03 16:40:44 +02:00
|
|
|
|
2014-12-08 11:02:14 +01:00
|
|
|
class StressOrdering(name: String) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case LatchCmd(latch, data) =>
|
2014-12-08 11:02:14 +01:00
|
|
|
sender() ! data
|
|
|
|
|
Await.ready(latch, 5.seconds)
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(data)(_ => ())
|
|
|
|
|
case Cmd(data) =>
|
2014-12-08 11:02:14 +01:00
|
|
|
sender() ! data
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(data)(_ => ())
|
|
|
|
|
case s: String =>
|
2014-12-08 11:02:14 +01:00
|
|
|
sender() ! s
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class StressOrderingWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends StressOrdering(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class StressOrderingWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends StressOrdering(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2014-12-08 11:02:14 +01:00
|
|
|
|
2016-11-13 20:30:33 -05:00
|
|
|
class RecoverMessageCausedRestart(name: String) extends NamedPersistentActor(name) {
|
|
|
|
|
var master: ActorRef = _
|
|
|
|
|
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case "Boom" =>
|
2016-11-13 20:30:33 -05:00
|
|
|
master = sender()
|
|
|
|
|
throw new TestException("boom")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def preRestart(reason: Throwable, message: Option[Any]): Unit = {
|
|
|
|
|
if (master ne null) {
|
|
|
|
|
master ! "failed with " + reason.getClass.getSimpleName + " while processing " + message.getOrElse("")
|
|
|
|
|
}
|
2019-03-11 10:38:24 +01:00
|
|
|
context.stop(self)
|
2016-11-13 20:30:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def receiveRecover = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case _ => ()
|
2016-11-13 20:30:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class RecoverMessageCausedRestartWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends RecoverMessageCausedRestart(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class RecoverMessageCausedRestartWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends RecoverMessageCausedRestart(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2016-11-13 20:30:33 -05:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
class MultipleAndNestedPersists(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-outer-1") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-03-11 10:38:24 +01:00
|
|
|
persist(s + "-inner-1") { inner =>
|
|
|
|
|
probe ! inner
|
|
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
}
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-outer-2") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-03-11 10:38:24 +01:00
|
|
|
persist(s + "-inner-2") { inner =>
|
|
|
|
|
probe ! inner
|
|
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class MultipleAndNestedPersistsWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends MultipleAndNestedPersists(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class MultipleAndNestedPersistsWithInmemRuntimePluginConfig(name: String, probe: ActorRef, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends MultipleAndNestedPersists(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
class MultipleAndNestedPersistAsyncs(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-outer-1") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-03-11 10:38:24 +01:00
|
|
|
persistAsync(s + "-inner-1") { inner =>
|
|
|
|
|
probe ! inner
|
|
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
}
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-outer-2") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-03-11 10:38:24 +01:00
|
|
|
persistAsync(s + "-inner-2") { inner =>
|
|
|
|
|
probe ! inner
|
|
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class MultipleAndNestedPersistAsyncsWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends MultipleAndNestedPersistAsyncs(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class MultipleAndNestedPersistAsyncsWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends MultipleAndNestedPersistAsyncs(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
class DeeplyNestedPersistAsyncs(name: String, maxDepth: Int, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
var currentDepths = Map.empty[String, Int].withDefaultValue(1)
|
|
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
def weMustGoDeeper: String => Unit = { dWithDepth =>
|
2015-06-24 19:58:43 +02:00
|
|
|
val d = dWithDepth.split("-").head
|
|
|
|
|
probe ! dWithDepth
|
|
|
|
|
if (currentDepths(d) < maxDepth) {
|
|
|
|
|
currentDepths = currentDepths.updated(d, currentDepths(d) + 1)
|
|
|
|
|
persistAsync(d + "-" + currentDepths(d))(weMustGoDeeper)
|
|
|
|
|
} else {
|
|
|
|
|
// reset depth counter before next command
|
|
|
|
|
currentDepths = currentDepths.updated(d, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
|
|
|
|
persistAsync(s + "-" + 1)(weMustGoDeeper)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeeplyNestedPersistAsyncsWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
maxDepth: Int,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeeplyNestedPersistAsyncs(name, maxDepth, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeeplyNestedPersistAsyncsWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
maxDepth: Int,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeeplyNestedPersistAsyncs(name, maxDepth, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2015-06-24 19:58:43 +02:00
|
|
|
|
|
|
|
|
class NestedPersistNormalAndAsyncs(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-outer-1") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-inner-async-1") { inner =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! inner
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-outer-2") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-inner-async-2") { inner =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! inner
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistNormalAndAsyncsWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistNormalAndAsyncs(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistNormalAndAsyncsWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistNormalAndAsyncs(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
class NestedPersistAsyncsAndNormal(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-outer-async-1") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-inner-1") { inner =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! inner
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-outer-async-2") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-inner-2") { inner =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! inner
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistAsyncsAndNormalWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistAsyncsAndNormal(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistAsyncsAndNormalWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistAsyncsAndNormal(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2015-06-24 19:58:43 +02:00
|
|
|
class NestedPersistInAsyncEnforcesStashing(name: String, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
2019-02-09 15:25:39 +01:00
|
|
|
persistAsync(s + "-outer-async") { outer =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! outer
|
2019-02-09 15:25:39 +01:00
|
|
|
persist(s + "-inner") { inner =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! inner
|
|
|
|
|
Thread.sleep(1000) // really long wait here...
|
|
|
|
|
// the next incoming command must be handled by the following function
|
2019-02-09 15:25:39 +01:00
|
|
|
context.become({ case _ => sender() ! "done" })
|
2015-06-24 19:58:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistInAsyncEnforcesStashingWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistInAsyncEnforcesStashing(name, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class NestedPersistInAsyncEnforcesStashingWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends NestedPersistInAsyncEnforcesStashing(name, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2015-06-24 19:58:43 +02:00
|
|
|
|
|
|
|
|
class DeeplyNestedPersists(name: String, maxDepth: Int, probe: ActorRef) extends ExamplePersistentActor(name) {
|
|
|
|
|
var currentDepths = Map.empty[String, Int].withDefaultValue(1)
|
|
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
def weMustGoDeeper: String => Unit = { dWithDepth =>
|
2015-06-24 19:58:43 +02:00
|
|
|
val d = dWithDepth.split("-").head
|
|
|
|
|
probe ! dWithDepth
|
|
|
|
|
if (currentDepths(d) < maxDepth) {
|
|
|
|
|
currentDepths = currentDepths.updated(d, currentDepths(d) + 1)
|
|
|
|
|
persist(d + "-" + currentDepths(d))(weMustGoDeeper)
|
|
|
|
|
} else {
|
|
|
|
|
// reset depth counter before next command
|
|
|
|
|
currentDepths = currentDepths.updated(d, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val receiveCommand: Receive = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case s: String =>
|
2015-06-24 19:58:43 +02:00
|
|
|
probe ! s
|
|
|
|
|
persist(s + "-" + 1)(weMustGoDeeper)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeeplyNestedPersistsWithLevelDbRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
maxDepth: Int,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeeplyNestedPersists(name, maxDepth, probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2019-03-13 10:56:20 +01:00
|
|
|
class DeeplyNestedPersistsWithInmemRuntimePluginConfig(
|
|
|
|
|
name: String,
|
|
|
|
|
maxDepth: Int,
|
|
|
|
|
probe: ActorRef,
|
|
|
|
|
val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends DeeplyNestedPersists(name, maxDepth, probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
|
|
|
|
|
|
|
|
|
class StackableTestPersistentActor(val probe: ActorRef)
|
|
|
|
|
extends StackableTestPersistentActor.BaseActor
|
|
|
|
|
with PersistentActor
|
|
|
|
|
with StackableTestPersistentActor.MixinActor {
|
2014-10-22 22:12:22 +02:00
|
|
|
override def persistenceId: String = "StackableTestPersistentActor"
|
|
|
|
|
|
|
|
|
|
def receiveCommand = {
|
2019-03-11 10:38:24 +01:00
|
|
|
case "restart" =>
|
|
|
|
|
throw new Exception("triggering restart") with NoStackTrace {
|
|
|
|
|
override def toString = "Boom!"
|
|
|
|
|
}
|
2014-10-22 22:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def receiveRecover = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case _ => ()
|
2014-10-22 22:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def preStart(): Unit = {
|
|
|
|
|
probe ! "preStart"
|
|
|
|
|
super.preStart()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def postStop(): Unit = {
|
|
|
|
|
probe ! "postStop"
|
|
|
|
|
super.postStop()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def preRestart(reason: Throwable, message: Option[Any]): Unit = {
|
|
|
|
|
probe ! "preRestart"
|
|
|
|
|
super.preRestart(reason, message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def postRestart(reason: Throwable): Unit = {
|
|
|
|
|
probe ! "postRestart"
|
|
|
|
|
super.postRestart(reason)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class StackableTestPersistentActorWithLevelDbRuntimePluginConfig(probe: ActorRef, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends StackableTestPersistentActor(probe)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class StackableTestPersistentActorWithInmemRuntimePluginConfig(probe: ActorRef, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends StackableTestPersistentActor(probe)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2014-10-22 22:12:22 +02:00
|
|
|
|
|
|
|
|
object StackableTestPersistentActor {
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
trait BaseActor extends Actor {
|
2019-02-09 15:25:39 +01:00
|
|
|
this: StackableTestPersistentActor =>
|
2014-10-22 22:12:22 +02:00
|
|
|
override protected[akka] def aroundPreStart() = {
|
|
|
|
|
probe ! "base aroundPreStart"
|
|
|
|
|
super.aroundPreStart()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPostStop() = {
|
|
|
|
|
probe ! "base aroundPostStop"
|
|
|
|
|
super.aroundPostStop()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPreRestart(reason: Throwable, message: Option[Any]) = {
|
|
|
|
|
probe ! "base aroundPreRestart"
|
|
|
|
|
super.aroundPreRestart(reason, message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPostRestart(reason: Throwable) = {
|
|
|
|
|
probe ! "base aroundPostRestart"
|
|
|
|
|
super.aroundPostRestart(reason)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundReceive(receive: Receive, message: Any) = {
|
2018-03-26 13:52:31 +02:00
|
|
|
if (message == "restart" && recoveryFinished) {
|
|
|
|
|
probe ! s"base aroundReceive $message"
|
|
|
|
|
}
|
2014-10-22 22:12:22 +02:00
|
|
|
super.aroundReceive(receive, message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
trait MixinActor extends Actor {
|
2019-02-09 15:25:39 +01:00
|
|
|
this: StackableTestPersistentActor =>
|
2014-10-22 22:12:22 +02:00
|
|
|
override protected[akka] def aroundPreStart() = {
|
|
|
|
|
probe ! "mixin aroundPreStart"
|
|
|
|
|
super.aroundPreStart()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPostStop() = {
|
|
|
|
|
probe ! "mixin aroundPostStop"
|
|
|
|
|
super.aroundPostStop()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPreRestart(reason: Throwable, message: Option[Any]) = {
|
|
|
|
|
probe ! "mixin aroundPreRestart"
|
|
|
|
|
super.aroundPreRestart(reason, message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundPostRestart(reason: Throwable) = {
|
|
|
|
|
probe ! "mixin aroundPostRestart"
|
|
|
|
|
super.aroundPostRestart(reason)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override protected[akka] def aroundReceive(receive: Receive, message: Any) = {
|
2018-03-26 13:52:31 +02:00
|
|
|
if (message == "restart" && recoveryFinished) {
|
|
|
|
|
probe ! s"mixin aroundReceive $message"
|
|
|
|
|
}
|
2014-10-22 22:12:22 +02:00
|
|
|
super.aroundReceive(receive, message)
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-10-22 22:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-14 17:32:27 +05:00
|
|
|
class PersistInRecovery(name: String) extends ExamplePersistentActor(name) {
|
|
|
|
|
override def receiveRecover = {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Evt("invalid") =>
|
2016-12-14 17:32:27 +05:00
|
|
|
persist(Evt("invalid-recovery"))(updateState)
|
2019-02-09 15:25:39 +01:00
|
|
|
case e: Evt => updateState(e)
|
|
|
|
|
case RecoveryCompleted =>
|
2016-12-14 17:32:27 +05:00
|
|
|
persistAsync(Evt("rc-1"))(updateState)
|
|
|
|
|
persist(Evt("rc-2"))(updateState)
|
|
|
|
|
persistAsync(Evt("rc-3"))(updateState)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def onRecoveryFailure(cause: scala.Throwable, event: Option[Any]): Unit = ()
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
def receiveCommand = commonBehavior.orElse {
|
2019-02-09 15:25:39 +01:00
|
|
|
case Cmd(d) => persist(Evt(d))(updateState)
|
2016-12-14 17:32:27 +05:00
|
|
|
}
|
|
|
|
|
}
|
2018-03-26 13:52:31 +02:00
|
|
|
class PersistInRecoveryWithLevelDbRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends PersistInRecovery(name)
|
|
|
|
|
with LevelDbRuntimePluginConfig
|
2018-03-26 13:52:31 +02:00
|
|
|
class PersistInRecoveryWithInmemRuntimePluginConfig(name: String, val providedConfig: Config)
|
2019-03-11 10:38:24 +01:00
|
|
|
extends PersistInRecovery(name)
|
|
|
|
|
with InmemRuntimePluginConfig
|
2018-02-22 01:20:52 +09:00
|
|
|
|
|
|
|
|
class ExceptionActor(name: String) extends ExamplePersistentActor(name) {
|
|
|
|
|
override def receiveCommand = commonBehavior
|
|
|
|
|
override def receiveRecover = throw new TestException("boom")
|
|
|
|
|
}
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-09 14:12:36 +02:00
|
|
|
abstract class PersistentActorSpec(config: Config) extends PersistenceSpec(config) with ImplicitSender {
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-05-21 01:35:21 +02:00
|
|
|
import PersistentActorSpec._
|
2013-10-15 09:01:07 +02:00
|
|
|
|
2018-07-25 20:38:27 +09:00
|
|
|
override protected def beforeEach(): Unit = {
|
2013-10-15 09:01:07 +02:00
|
|
|
super.beforeEach()
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior1PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2"))
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
protected def behavior1PersistentActor: ActorRef = namedPersistentActor[Behavior1PersistentActor]
|
|
|
|
|
|
|
|
|
|
protected def behavior2PersistentActor: ActorRef = namedPersistentActor[Behavior2PersistentActor]
|
|
|
|
|
|
|
|
|
|
protected def behavior3PersistentActor: ActorRef = namedPersistentActor[Behavior3PersistentActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def changeBehaviorInFirstEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[ChangeBehaviorInFirstEventHandlerPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def changeBehaviorInLastEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[ChangeBehaviorInLastEventHandlerPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def changeBehaviorInCommandHandlerFirstPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[ChangeBehaviorInCommandHandlerFirstPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def changeBehaviorInCommandHandlerLastPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[ChangeBehaviorInCommandHandlerLastPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def snapshottingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[SnapshottingPersistentActor], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def snapshottingBecomingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[SnapshottingBecomingPersistentActor], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def replyInEventHandlerPersistentActor: ActorRef = namedPersistentActor[ReplyInEventHandlerPersistentActor]
|
|
|
|
|
|
2019-03-13 14:24:04 +01:00
|
|
|
protected def primitiveEventPersistentActor: ActorRef = namedPersistentActor[PrimitiveEventPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def asyncPersistPersistentActor: ActorRef = namedPersistentActor[AsyncPersistPersistentActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def asyncPersistThreeTimesPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[AsyncPersistThreeTimesPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def asyncPersistSameEventTwicePersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[AsyncPersistSameEventTwicePersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def persistAllNilPersistentActor: ActorRef = namedPersistentActor[PersistAllNilPersistentActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def asyncPersistAndPersistMixedSyncAsyncSyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def asyncPersistAndPersistMixedSyncAsyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActor[AsyncPersistAndPersistMixedSyncAsyncPersistentActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def asyncPersistHandlerCorrelationCheck: ActorRef =
|
|
|
|
|
namedPersistentActor[AsyncPersistHandlerCorrelationCheck]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def deferringWithPersistActor: ActorRef = namedPersistentActor[DeferringWithPersistActor]
|
|
|
|
|
|
|
|
|
|
protected def deferringWithAsyncPersistActor: ActorRef = namedPersistentActor[DeferringWithAsyncPersistActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringMixedCallsPPADDPADPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringWithNoPersistCallsPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def handleRecoveryFinishedEventPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[HandleRecoveryFinishedEventPersistentActor], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def stressOrdering: ActorRef = namedPersistentActor[StressOrdering]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def stackableTestPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[StackableTestPersistentActor], testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def multipleAndNestedPersists: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[MultipleAndNestedPersists], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def multipleAndNestedPersistAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[MultipleAndNestedPersistAsyncs], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deeplyNestedPersists(nestedPersists: Int): ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[DeeplyNestedPersists], name, nestedPersists, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deeplyNestedPersistAsyncs(nestedPersistAsyncs: Int): ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[DeeplyNestedPersistAsyncs], name, nestedPersistAsyncs, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def nestedPersistNormalAndAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[NestedPersistNormalAndAsyncs], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def nestedPersistAsyncsAndNormal: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[NestedPersistAsyncsAndNormal], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def nestedPersistInAsyncEnforcesStashing: ActorRef =
|
|
|
|
|
system.actorOf(Props(classOf[NestedPersistInAsyncEnforcesStashing], name, testActor))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def persistInRecovery: ActorRef = namedPersistentActor[PersistInRecovery]
|
|
|
|
|
|
|
|
|
|
protected def recoverMessageCausedRestart: ActorRef = namedPersistentActor[RecoverMessageCausedRestart]
|
|
|
|
|
|
|
|
|
|
protected def deferringAsyncWithPersistActor: ActorRef = namedPersistentActor[DeferringAsyncWithPersistActor]
|
|
|
|
|
|
|
|
|
|
protected def deferringSyncWithPersistActor: ActorRef = namedPersistentActor[DeferringSyncWithPersistActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringAsyncWithAsyncPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringAsyncWithAsyncPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def deferringSyncWithAsyncPersistActor: ActorRef = namedPersistentActor[DeferringSyncWithAsyncPersistActor]
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringAsyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringAsyncMixedCallsPPADDPADPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringSyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringSyncMixedCallsPPADDPADPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringAsyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringAsyncWithNoPersistCallsPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
protected def deferringSyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActor[DeferringSyncWithNoPersistCallsPersistActor]
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
protected def deferringAsyncActor: ActorRef = namedPersistentActor[DeferringAsyncActor]
|
|
|
|
|
|
|
|
|
|
protected def deferringSyncActor: ActorRef = namedPersistentActor[DeferringSyncActor]
|
|
|
|
|
|
2014-05-21 01:35:21 +02:00
|
|
|
"A persistent actor" must {
|
2016-12-16 16:54:53 +01:00
|
|
|
"fail fast if persistenceId is null" in {
|
|
|
|
|
import akka.testkit.filterEvents
|
|
|
|
|
filterEvents(EventFilter[ActorInitializationException]()) {
|
2019-03-11 10:38:24 +01:00
|
|
|
EventFilter.error(message = "requirement failed: persistenceId is [null] for PersistentActor").intercept {
|
2016-12-16 16:54:53 +01:00
|
|
|
val ref = system.actorOf(Props(new NamedPersistentActor(null) {
|
|
|
|
|
override def receiveRecover: Receive = Actor.emptyBehavior
|
|
|
|
|
|
|
|
|
|
override def receiveCommand: Receive = Actor.emptyBehavior
|
|
|
|
|
}))
|
|
|
|
|
watch(ref)
|
|
|
|
|
expectTerminated(ref)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-03 16:22:44 -05:00
|
|
|
"fail fast if persistenceId is an empty string" in {
|
|
|
|
|
import akka.testkit.filterEvents
|
|
|
|
|
filterEvents(EventFilter[ActorInitializationException]()) {
|
2019-03-11 10:38:24 +01:00
|
|
|
EventFilter.error(message = "persistenceId cannot be empty for PersistentActor").intercept {
|
2018-01-03 16:22:44 -05:00
|
|
|
val ref = system.actorOf(Props(new NamedPersistentActor(" ") {
|
|
|
|
|
override def receiveRecover: Receive = Actor.emptyBehavior
|
|
|
|
|
|
|
|
|
|
override def receiveCommand: Receive = Actor.emptyBehavior
|
|
|
|
|
}))
|
|
|
|
|
watch(ref)
|
|
|
|
|
expectTerminated(ref)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-15 09:01:07 +02:00
|
|
|
"recover from persisted events" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior1PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2"))
|
|
|
|
|
}
|
|
|
|
|
"handle multiple emitted events in correct order (for a single persist call)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior1PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2"))
|
|
|
|
|
}
|
|
|
|
|
"handle multiple emitted events in correct order (for multiple persist calls)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior2PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2", "b-3", "b-4"))
|
|
|
|
|
}
|
|
|
|
|
"receive emitted events immediately after command" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior3PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-10", "b-11", "b-12", "c-10", "c-11", "c-12"))
|
|
|
|
|
}
|
2015-07-10 00:13:07 +02:00
|
|
|
"recover on command failure" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior3PersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! "boom"
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
// cmd that was added to state before failure (b-10) is not replayed ...
|
|
|
|
|
expectMsg(List("a-1", "a-2", "b-11", "b-12", "c-10", "c-11", "c-12"))
|
|
|
|
|
}
|
|
|
|
|
"allow behavior changes in event handler (when handling first event)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = changeBehaviorInFirstEventHandlerPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! Cmd("d")
|
|
|
|
|
persistentActor ! Cmd("e")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-0", "c-21", "c-22", "d-0", "e-21", "e-22"))
|
|
|
|
|
}
|
|
|
|
|
"allow behavior changes in event handler (when handling last event)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = changeBehaviorInLastEventHandlerPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! Cmd("d")
|
|
|
|
|
persistentActor ! Cmd("e")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-0", "c-21", "c-22", "d-0", "e-21", "e-22"))
|
|
|
|
|
}
|
|
|
|
|
"allow behavior changes in command handler (as first action)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = changeBehaviorInCommandHandlerFirstPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! Cmd("d")
|
|
|
|
|
persistentActor ! Cmd("e")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-0", "c-30", "c-31", "c-32", "d-0", "e-30", "e-31", "e-32"))
|
|
|
|
|
}
|
|
|
|
|
"allow behavior changes in command handler (as last action)" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = changeBehaviorInCommandHandlerLastPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
|
|
|
|
persistentActor ! Cmd("d")
|
|
|
|
|
persistentActor ! Cmd("e")
|
|
|
|
|
persistentActor ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-0", "c-30", "c-31", "c-32", "d-0", "e-30", "e-31", "e-32"))
|
|
|
|
|
}
|
|
|
|
|
"support snapshotting" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor1 = snapshottingPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! Cmd("b")
|
|
|
|
|
persistentActor1 ! "snap"
|
|
|
|
|
persistentActor1 ! Cmd("c")
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg("saved")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42"))
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor2 = snapshottingPersistentActor
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg("offered")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor2 ! GetState
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42"))
|
|
|
|
|
}
|
2014-03-19 11:59:16 +01:00
|
|
|
"support context.become during recovery" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor1 = snapshottingPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! Cmd("b")
|
|
|
|
|
persistentActor1 ! "snap"
|
|
|
|
|
persistentActor1 ! Cmd("c")
|
2014-03-19 11:59:16 +01:00
|
|
|
expectMsg("saved")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! GetState
|
2014-03-19 11:59:16 +01:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42"))
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor2 = snapshottingBecomingPersistentActor
|
2014-03-19 11:59:16 +01:00
|
|
|
expectMsg("offered")
|
|
|
|
|
expectMsg("I am becoming")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor2 ! GetState
|
2014-03-19 11:59:16 +01:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42"))
|
|
|
|
|
}
|
2013-10-15 09:01:07 +02:00
|
|
|
"be able to reply within an event handler" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = replyInEventHandlerPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg("a")
|
|
|
|
|
}
|
2019-03-13 14:24:04 +01:00
|
|
|
"be able to persist primitive events" in {
|
|
|
|
|
val persistentActor = primitiveEventPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
2013-10-15 09:01:07 +02:00
|
|
|
expectMsg(5)
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
"be able to opt-out from stashing messages until all events have been processed" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("x")
|
|
|
|
|
persistentActor ! Cmd("y")
|
2014-05-21 01:35:21 +02:00
|
|
|
expectMsg("x")
|
|
|
|
|
expectMsg("y") // "y" command was processed before event persisted
|
|
|
|
|
expectMsg("x-1")
|
|
|
|
|
expectMsg("y-2")
|
|
|
|
|
}
|
|
|
|
|
"support multiple persistAsync calls for one command, and execute them 'when possible', not hindering command processing" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistThreeTimesPersistentActor
|
2019-03-11 10:38:24 +01:00
|
|
|
val commands = (1 to 10).map { i =>
|
|
|
|
|
Cmd(s"c-$i")
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
commands.foreach { i =>
|
2014-05-21 01:35:21 +02:00
|
|
|
Thread.sleep(Random.nextInt(10))
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! i
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val all: Seq[String] = this.receiveN(40).asInstanceOf[Seq[String]] // each command = 1 reply + 3 event-replies
|
|
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
val replies = all.filter(r => r.count(_ == '-') == 1)
|
2014-05-21 01:35:21 +02:00
|
|
|
replies should equal(commands.map(_.data))
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val expectedAcks = (3 to 32).map { i =>
|
|
|
|
|
s"a-${i / 3}-${i - 2}"
|
|
|
|
|
}
|
2019-02-09 15:25:39 +01:00
|
|
|
val acks = all.filter(r => r.count(_ == '-') == 2)
|
2014-05-21 01:35:21 +02:00
|
|
|
acks should equal(expectedAcks)
|
|
|
|
|
}
|
|
|
|
|
"reply to the original sender() of a command, even when using persistAsync" in {
|
2014-12-08 11:02:14 +01:00
|
|
|
// sanity check, the setting of sender() for PersistentRepl is handled by PersistentActor currently
|
2014-05-21 01:35:21 +02:00
|
|
|
// but as we want to remove it soon, keeping the explicit test here.
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistThreeTimesPersistentActor
|
2014-05-21 01:35:21 +02:00
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
val commands = (1 to 10).map { i =>
|
|
|
|
|
Cmd(s"c-$i")
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
val probes = Vector.fill(10)(TestProbe())
|
|
|
|
|
|
2019-03-21 12:42:29 -07:00
|
|
|
probes.zip(commands).foreach {
|
2019-02-09 15:25:39 +01:00
|
|
|
case (p, c) =>
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor.tell(c, p.ref)
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val ackClass = classOf[String]
|
|
|
|
|
within(3.seconds) {
|
2019-03-11 10:38:24 +01:00
|
|
|
probes.foreach {
|
2018-03-26 13:52:31 +02:00
|
|
|
_.expectMsgAllClassOf(ackClass, ackClass, ackClass)
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
"support the same event being asyncPersist'ed multiple times" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistSameEventTwicePersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("x")
|
2014-05-21 01:35:21 +02:00
|
|
|
expectMsg("x")
|
|
|
|
|
|
|
|
|
|
expectMsg("x-a-1")
|
|
|
|
|
expectMsg("x-b-2")
|
2018-03-26 13:52:31 +02:00
|
|
|
expectNoMessage(100.millis)
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
2015-10-24 10:44:07 -07:00
|
|
|
"support calling persistAll with Nil" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = persistAllNilPersistentActor
|
2015-10-24 10:44:07 -07:00
|
|
|
persistentActor ! Cmd("defer-x")
|
|
|
|
|
expectMsg("before-nil")
|
|
|
|
|
expectMsg("after-nil")
|
|
|
|
|
expectMsg("defer-x")
|
|
|
|
|
persistentActor ! Cmd("persist-x")
|
|
|
|
|
expectMsg("persist-x")
|
|
|
|
|
expectMsg("before-nil")
|
|
|
|
|
expectMsg("after-nil")
|
|
|
|
|
}
|
2014-05-21 01:35:21 +02:00
|
|
|
"support a mix of persist calls (sync, async, sync) and persist calls in expected order" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistAndPersistMixedSyncAsyncSyncPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
|
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
2014-05-21 01:35:21 +02:00
|
|
|
expectMsg("a")
|
|
|
|
|
expectMsg("a-e1-1") // persist
|
|
|
|
|
expectMsg("a-ea2-2") // persistAsync, but ordering enforced by sync persist below
|
|
|
|
|
expectMsg("a-e3-3") // persist
|
|
|
|
|
expectMsg("b")
|
|
|
|
|
expectMsg("b-e1-4")
|
|
|
|
|
expectMsg("b-ea2-5")
|
|
|
|
|
expectMsg("b-e3-6")
|
|
|
|
|
expectMsg("c")
|
|
|
|
|
expectMsg("c-e1-7")
|
|
|
|
|
expectMsg("c-ea2-8")
|
|
|
|
|
expectMsg("c-e3-9")
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
expectNoMessage(100.millis)
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
|
|
|
|
"support a mix of persist calls (sync, async) and persist calls" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistAndPersistMixedSyncAsyncPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
|
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! Cmd("c")
|
2014-05-21 01:35:21 +02:00
|
|
|
expectMsg("a")
|
|
|
|
|
expectMsg("a-e1-1") // persist, must be before next command
|
|
|
|
|
|
|
|
|
|
var expectInAnyOrder1 = Set("b", "a-ea2-2")
|
|
|
|
|
expectInAnyOrder1 -= expectMsgAnyOf(expectInAnyOrder1.toList: _*) // ea2 is persistAsync, b (command) can processed before it
|
|
|
|
|
expectMsgAnyOf(expectInAnyOrder1.toList: _*)
|
|
|
|
|
|
|
|
|
|
expectMsg("b-e1-3") // persist, must be before next command
|
|
|
|
|
|
|
|
|
|
var expectInAnyOrder2 = Set("c", "b-ea2-4")
|
|
|
|
|
expectInAnyOrder2 -= expectMsgAnyOf(expectInAnyOrder2.toList: _*) // ea2 is persistAsync, b (command) can processed before it
|
|
|
|
|
expectMsgAnyOf(expectInAnyOrder2.toList: _*)
|
|
|
|
|
|
|
|
|
|
expectMsg("c-e1-5")
|
|
|
|
|
expectMsg("c-ea2-6")
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
expectNoMessage(100.millis)
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
2014-06-26 17:35:46 +02:00
|
|
|
"correlate persistAsync handlers after restart" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = asyncPersistHandlerCorrelationCheck
|
2019-02-09 15:25:39 +01:00
|
|
|
for (n <- 1 to 100) persistentActor ! Cmd(n)
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! "boom"
|
2019-02-09 15:25:39 +01:00
|
|
|
for (n <- 1 to 20) persistentActor ! Cmd(n)
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("done")
|
2014-06-26 17:35:46 +02:00
|
|
|
expectMsg(5.seconds, "done")
|
|
|
|
|
}
|
2014-06-03 16:40:44 +02:00
|
|
|
"allow deferring handlers in order to provide ordered processing in respect to persist handlers" in {
|
2018-02-05 22:36:26 +01:00
|
|
|
def test(actor: ActorRef): Unit = {
|
|
|
|
|
actor ! Cmd("a")
|
|
|
|
|
expectMsg("d-1")
|
|
|
|
|
expectMsg("a-2")
|
|
|
|
|
expectMsg("d-3")
|
|
|
|
|
expectMsg("d-4")
|
2019-03-21 12:42:29 -07:00
|
|
|
expectNoMessage(100.millis)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
test(deferringAsyncWithPersistActor)
|
|
|
|
|
test(deferringSyncWithPersistActor)
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
"allow deferring handlers in order to provide ordered processing in respect to asyncPersist handlers" in {
|
2018-02-05 22:36:26 +01:00
|
|
|
def test(actor: ActorRef): Unit = {
|
|
|
|
|
actor ! Cmd("a")
|
|
|
|
|
expectMsg("d-a-1")
|
|
|
|
|
expectMsg("pa-a-2")
|
|
|
|
|
expectMsg("d-a-3")
|
|
|
|
|
expectMsg("d-a-4")
|
2019-03-21 12:42:29 -07:00
|
|
|
expectNoMessage(100.millis)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
test(deferringAsyncWithAsyncPersistActor)
|
|
|
|
|
test(deferringSyncWithAsyncPersistActor)
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
"invoke deferred handlers, in presence of mixed a long series persist / persistAsync calls" in {
|
2018-02-05 22:36:26 +01:00
|
|
|
def test(actor: ActorRef): Unit = {
|
|
|
|
|
val p1, p2 = TestProbe()
|
|
|
|
|
|
|
|
|
|
actor.tell(Cmd("a"), p1.ref)
|
|
|
|
|
actor.tell(Cmd("b"), p2.ref)
|
|
|
|
|
p1.expectMsg("p-a-1")
|
|
|
|
|
p1.expectMsg("pa-a-2")
|
|
|
|
|
p1.expectMsg("d-a-3")
|
|
|
|
|
p1.expectMsg("d-a-4")
|
|
|
|
|
p1.expectMsg("pa-a-5")
|
|
|
|
|
p1.expectMsg("d-a-6")
|
|
|
|
|
|
|
|
|
|
p2.expectMsg("p-b-1")
|
|
|
|
|
p2.expectMsg("pa-b-2")
|
|
|
|
|
p2.expectMsg("d-b-3")
|
|
|
|
|
p2.expectMsg("d-b-4")
|
|
|
|
|
p2.expectMsg("pa-b-5")
|
|
|
|
|
p2.expectMsg("d-b-6")
|
|
|
|
|
|
2019-03-21 12:42:29 -07:00
|
|
|
expectNoMessage(100.millis)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
2014-06-03 16:40:44 +02:00
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
test(deferringAsyncMixedCallsPPADDPADPersistActor)
|
|
|
|
|
test(deferringSyncMixedCallsPPADDPADPersistActor)
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
|
|
|
|
"invoke deferred handlers right away, if there are no pending persist handlers registered" in {
|
2018-02-05 22:36:26 +01:00
|
|
|
def test(actor: ActorRef): Unit = {
|
|
|
|
|
actor ! Cmd("a")
|
|
|
|
|
expectMsg("d-1")
|
|
|
|
|
expectMsg("d-2")
|
|
|
|
|
expectMsg("d-3")
|
2019-03-21 12:42:29 -07:00
|
|
|
expectNoMessage(100.millis)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
test(deferringAsyncWithNoPersistCallsPersistActor)
|
|
|
|
|
test(deferringSyncWithNoPersistCallsPersistActor)
|
2014-06-03 16:40:44 +02:00
|
|
|
}
|
2016-11-13 20:30:33 -05:00
|
|
|
"invoke deferred handlers, preserving the original sender references" in {
|
2018-02-05 22:36:26 +01:00
|
|
|
def test(actor: ActorRef): Unit = {
|
|
|
|
|
val p1, p2 = TestProbe()
|
|
|
|
|
|
|
|
|
|
actor.tell(Cmd("a"), p1.ref)
|
|
|
|
|
actor.tell(Cmd("b"), p2.ref)
|
|
|
|
|
p1.expectMsg("d-a-1")
|
|
|
|
|
p1.expectMsg("pa-a-2")
|
|
|
|
|
p1.expectMsg("d-a-3")
|
|
|
|
|
p1.expectMsg("d-a-4")
|
|
|
|
|
|
|
|
|
|
p2.expectMsg("d-b-1")
|
|
|
|
|
p2.expectMsg("pa-b-2")
|
|
|
|
|
p2.expectMsg("d-b-3")
|
|
|
|
|
p2.expectMsg("d-b-4")
|
2019-03-21 12:42:29 -07:00
|
|
|
expectNoMessage(100.millis)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
test(deferringAsyncWithAsyncPersistActor)
|
|
|
|
|
test(deferringSyncWithAsyncPersistActor)
|
2018-02-05 22:36:26 +01:00
|
|
|
}
|
|
|
|
|
"handle new messages before deferAsync handler is called" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = deferringAsyncActor
|
2018-02-05 22:36:26 +01:00
|
|
|
persistentActor ! Cmd("x")
|
|
|
|
|
persistentActor ! Cmd("y")
|
|
|
|
|
expectMsg("x")
|
|
|
|
|
expectMsg("y") // "y" command was processed before event persisted
|
|
|
|
|
expectMsg("x-defer")
|
|
|
|
|
expectMsg("y-defer")
|
|
|
|
|
}
|
|
|
|
|
"handle defer sequentially" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = deferringSyncActor
|
2018-02-05 22:36:26 +01:00
|
|
|
persistentActor ! Cmd("x")
|
|
|
|
|
persistentActor ! Cmd("y")
|
|
|
|
|
expectMsg("x")
|
|
|
|
|
expectMsg("x-defer")
|
|
|
|
|
expectMsg("y")
|
|
|
|
|
expectMsg("y-defer")
|
2014-05-21 01:35:21 +02:00
|
|
|
}
|
2014-06-05 14:07:17 +02:00
|
|
|
"receive RecoveryFinished if it is handled after all events have been replayed" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor1 = snapshottingPersistentActor
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! Cmd("b")
|
|
|
|
|
persistentActor1 ! "snap"
|
|
|
|
|
persistentActor1 ! Cmd("c")
|
2014-06-05 14:07:17 +02:00
|
|
|
expectMsg("saved")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor1 ! GetState
|
2014-06-05 14:07:17 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42"))
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor2 = handleRecoveryFinishedEventPersistentActor
|
2014-06-05 14:07:17 +02:00
|
|
|
expectMsg("offered")
|
|
|
|
|
expectMsg(RecoveryCompleted)
|
|
|
|
|
expectMsg("I am the stashed")
|
|
|
|
|
expectMsg("I am the recovered")
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor2 ! GetState
|
2014-06-05 14:07:17 +02:00
|
|
|
expectMsg(List("a-1", "a-2", "b-41", "b-42", "c-41", "c-42", RecoveryCompleted))
|
|
|
|
|
}
|
2016-11-13 20:30:33 -05:00
|
|
|
"preserve order of incoming messages" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = stressOrdering
|
2014-12-08 11:02:14 +01:00
|
|
|
persistentActor ! Cmd("a")
|
|
|
|
|
val latch = TestLatch(1)
|
|
|
|
|
persistentActor ! LatchCmd(latch, "b")
|
|
|
|
|
persistentActor ! "c"
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
expectMsg("b")
|
|
|
|
|
persistentActor ! "d"
|
|
|
|
|
latch.countDown()
|
|
|
|
|
expectMsg("c")
|
|
|
|
|
expectMsg("d")
|
|
|
|
|
}
|
2014-10-22 22:12:22 +02:00
|
|
|
"be used as a stackable modification" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = stackableTestPersistentActor
|
2014-10-22 22:12:22 +02:00
|
|
|
expectMsg("mixin aroundPreStart")
|
|
|
|
|
expectMsg("base aroundPreStart")
|
|
|
|
|
expectMsg("preStart")
|
|
|
|
|
|
|
|
|
|
persistentActor ! "restart"
|
2014-12-08 11:02:14 +01:00
|
|
|
expectMsg("mixin aroundReceive restart")
|
|
|
|
|
expectMsg("base aroundReceive restart")
|
2014-10-22 22:12:22 +02:00
|
|
|
|
|
|
|
|
expectMsg("mixin aroundPreRestart")
|
|
|
|
|
expectMsg("base aroundPreRestart")
|
|
|
|
|
expectMsg("preRestart")
|
|
|
|
|
expectMsg("postStop")
|
|
|
|
|
|
|
|
|
|
expectMsg("mixin aroundPostRestart")
|
|
|
|
|
expectMsg("base aroundPostRestart")
|
|
|
|
|
expectMsg("postRestart")
|
|
|
|
|
expectMsg("preStart")
|
|
|
|
|
|
|
|
|
|
persistentActor ! PoisonPill
|
|
|
|
|
expectMsg("mixin aroundPostStop")
|
|
|
|
|
expectMsg("base aroundPostStop")
|
|
|
|
|
expectMsg("postStop")
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
expectNoMessage(100.millis)
|
2014-10-22 22:12:22 +02:00
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
"allow multiple persists with nested persist calls" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = multipleAndNestedPersists
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
persistentActor ! "b"
|
|
|
|
|
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
expectMsg("a-outer-1")
|
|
|
|
|
expectMsg("a-outer-2")
|
|
|
|
|
expectMsg("a-inner-1")
|
|
|
|
|
expectMsg("a-inner-2")
|
|
|
|
|
// and only then process "b"
|
|
|
|
|
expectMsg("b")
|
|
|
|
|
expectMsg("b-outer-1")
|
|
|
|
|
expectMsg("b-outer-2")
|
|
|
|
|
expectMsg("b-inner-1")
|
|
|
|
|
expectMsg("b-inner-2")
|
|
|
|
|
}
|
|
|
|
|
"allow multiple persistAsyncs with nested persistAsync calls" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = multipleAndNestedPersistAsyncs
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
persistentActor ! "b"
|
|
|
|
|
|
|
|
|
|
val msgs = receiveN(10).map(_.toString)
|
2019-03-11 10:38:24 +01:00
|
|
|
val as = msgs.filter(_.startsWith("a"))
|
|
|
|
|
val bs = msgs.filter(_.startsWith("b"))
|
2015-06-24 19:58:43 +02:00
|
|
|
as should equal(List("a", "a-outer-1", "a-outer-2", "a-inner-1", "a-inner-2"))
|
|
|
|
|
bs should equal(List("b", "b-outer-1", "b-outer-2", "b-inner-1", "b-inner-2"))
|
|
|
|
|
}
|
|
|
|
|
"allow deeply nested persist calls" in {
|
|
|
|
|
val nestedPersists = 6
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = deeplyNestedPersists(nestedPersists)
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
persistentActor ! "b"
|
|
|
|
|
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
receiveN(6) should ===((1 to nestedPersists).map("a-" + _))
|
|
|
|
|
// and only then process "b"
|
|
|
|
|
expectMsg("b")
|
|
|
|
|
receiveN(6) should ===((1 to nestedPersists).map("b-" + _))
|
|
|
|
|
}
|
|
|
|
|
"allow deeply nested persistAsync calls" in {
|
|
|
|
|
val nestedPersistAsyncs = 6
|
|
|
|
|
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = deeplyNestedPersistAsyncs(nestedPersistAsyncs)
|
2015-06-24 19:58:43 +02:00
|
|
|
|
|
|
|
|
persistentActor ! "a"
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
val got = receiveN(nestedPersistAsyncs)
|
|
|
|
|
got should beIndependentlyOrdered("a-")
|
|
|
|
|
|
|
|
|
|
persistentActor ! "b"
|
|
|
|
|
persistentActor ! "c"
|
|
|
|
|
val expectedReplies = 2 + (nestedPersistAsyncs * 2)
|
|
|
|
|
receiveN(expectedReplies).map(_.toString) should beIndependentlyOrdered("b-", "c-")
|
|
|
|
|
}
|
|
|
|
|
"allow mixed nesting of persistAsync in persist calls" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = nestedPersistNormalAndAsyncs
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
receiveN(4) should equal(List("a-outer-1", "a-outer-2", "a-inner-async-1", "a-inner-async-2"))
|
|
|
|
|
}
|
|
|
|
|
"allow mixed nesting of persist in persistAsync calls" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = nestedPersistAsyncsAndNormal
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
receiveN(4) should equal(List("a-outer-async-1", "a-outer-async-2", "a-inner-1", "a-inner-2"))
|
|
|
|
|
}
|
2015-06-24 19:58:43 +02:00
|
|
|
"make sure persist retains promised semantics when nested in persistAsync callback" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = nestedPersistInAsyncEnforcesStashing
|
2015-06-24 19:58:43 +02:00
|
|
|
persistentActor ! "a"
|
|
|
|
|
|
|
|
|
|
expectMsg("a")
|
|
|
|
|
expectMsg("a-outer-async")
|
|
|
|
|
expectMsg("a-inner")
|
|
|
|
|
persistentActor ! "b"
|
|
|
|
|
expectMsg("done")
|
|
|
|
|
// which means that b only got applied after the inner persist() handler finished
|
|
|
|
|
// so it keeps the persist() semantics, even though we should not recommend this style it can come in handy I guess
|
|
|
|
|
}
|
2014-12-08 11:02:14 +01:00
|
|
|
|
2015-06-26 10:36:27 +02:00
|
|
|
"be able to delete events" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior1PersistentActor
|
2015-06-26 10:36:27 +02:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2"))
|
|
|
|
|
persistentActor ! Delete(2L) // delete "a-1" and "a-2"
|
|
|
|
|
persistentActor ! "boom" // restart, recover
|
2015-07-02 00:44:10 +02:00
|
|
|
expectMsgType[DeleteMessagesSuccess]
|
2015-06-26 10:36:27 +02:00
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("b-1", "b-2"))
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 08:32:26 +02:00
|
|
|
"be able to delete all events" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = behavior1PersistentActor
|
2015-09-17 08:32:26 +02:00
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2"))
|
|
|
|
|
persistentActor ! Delete(Long.MaxValue)
|
|
|
|
|
persistentActor ! "boom" // restart, recover
|
|
|
|
|
expectMsgType[DeleteMessagesSuccess]
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(Nil)
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 08:14:56 +02:00
|
|
|
"not be able to delete higher seqnr than current" in {
|
|
|
|
|
val persistentActor = behavior1PersistentActor
|
|
|
|
|
persistentActor ! Cmd("b")
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2"))
|
|
|
|
|
persistentActor ! Delete(5L) // > current 4
|
|
|
|
|
persistentActor ! "boom" // restart, recover
|
|
|
|
|
expectMsgType[DeleteMessagesFailure].cause.getMessage should include("less than or equal to lastSequenceNr")
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("a-1", "a-2", "b-1", "b-2"))
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-13 20:30:33 -05:00
|
|
|
"recover the message which caused the restart" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = recoverMessageCausedRestart
|
2016-11-13 20:30:33 -05:00
|
|
|
persistentActor ! "Boom"
|
|
|
|
|
expectMsg("failed with TestException while processing Boom")
|
|
|
|
|
}
|
2016-12-14 17:32:27 +05:00
|
|
|
|
|
|
|
|
"be able to persist events that happen during recovery" in {
|
2018-03-26 13:52:31 +02:00
|
|
|
val persistentActor = persistInRecovery
|
2016-12-14 17:32:27 +05:00
|
|
|
persistentActor ! GetState
|
2017-01-26 19:11:08 +05:00
|
|
|
expectMsgAnyOf(List("a-1", "a-2", "rc-1", "rc-2"), List("a-1", "a-2", "rc-1", "rc-2", "rc-3"))
|
2016-12-14 17:32:27 +05:00
|
|
|
persistentActor ! Cmd("invalid")
|
|
|
|
|
persistentActor ! GetState
|
|
|
|
|
expectMsg(List("a-1", "a-2", "rc-1", "rc-2", "rc-3", "invalid"))
|
|
|
|
|
watch(persistentActor)
|
|
|
|
|
persistentActor ! "boom"
|
|
|
|
|
expectTerminated(persistentActor)
|
|
|
|
|
}
|
2018-02-22 01:20:52 +09:00
|
|
|
|
|
|
|
|
"stop actor when direct exception from receiveRecover" in {
|
|
|
|
|
val persistentActor = namedPersistentActor[ExceptionActor]
|
|
|
|
|
watch(persistentActor)
|
|
|
|
|
expectTerminated(persistentActor)
|
|
|
|
|
}
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
2014-10-22 22:12:22 +02:00
|
|
|
|
2013-10-15 09:01:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
class LeveldbPersistentActorSpec
|
|
|
|
|
extends PersistentActorSpec(PersistenceSpec.config("leveldb", "LeveldbPersistentActorSpec"))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
2014-06-05 14:07:17 +02:00
|
|
|
class InmemPersistentActorSpec extends PersistentActorSpec(PersistenceSpec.config("inmem", "InmemPersistentActorSpec"))
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Same test suite as [[LeveldbPersistentActorSpec]], the only difference is that all persistent actors are using the
|
|
|
|
|
* provided [[Config]] instead of the [[Config]] coming from the [[ActorSystem]].
|
|
|
|
|
*/
|
2019-03-11 10:38:24 +01:00
|
|
|
class LeveldbPersistentActorWithRuntimePluginConfigSpec
|
|
|
|
|
extends PersistentActorSpec(PersistenceSpec.config("leveldb", "LeveldbPersistentActorWithRuntimePluginConfigSpec")) {
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
val providedActorConfig: Config = {
|
2019-03-11 10:38:24 +01:00
|
|
|
ConfigFactory
|
|
|
|
|
.parseString(s"""
|
2018-03-26 13:52:31 +02:00
|
|
|
| custom.persistence.journal.leveldb.dir = target/journal-LeveldbPersistentActorWithRuntimePluginConfigSpec
|
|
|
|
|
| custom.persistence.snapshot-store.local.dir = target/snapshots-LeveldbPersistentActorWithRuntimePluginConfigSpec/
|
2019-03-11 10:38:24 +01:00
|
|
|
""".stripMargin)
|
2019-03-13 10:56:20 +01:00
|
|
|
.withValue(
|
|
|
|
|
s"custom.persistence.journal.leveldb",
|
|
|
|
|
system.settings.config.getValue(s"akka.persistence.journal.leveldb"))
|
|
|
|
|
.withValue(
|
|
|
|
|
"custom.persistence.snapshot-store.local",
|
|
|
|
|
system.settings.config.getValue("akka.persistence.snapshot-store.local"))
|
2018-03-26 13:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
override protected def behavior1PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior1PersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def behavior2PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior2PersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def behavior3PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior3PersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInFirstEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInFirstEventHandlerPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInLastEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInLastEventHandlerPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInCommandHandlerFirstPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInCommandHandlerFirstPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInCommandHandlerLastPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInCommandHandlerLastPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def snapshottingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[SnapshottingPersistentActorWithLevelDbRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def snapshottingBecomingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[SnapshottingBecomingPersistentActorWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def replyInEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[ReplyInEventHandlerPersistentActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
2019-03-13 14:24:04 +01:00
|
|
|
override protected def primitiveEventPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PrimitiveEventPersistentActorWithLevelDbRuntimePluginConfig](
|
2019-03-11 10:38:24 +01:00
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistPersistentActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistThreeTimesPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistThreeTimesPersistentActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistSameEventTwicePersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistSameEventTwicePersistentActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def persistAllNilPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PersistAllNilPersistentActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistAndPersistMixedSyncAsyncSyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistAndPersistMixedSyncAsyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
AsyncPersistAndPersistMixedSyncAsyncPersistentActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistHandlerCorrelationCheck: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistHandlerCorrelationCheckWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def handleRecoveryFinishedEventPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[HandleRecoveryFinishedEventPersistentActorWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def stressOrdering: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[StressOrderingWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def stackableTestPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[StackableTestPersistentActorWithLevelDbRuntimePluginConfig], testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def multipleAndNestedPersists: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[MultipleAndNestedPersistsWithLevelDbRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def multipleAndNestedPersistAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[MultipleAndNestedPersistAsyncsWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def deeplyNestedPersists(nestedPersists: Int): ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[DeeplyNestedPersistsWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
nestedPersists,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def deeplyNestedPersistAsyncs(nestedPersistAsyncs: Int): ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[DeeplyNestedPersistAsyncsWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
nestedPersistAsyncs,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def nestedPersistNormalAndAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[NestedPersistNormalAndAsyncsWithLevelDbRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def nestedPersistAsyncsAndNormal: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[NestedPersistAsyncsAndNormalWithLevelDbRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def nestedPersistInAsyncEnforcesStashing: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[NestedPersistInAsyncEnforcesStashingWithLevelDbRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def persistInRecovery: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PersistInRecoveryWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def recoverMessageCausedRestart: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[RecoverMessageCausedRestartWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithAsyncPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithAsyncPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithAsyncPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithAsyncPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncMixedCallsPPADDPADPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncMixedCallsPPADDPADPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithNoPersistCallsPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithNoPersistCallsPersistActorWithLevelDbRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncActorWithLevelDbRuntimePluginConfig](providedActorConfig)
|
2018-03-26 13:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Same test suite as [[InmemPersistentActorSpec]], the only difference is that all persistent actors are using the
|
|
|
|
|
* provided [[Config]] instead of the [[Config]] coming from the [[ActorSystem]].
|
|
|
|
|
*/
|
2019-03-11 10:38:24 +01:00
|
|
|
class InmemPersistentActorWithRuntimePluginConfigSpec
|
|
|
|
|
extends PersistentActorSpec(PersistenceSpec.config("inmem", "InmemPersistentActorWithRuntimePluginConfigSpec")) {
|
2018-03-26 13:52:31 +02:00
|
|
|
|
|
|
|
|
val providedActorConfig: Config = {
|
2019-03-11 10:38:24 +01:00
|
|
|
ConfigFactory
|
|
|
|
|
.parseString(s"""
|
2018-03-26 13:52:31 +02:00
|
|
|
| custom.persistence.snapshot-store.local.dir = target/snapshots-InmemPersistentActorWithRuntimePluginConfigSpec/
|
2019-03-11 10:38:24 +01:00
|
|
|
""".stripMargin)
|
2019-03-13 10:56:20 +01:00
|
|
|
.withValue(
|
|
|
|
|
s"custom.persistence.journal.inmem",
|
|
|
|
|
system.settings.config.getValue(s"akka.persistence.journal.inmem"))
|
|
|
|
|
.withValue(
|
|
|
|
|
"custom.persistence.snapshot-store.local",
|
|
|
|
|
system.settings.config.getValue("akka.persistence.snapshot-store.local"))
|
2018-03-26 13:52:31 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-11 10:38:24 +01:00
|
|
|
override protected def behavior1PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior1PersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def behavior2PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior2PersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def behavior3PersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[Behavior3PersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInFirstEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInFirstEventHandlerPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInLastEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[ChangeBehaviorInLastEventHandlerPersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInCommandHandlerFirstPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInCommandHandlerFirstPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def changeBehaviorInCommandHandlerLastPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
ChangeBehaviorInCommandHandlerLastPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def snapshottingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[SnapshottingPersistentActorWithInmemRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def snapshottingBecomingPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[SnapshottingBecomingPersistentActorWithInmemRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def replyInEventHandlerPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[ReplyInEventHandlerPersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
2019-03-13 14:24:04 +01:00
|
|
|
override protected def primitiveEventPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PrimitiveEventPersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def asyncPersistPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistThreeTimesPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistThreeTimesPersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistSameEventTwicePersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistSameEventTwicePersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def persistAllNilPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PersistAllNilPersistentActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistAndPersistMixedSyncAsyncSyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
AsyncPersistAndPersistMixedSyncAsyncSyncPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistAndPersistMixedSyncAsyncPersistentActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[
|
|
|
|
|
AsyncPersistAndPersistMixedSyncAsyncPersistentActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def asyncPersistHandlerCorrelationCheck: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[AsyncPersistHandlerCorrelationCheckWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def handleRecoveryFinishedEventPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[HandleRecoveryFinishedEventPersistentActorWithInmemRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def stressOrdering: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[StressOrderingWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def stackableTestPersistentActor: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[StackableTestPersistentActorWithInmemRuntimePluginConfig], testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def multipleAndNestedPersists: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[MultipleAndNestedPersistsWithInmemRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def multipleAndNestedPersistAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[MultipleAndNestedPersistAsyncsWithInmemRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def deeplyNestedPersists(nestedPersists: Int): ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[DeeplyNestedPersistsWithInmemRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
nestedPersists,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def deeplyNestedPersistAsyncs(nestedPersistAsyncs: Int): ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[DeeplyNestedPersistAsyncsWithInmemRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
nestedPersistAsyncs,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def nestedPersistNormalAndAsyncs: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[NestedPersistNormalAndAsyncsWithInmemRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def nestedPersistAsyncsAndNormal: ActorRef =
|
|
|
|
|
system.actorOf(
|
|
|
|
|
Props(classOf[NestedPersistAsyncsAndNormalWithInmemRuntimePluginConfig], name, testActor, providedActorConfig))
|
|
|
|
|
|
|
|
|
|
override protected def nestedPersistInAsyncEnforcesStashing: ActorRef =
|
|
|
|
|
system.actorOf(
|
2019-03-13 10:56:20 +01:00
|
|
|
Props(
|
|
|
|
|
classOf[NestedPersistInAsyncEnforcesStashingWithInmemRuntimePluginConfig],
|
|
|
|
|
name,
|
|
|
|
|
testActor,
|
|
|
|
|
providedActorConfig))
|
2019-03-11 10:38:24 +01:00
|
|
|
|
|
|
|
|
override protected def persistInRecovery: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[PersistInRecoveryWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def recoverMessageCausedRestart: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[RecoverMessageCausedRestartWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithAsyncPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithAsyncPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithAsyncPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithAsyncPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncMixedCallsPPADDPADPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncMixedCallsPPADDPADPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncMixedCallsPPADDPADPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncWithNoPersistCallsPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncWithNoPersistCallsPersistActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncWithNoPersistCallsPersistActorWithInmemRuntimePluginConfig](
|
|
|
|
|
providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringAsyncActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringAsyncActorWithInmemRuntimePluginConfig](providedActorConfig)
|
|
|
|
|
|
|
|
|
|
override protected def deferringSyncActor: ActorRef =
|
|
|
|
|
namedPersistentActorWithProvidedConfig[DeferringSyncActorWithInmemRuntimePluginConfig](providedActorConfig)
|
2018-03-26 13:52:31 +02:00
|
|
|
}
|