Merge pull request #1939 from krasserm/wip-3828-rename-recreiveReplay-krasserm

!per #3828 Rename receiveReplay to receiveRecover
This commit is contained in:
Patrik Nordwall 2014-01-20 02:53:51 -08:00
commit 10fbdd2db8
13 changed files with 30 additions and 30 deletions

View file

@ -1141,7 +1141,7 @@ class ShardCoordinator(handOffTimeout: FiniteDuration, rebalanceInterval: Finite
rebalanceTask.cancel() rebalanceTask.cancel()
} }
override def receiveReplay: Receive = { override def receiveRecover: Receive = {
case evt: DomainEvent evt match { case evt: DomainEvent evt match {
case ShardRegionRegistered(region) case ShardRegionRegistered(region)
context.watch(region) context.watch(region)

View file

@ -91,7 +91,7 @@ object ClusterShardingSpec extends MultiNodeConfig {
def updateState(event: CounterChanged): Unit = def updateState(event: CounterChanged): Unit =
count += event.delta count += event.delta
override def receiveReplay: Receive = { override def receiveRecover: Receive = {
case evt: CounterChanged updateState(evt) case evt: CounterChanged updateState(evt)
} }

View file

@ -124,7 +124,7 @@ public class ClusterShardingTest {
} }
@Override @Override
public void onReceiveReplay(Object msg) { public void onReceiveRecover(Object msg) {
if (msg instanceof CounterChanged) if (msg instanceof CounterChanged)
updateState((CounterChanged) msg); updateState((CounterChanged) msg);
else else

View file

@ -336,7 +336,7 @@ public class PersistenceDocTest {
event, getCurrentPersistentMessage()), destination.path()), getSelf()); event, getCurrentPersistentMessage()), destination.path()), getSelf());
} }
public void onReceiveReplay(Object msg) { public void onReceiveRecover(Object msg) {
if (msg instanceof String) { if (msg instanceof String) {
handleEvent((String)msg); handleEvent((String)msg);
} }

View file

@ -434,7 +434,7 @@ also process commands that do not change application state, such as query comman
Akka persistence supports event sourcing with the abstract ``UntypedEventsourcedProcessor`` class (which implements Akka persistence supports event sourcing with the abstract ``UntypedEventsourcedProcessor`` class (which implements
event sourcing as a pattern on top of command sourcing). A processor that extends this abstract class does not handle event sourcing as a pattern on top of command sourcing). A processor that extends this abstract class does not handle
``Persistent`` messages directly but uses the ``persist`` method to persist and handle events. The behavior of an ``Persistent`` messages directly but uses the ``persist`` method to persist and handle events. The behavior of an
``UntypedEventsourcedProcessor`` is defined by implementing ``onReceiveReplay`` and ``onReceiveCommand``. This is ``UntypedEventsourcedProcessor`` is defined by implementing ``onReceiveRecover`` and ``onReceiveCommand``. This is
demonstrated in the following example. demonstrated in the following example.
.. includecode:: ../../../akka-samples/akka-sample-persistence/src/main/java/sample/persistence/japi/EventsourcedExample.java#eventsourced-example .. includecode:: ../../../akka-samples/akka-sample-persistence/src/main/java/sample/persistence/japi/EventsourcedExample.java#eventsourced-example
@ -442,7 +442,7 @@ demonstrated in the following example.
The example defines two data types, ``Cmd`` and ``Evt`` to represent commands and events, respectively. The The example defines two data types, ``Cmd`` and ``Evt`` to represent commands and events, respectively. The
``state`` of the ``ExampleProcessor`` is a list of persisted event data contained in ``ExampleState``. ``state`` of the ``ExampleProcessor`` is a list of persisted event data contained in ``ExampleState``.
The processor's ``onReceiveReplay`` method defines how ``state`` is updated during recovery by handling ``Evt`` The processor's ``onReceiveRecover`` method defines how ``state`` is updated during recovery by handling ``Evt``
and ``SnapshotOffer`` messages. The processor's ``onReceiveCommand`` method is a command handler. In this example, and ``SnapshotOffer`` messages. The processor's ``onReceiveCommand`` method is a command handler. In this example,
a command is handled by generating two events which are then persisted and handled. Events are persisted by calling a command is handled by generating two events which are then persisted and handled. Events are persisted by calling
``persist`` with an event (or a sequence of events) as first argument and an event handler as second argument. ``persist`` with an event (or a sequence of events) as first argument and an event handler as second argument.
@ -465,7 +465,7 @@ Reliable event delivery
----------------------- -----------------------
Sending events from an event handler to another actor has at-most-once delivery semantics. For at-least-once delivery, Sending events from an event handler to another actor has at-most-once delivery semantics. For at-least-once delivery,
:ref:`channels-java` must be used. In this case, also replayed events (received by ``receiveReplay``) must be sent to a :ref:`channels-java` must be used. In this case, also replayed events (received by ``receiveRecover``) must be sent to a
channel, as shown in the following example: channel, as shown in the following example:
.. includecode:: code/docs/persistence/PersistenceDocTest.java#reliable-event-delivery .. includecode:: code/docs/persistence/PersistenceDocTest.java#reliable-event-delivery

View file

@ -295,7 +295,7 @@ trait PersistenceDocSpec {
channel ! Deliver(Persistent(event), destination.path) channel ! Deliver(Persistent(event), destination.path)
} }
def receiveReplay: Receive = { def receiveRecover: Receive = {
case event: String => handleEvent(event) case event: String => handleEvent(event)
} }

View file

@ -445,14 +445,14 @@ also process commands that do not change application state, such as query comman
Akka persistence supports event sourcing with the ``EventsourcedProcessor`` trait (which implements event sourcing Akka persistence supports event sourcing with the ``EventsourcedProcessor`` trait (which implements event sourcing
as a pattern on top of command sourcing). A processor that extends this trait does not handle ``Persistent`` messages as a pattern on top of command sourcing). A processor that extends this trait does not handle ``Persistent`` messages
directly but uses the ``persist`` method to persist and handle events. The behavior of an ``EventsourcedProcessor`` directly but uses the ``persist`` method to persist and handle events. The behavior of an ``EventsourcedProcessor``
is defined by implementing ``receiveReplay`` and ``receiveCommand``. This is demonstrated in the following example. is defined by implementing ``receiveRecover`` and ``receiveCommand``. This is demonstrated in the following example.
.. includecode:: ../../../akka-samples/akka-sample-persistence/src/main/scala/sample/persistence/EventsourcedExample.scala#eventsourced-example .. includecode:: ../../../akka-samples/akka-sample-persistence/src/main/scala/sample/persistence/EventsourcedExample.scala#eventsourced-example
The example defines two data types, ``Cmd`` and ``Evt`` to represent commands and events, respectively. The The example defines two data types, ``Cmd`` and ``Evt`` to represent commands and events, respectively. The
``state`` of the ``ExampleProcessor`` is a list of persisted event data contained in ``ExampleState``. ``state`` of the ``ExampleProcessor`` is a list of persisted event data contained in ``ExampleState``.
The processor's ``receiveReplay`` method defines how ``state`` is updated during recovery by handling ``Evt`` The processor's ``receiveRecover`` method defines how ``state`` is updated during recovery by handling ``Evt``
and ``SnapshotOffer`` messages. The processor's ``receiveCommand`` method is a command handler. In this example, and ``SnapshotOffer`` messages. The processor's ``receiveCommand`` method is a command handler. In this example,
a command is handled by generating two events which are then persisted and handled. Events are persisted by calling a command is handled by generating two events which are then persisted and handled. Events are persisted by calling
``persist`` with an event (or a sequence of events) as first argument and an event handler as second argument. ``persist`` with an event (or a sequence of events) as first argument and an event handler as second argument.
@ -475,7 +475,7 @@ Reliable event delivery
----------------------- -----------------------
Sending events from an event handler to another actor has at-most-once delivery semantics. For at-least-once delivery, Sending events from an event handler to another actor has at-most-once delivery semantics. For at-least-once delivery,
:ref:`channels` must be used. In this case, also replayed events (received by ``receiveReplay``) must be sent to a :ref:`channels` must be used. In this case, also replayed events (received by ``receiveRecover``) must be sent to a
channel, as shown in the following example: channel, as shown in the following example:
.. includecode:: code/docs/persistence/PersistenceDocSpec.scala#reliable-event-delivery .. includecode:: code/docs/persistence/PersistenceDocSpec.scala#reliable-event-delivery

View file

@ -137,7 +137,7 @@ private[persistence] trait Eventsourced extends Processor {
events.foreach(persist(_)(handler)) events.foreach(persist(_)(handler))
/** /**
* Replay handler that receives persisted events during recovery. If a state snapshot * Recovery handler that receives persisted events during recovery. If a state snapshot
* has been captured and saved, this handler will receive a [[SnapshotOffer]] message * has been captured and saved, this handler will receive a [[SnapshotOffer]] message
* followed by events that are younger than the offered snapshot. * followed by events that are younger than the offered snapshot.
* *
@ -147,7 +147,7 @@ private[persistence] trait Eventsourced extends Processor {
* *
* @see [[Recover]] * @see [[Recover]]
*/ */
def receiveReplay: Receive def receiveRecover: Receive
/** /**
* Command handler. Typically validates commands against current state (and/or by * Command handler. Typically validates commands against current state (and/or by
@ -191,12 +191,12 @@ private[persistence] trait Eventsourced extends Processor {
* INTERNAL API. * INTERNAL API.
*/ */
protected[persistence] val initialBehavior: Receive = { protected[persistence] val initialBehavior: Receive = {
case Persistent(payload, _) if receiveReplay.isDefinedAt(payload) && recoveryRunning case Persistent(payload, _) if receiveRecover.isDefinedAt(payload) && recoveryRunning
receiveReplay(payload) receiveRecover(payload)
case s: SnapshotOffer if receiveReplay.isDefinedAt(s) case s: SnapshotOffer if receiveRecover.isDefinedAt(s)
receiveReplay(s) receiveRecover(s)
case f: RecoveryFailure if receiveReplay.isDefinedAt(f) case f: RecoveryFailure if receiveRecover.isDefinedAt(f)
receiveReplay(f) receiveRecover(f)
case msg if receiveCommand.isDefinedAt(msg) case msg if receiveCommand.isDefinedAt(msg)
receiveCommand(msg) receiveCommand(msg)
} }
@ -215,8 +215,8 @@ trait EventsourcedProcessor extends Processor with Eventsourced {
abstract class UntypedEventsourcedProcessor extends UntypedProcessor with Eventsourced { abstract class UntypedEventsourcedProcessor extends UntypedProcessor with Eventsourced {
final def onReceive(message: Any) = initialBehavior(message) final def onReceive(message: Any) = initialBehavior(message)
final def receiveReplay: Receive = { final def receiveRecover: Receive = {
case msg onReceiveReplay(msg) case msg onReceiveRecover(msg)
} }
final def receiveCommand: Receive = { final def receiveCommand: Receive = {
@ -260,7 +260,7 @@ abstract class UntypedEventsourcedProcessor extends UntypedProcessor with Events
persist(Util.immutableSeq(events))(event handler(event)) persist(Util.immutableSeq(events))(event handler(event))
/** /**
* Java API: replay handler that receives persisted events during recovery. If a state snapshot * Java API: recovery handler that receives persisted events during recovery. If a state snapshot
* has been captured and saved, this handler will receive a [[SnapshotOffer]] message * has been captured and saved, this handler will receive a [[SnapshotOffer]] message
* followed by events that are younger than the offered snapshot. * followed by events that are younger than the offered snapshot.
* *
@ -270,7 +270,7 @@ abstract class UntypedEventsourcedProcessor extends UntypedProcessor with Events
* *
* @see [[Recover]] * @see [[Recover]]
*/ */
def onReceiveReplay(msg: Any): Unit def onReceiveRecover(msg: Any): Unit
/** /**
* Java API: command handler. Typically validates commands against current state (and/or by * Java API: command handler. Typically validates commands against current state (and/or by

View file

@ -28,7 +28,7 @@ object EventsourcedSpec {
case GetState sender ! events.reverse case GetState sender ! events.reverse
} }
def receiveReplay = updateState def receiveRecover = updateState
} }
class Behavior1Processor(name: String) extends ExampleProcessor(name) { class Behavior1Processor(name: String) extends ExampleProcessor(name) {
@ -123,7 +123,7 @@ object EventsourcedSpec {
} }
class SnapshottingEventsourcedProcessor(name: String, probe: ActorRef) extends ExampleProcessor(name) { class SnapshottingEventsourcedProcessor(name: String, probe: ActorRef) extends ExampleProcessor(name) {
override def receiveReplay = super.receiveReplay orElse { override def receiveRecover = super.receiveRecover orElse {
case SnapshotOffer(_, events: List[_]) case SnapshotOffer(_, events: List[_])
probe ! "offered" probe ! "offered"
this.events = events this.events = events

View file

@ -86,7 +86,7 @@ object PerformanceSpec {
} }
class EventsourcedTestProcessor(name: String) extends PerformanceTestProcessor(name) with EventsourcedProcessor { class EventsourcedTestProcessor(name: String) extends PerformanceTestProcessor(name) with EventsourcedProcessor {
val receiveReplay: Receive = { val receiveRecover: Receive = {
case _ if (lastSequenceNr % 1000 == 0) print("r") case _ if (lastSequenceNr % 1000 == 0) print("r")
} }
@ -99,7 +99,7 @@ object PerformanceSpec {
} }
class StashingEventsourcedTestProcessor(name: String) extends PerformanceTestProcessor(name) with EventsourcedProcessor { class StashingEventsourcedTestProcessor(name: String) extends PerformanceTestProcessor(name) with EventsourcedProcessor {
val receiveReplay: Receive = { val receiveRecover: Receive = {
case _ if (lastSequenceNr % 1000 == 0) print("r") case _ if (lastSequenceNr % 1000 == 0) print("r")
} }

View file

@ -53,7 +53,7 @@ object ProcessorChannelSpec {
channel ! Deliver(Persistent(event), destination.path) channel ! Deliver(Persistent(event), destination.path)
} }
def receiveReplay: Receive = { def receiveRecover: Receive = {
case event: String handleEvent(event) case event: String handleEvent(event)
} }

View file

@ -70,7 +70,7 @@ class ExampleProcessor extends UntypedEventsourcedProcessor {
return state.size(); return state.size();
} }
public void onReceiveReplay(Object msg) { public void onReceiveRecover(Object msg) {
if (msg instanceof Evt) { if (msg instanceof Evt) {
state.update((Evt) msg); state.update((Evt) msg);
} else if (msg instanceof SnapshotOffer) { } else if (msg instanceof SnapshotOffer) {

View file

@ -26,7 +26,7 @@ class ExampleProcessor extends EventsourcedProcessor {
def numEvents = def numEvents =
state.size state.size
val receiveReplay: Receive = { val receiveRecover: Receive = {
case evt: Evt => updateState(evt) case evt: Evt => updateState(evt)
case SnapshotOffer(_, snapshot: ExampleState) => state = snapshot case SnapshotOffer(_, snapshot: ExampleState) => state = snapshot
} }